forked from web-infra-dev/rsdoctor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodern.base.config.ts
85 lines (77 loc) · 1.61 KB
/
modern.base.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import {
defineConfig,
moduleTools,
type PartialBaseBuildConfig,
} from '@modern-js/module-tools';
import path from 'path';
const define = {
RSDOCTOR_VERSION: require('../packages/core/package.json').version,
};
const BUILD_TARGET = 'es2020' as const;
export const baseBuildConfig = {
plugins: [moduleTools()],
buildConfig: {
buildType: 'bundleless' as const,
format: 'cjs' as const,
target: BUILD_TARGET,
define,
},
};
export default defineConfig(baseBuildConfig);
export const buildConfigWithMjs: PartialBaseBuildConfig[] = [
{
format: 'cjs',
target: BUILD_TARGET,
define,
autoExtension: true,
dts: {
respectExternal: false,
},
},
{
format: 'esm',
target: BUILD_TARGET,
dts: false,
define,
autoExtension: true,
shims: true,
esbuildOptions: (option) => {
let { inject } = option;
const filepath = path.join(__dirname, 'requireShims.js');
if (inject) {
inject.push(filepath);
} else {
inject = [filepath];
}
return {
...option,
inject,
};
},
},
];
export const configWithMjs = defineConfig({
plugins: [moduleTools()],
buildConfig: buildConfigWithMjs,
});
export const configWithEsm = defineConfig({
plugins: [moduleTools()],
buildConfig: [
{
buildType: 'bundleless',
format: 'cjs',
target: BUILD_TARGET,
outDir: './dist/cjs',
dts: {
distPath: '../type',
},
},
{
buildType: 'bundleless',
format: 'esm',
target: BUILD_TARGET,
outDir: './dist/esm',
dts: false,
},
],
});