@deot/dev-builder 2.5.2 → 2.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -2
- package/dist/index.es.js +4 -2
- package/package.json +1 -1
- package/shared.config.ts +33 -6
package/dist/index.cjs
CHANGED
|
@@ -58,7 +58,7 @@ const run$3 = async (options) => {
|
|
|
58
58
|
isVuePackage,
|
|
59
59
|
isReactPackage
|
|
60
60
|
} = options || {};
|
|
61
|
-
const { scriptFormats } = commandOptions;
|
|
61
|
+
const { scriptFormats, external, globals } = commandOptions;
|
|
62
62
|
const stats = [];
|
|
63
63
|
let files = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
|
|
64
64
|
if (!files.length)
|
|
@@ -67,6 +67,8 @@ const run$3 = async (options) => {
|
|
|
67
67
|
const buildOptions = {
|
|
68
68
|
files,
|
|
69
69
|
format,
|
|
70
|
+
external,
|
|
71
|
+
globals,
|
|
70
72
|
workspace,
|
|
71
73
|
packageName,
|
|
72
74
|
packageDir,
|
|
@@ -267,7 +269,7 @@ class Build {
|
|
|
267
269
|
this.commandOptions = commandOptions;
|
|
268
270
|
const { reactPackage, vuePackage, nodePackage } = commandOptions;
|
|
269
271
|
this.isVuePackage = typeof vuePackage === "string" && (vuePackage === "*" || vuePackage.split(",").includes(this.packageName));
|
|
270
|
-
this.isReactPackage = typeof
|
|
272
|
+
this.isReactPackage = typeof reactPackage === "string" && (reactPackage === "*" || reactPackage.split(",").includes(this.packageName));
|
|
271
273
|
this.isNodePackage = typeof nodePackage === "string" && (nodePackage === "*" || nodePackage.split(",").includes(this.packageName));
|
|
272
274
|
}
|
|
273
275
|
async process() {
|
package/dist/index.es.js
CHANGED
|
@@ -33,7 +33,7 @@ const run$3 = async (options) => {
|
|
|
33
33
|
isVuePackage,
|
|
34
34
|
isReactPackage
|
|
35
35
|
} = options || {};
|
|
36
|
-
const { scriptFormats } = commandOptions;
|
|
36
|
+
const { scriptFormats, external, globals } = commandOptions;
|
|
37
37
|
const stats = [];
|
|
38
38
|
let files = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
|
|
39
39
|
if (!files.length)
|
|
@@ -42,6 +42,8 @@ const run$3 = async (options) => {
|
|
|
42
42
|
const buildOptions = {
|
|
43
43
|
files,
|
|
44
44
|
format,
|
|
45
|
+
external,
|
|
46
|
+
globals,
|
|
45
47
|
workspace,
|
|
46
48
|
packageName,
|
|
47
49
|
packageDir,
|
|
@@ -242,7 +244,7 @@ class Build {
|
|
|
242
244
|
this.commandOptions = commandOptions;
|
|
243
245
|
const { reactPackage, vuePackage, nodePackage } = commandOptions;
|
|
244
246
|
this.isVuePackage = typeof vuePackage === "string" && (vuePackage === "*" || vuePackage.split(",").includes(this.packageName));
|
|
245
|
-
this.isReactPackage = typeof
|
|
247
|
+
this.isReactPackage = typeof reactPackage === "string" && (reactPackage === "*" || reactPackage.split(",").includes(this.packageName));
|
|
246
248
|
this.isNodePackage = typeof nodePackage === "string" && (nodePackage === "*" || nodePackage.split(",").includes(this.packageName));
|
|
247
249
|
}
|
|
248
250
|
async process() {
|
package/package.json
CHANGED
package/shared.config.ts
CHANGED
|
@@ -15,6 +15,8 @@ const buildOptions = JSON.parse(decodeURIComponent(process.env.BUILD_OPTIONS ||
|
|
|
15
15
|
|
|
16
16
|
const {
|
|
17
17
|
format,
|
|
18
|
+
external = '',
|
|
19
|
+
globals = '',
|
|
18
20
|
workspace,
|
|
19
21
|
files = [],
|
|
20
22
|
packageName,
|
|
@@ -22,7 +24,8 @@ const {
|
|
|
22
24
|
packageOptions = {}
|
|
23
25
|
} = buildOptions;
|
|
24
26
|
|
|
25
|
-
const
|
|
27
|
+
const usedForBrowser = /(iife|umd)/.test(format);
|
|
28
|
+
const external$ = !usedForBrowser
|
|
26
29
|
? [
|
|
27
30
|
/^node:/,
|
|
28
31
|
/^[a-zA-Z@]/,
|
|
@@ -33,13 +36,15 @@ const external = /(cjs|es)/.test(format)
|
|
|
33
36
|
})
|
|
34
37
|
.map(i => new RegExp(`^${i}$`))
|
|
35
38
|
]
|
|
36
|
-
:
|
|
39
|
+
: external.split(',')
|
|
40
|
+
.filter((i: string) => !!i)
|
|
41
|
+
.map((i: string) => new RegExp(`^${i}$`));
|
|
37
42
|
|
|
38
43
|
// alias
|
|
39
44
|
const replacement = (name: string) => path.resolve(cwd, `./packages/${name}`);
|
|
40
45
|
const { name } = createRequire(cwd)(path.resolve(cwd, workspace ? `${workspace}/index` : '', 'package.json'));
|
|
41
46
|
|
|
42
|
-
const alias = workspace &&
|
|
47
|
+
const alias = workspace && usedForBrowser
|
|
43
48
|
? [
|
|
44
49
|
{
|
|
45
50
|
find: new RegExp(`^${name}$`),
|
|
@@ -53,10 +58,16 @@ const alias = workspace && !(/(cjs|es)/.test(format))
|
|
|
53
58
|
]
|
|
54
59
|
: [];
|
|
55
60
|
|
|
61
|
+
const getGlobalName = (name$: string) => name$.replace(/(_|-|^|.*\/)([^-_\/@])/g, (_match: any, _$1: any, $2: string) => $2.toUpperCase());
|
|
56
62
|
|
|
57
63
|
export default defineConfig({
|
|
58
|
-
|
|
64
|
+
define: usedForBrowser
|
|
65
|
+
? {
|
|
66
|
+
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
|
|
67
|
+
}
|
|
68
|
+
: {},
|
|
59
69
|
logLevel: 'silent',
|
|
70
|
+
plugins: [],
|
|
60
71
|
css: {
|
|
61
72
|
postcss: {
|
|
62
73
|
plugins: [
|
|
@@ -75,8 +86,24 @@ export default defineConfig({
|
|
|
75
86
|
lib: {
|
|
76
87
|
entry: files.map((file: string) => path.resolve(packageSourceDir, file)),
|
|
77
88
|
formats: [format],
|
|
78
|
-
name: packageName
|
|
89
|
+
name: getGlobalName(packageName)
|
|
79
90
|
},
|
|
80
|
-
rollupOptions: {
|
|
91
|
+
rollupOptions: {
|
|
92
|
+
external: external$,
|
|
93
|
+
output: {
|
|
94
|
+
globals: usedForBrowser
|
|
95
|
+
? (globals || external).split(',')
|
|
96
|
+
.filter((i: string) => !!i)
|
|
97
|
+
.reduce((pre: any, cur: string) => {
|
|
98
|
+
const [key, value] = cur.split(':');
|
|
99
|
+
if (key) {
|
|
100
|
+
pre[key] = value || getGlobalName(key);
|
|
101
|
+
}
|
|
102
|
+
return pre;
|
|
103
|
+
}, {})
|
|
104
|
+
: {}
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
}
|
|
81
108
|
}
|
|
82
109
|
}) as UserConfig;
|