@deot/dev-builder 2.7.0 → 2.8.0
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 +46 -30
- package/dist/index.js +46 -30
- package/package.json +7 -7
- package/shared.config.ts +44 -44
package/dist/index.cjs
CHANGED
|
@@ -61,7 +61,7 @@ const run$3 = async (options) => {
|
|
|
61
61
|
} = options || {};
|
|
62
62
|
const { scriptFormats, external, globals } = commandOptions;
|
|
63
63
|
const stats = [];
|
|
64
|
-
|
|
64
|
+
const files = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
|
|
65
65
|
if (!files.length)
|
|
66
66
|
return stats;
|
|
67
67
|
const build = async (format, filepath) => {
|
|
@@ -97,11 +97,11 @@ const run$3 = async (options) => {
|
|
|
97
97
|
options$ = isVuePackage ? vite.mergeConfig(sharedVueConfig, options$) : isReactPackage ? vite.mergeConfig(sharedReactConfig, options$) : options$;
|
|
98
98
|
}
|
|
99
99
|
process.env.BUILD_OPTIONS = encodeURIComponent(JSON.stringify(buildOptions));
|
|
100
|
-
|
|
100
|
+
const outputs2 = await vite.build(options$);
|
|
101
101
|
outputs2.forEach((i) => {
|
|
102
102
|
i.output.forEach((j) => {
|
|
103
103
|
if (j.type === "asset") {
|
|
104
|
-
|
|
104
|
+
const fileName = filepath.replace(/^(.*)((\..*\.js)|\.cjs|\.ts)/, `$1.${j.fileName}`);
|
|
105
105
|
fs.outputFileSync(`${outDir}/${fileName}`, j.source);
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
@@ -123,9 +123,9 @@ const run$3 = async (options) => {
|
|
|
123
123
|
});
|
|
124
124
|
});
|
|
125
125
|
await serial;
|
|
126
|
-
|
|
126
|
+
const outputs = fs.readdirSync(outDir).filter((i) => /^index(.*)(?!=(\.d))\.(cjs|js|style\.css)$/.test(i));
|
|
127
127
|
outputs.forEach((file) => {
|
|
128
|
-
|
|
128
|
+
const stat = fs.statSync(path__namespace.resolve(outDir, file));
|
|
129
129
|
stats.push({
|
|
130
130
|
file: file.replace(/^(.*)(\.umd\.cjs|\.iife\.js)/, "$1.ts").replace(/^(.*)(\.js|\.cjs)/, "$1.ts"),
|
|
131
131
|
format: /\.style\.css$/.test(file) ? "css" : /\.umd\.cjs$/.test(file) ? "umd" : /\.cjs$/.test(file) ? "cjs" : /\.iife\.js$/.test(file) ? "iife" : "es",
|
|
@@ -142,11 +142,11 @@ const run$2 = async (options) => {
|
|
|
142
142
|
await styles.reduce(
|
|
143
143
|
(preProcess, file) => {
|
|
144
144
|
preProcess = preProcess.then(() => {
|
|
145
|
-
|
|
145
|
+
const filepath = path__namespace.resolve(srcDir, file);
|
|
146
146
|
const data = sass__namespace.compile(filepath, { style: "compressed" });
|
|
147
147
|
return postcss().use(atImport()).use(atUrl()).use(flexBugs()).use(cssnano()).use(autoprefixer({ remove: false })).process(data.css, { from: filepath });
|
|
148
148
|
}).then((source) => {
|
|
149
|
-
|
|
149
|
+
const output = path__namespace.resolve(outDir, `${file.replace(/\.scss$/g, ".css")}`);
|
|
150
150
|
fs.outputFileSync(output, source.css);
|
|
151
151
|
return fs.stat(output);
|
|
152
152
|
}).then((stat) => {
|
|
@@ -168,9 +168,9 @@ const run$1 = async (options) => {
|
|
|
168
168
|
const { isVuePackage, packageDir, packageOutDir, packageSourceDir, packageOptions, commandOptions } = options;
|
|
169
169
|
const done = () => {
|
|
170
170
|
const stats = [];
|
|
171
|
-
|
|
171
|
+
const fullpath = `${packageOutDir}/index.d.ts`;
|
|
172
172
|
if (fs.existsSync(fullpath)) {
|
|
173
|
-
|
|
173
|
+
const stat = fs.statSync(fullpath);
|
|
174
174
|
stats.push({
|
|
175
175
|
file: "index.d.ts",
|
|
176
176
|
size: stat.size
|
|
@@ -187,22 +187,30 @@ const run$1 = async (options) => {
|
|
|
187
187
|
});
|
|
188
188
|
return done();
|
|
189
189
|
}
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
190
|
+
const tempDir = `${packageOutDir}/temp`;
|
|
191
|
+
const rootDir = path__namespace.relative(tempDir, process.cwd());
|
|
192
|
+
const tsc = async (skipLibCheck) => {
|
|
193
|
+
fs.outputFileSync(`${tempDir}/tsconfig.json`, JSON.stringify({
|
|
194
|
+
extends: `${rootDir}/tsconfig.json`,
|
|
195
|
+
compilerOptions: {
|
|
196
|
+
declaration: true,
|
|
197
|
+
emitDeclarationOnly: true,
|
|
198
|
+
allowJs: true,
|
|
199
|
+
outDir: ".",
|
|
200
|
+
skipLibCheck,
|
|
201
|
+
rootDir
|
|
202
|
+
},
|
|
203
|
+
include: [
|
|
204
|
+
path__namespace.relative(tempDir, path__namespace.resolve(packageSourceDir, `*`))
|
|
205
|
+
]
|
|
206
|
+
}, null, " "));
|
|
207
|
+
await devShared.Shell.spawn(isVuePackage ? "vue-tsc" : "tsc", ["-p", `${tempDir}/tsconfig.json`]);
|
|
208
|
+
};
|
|
209
|
+
try {
|
|
210
|
+
await tsc(false);
|
|
211
|
+
} catch (e) {
|
|
212
|
+
await tsc(true);
|
|
213
|
+
}
|
|
206
214
|
const configPath = `${tempDir}/api-extractor.json`;
|
|
207
215
|
fs.outputFileSync(configPath, JSON.stringify({
|
|
208
216
|
extends: path__namespace.relative(tempDir, path__namespace.resolve(dirname, "../api-extractor.shared.json")),
|
|
@@ -224,13 +232,21 @@ const run$1 = async (options) => {
|
|
|
224
232
|
*
|
|
225
233
|
* 版本提示:
|
|
226
234
|
* 2. console-compiler-version-notice
|
|
227
|
-
* *** The target project appears to use TypeScript 5.1.6 which is newer
|
|
235
|
+
* *** The target project appears to use TypeScript 5.1.6 which is newer
|
|
228
236
|
* than the bundled compiler engine; consider upgrading API Extractor.
|
|
229
237
|
* 3. console-preamble
|
|
230
238
|
* Analysis will use the bundled TypeScript version 5.0.4
|
|
239
|
+
*
|
|
240
|
+
*
|
|
241
|
+
* 4. TS2590, TS2320, TS2344, TS2430
|
|
242
|
+
* 打包vue项目时,出现的warning
|
|
243
|
+
* (TS2344) Type 'C' does not satisfy the constraint 'ElementType<any>'.
|
|
244
|
+
* (TS2320) Interface 'Element' cannot simultaneously extend types 'VNode<RendererNode,
|
|
245
|
+
* (TS2430) Interface 'IntrinsicElements' incorrectly extends interface 'NativeElements'
|
|
246
|
+
* (TS2590) Expression produces a union type that is too complex to represent
|
|
231
247
|
*/
|
|
232
248
|
messageCallback: (message) => {
|
|
233
|
-
if (message.messageId === "console-compiler-version-notice" || message.messageId === "console-preamble" ||
|
|
249
|
+
if (message.messageId === "console-compiler-version-notice" || message.messageId === "console-preamble" || ["TS18028", "TS2590", "TS2320", "TS2344", "TS2430"].includes(message.messageId)) {
|
|
234
250
|
message.handled = true;
|
|
235
251
|
}
|
|
236
252
|
}
|
|
@@ -274,7 +290,7 @@ class Build {
|
|
|
274
290
|
this.isNodePackage = typeof nodePackage === "string" && (nodePackage === "*" || nodePackage.split(",").includes(this.packageName));
|
|
275
291
|
}
|
|
276
292
|
async process() {
|
|
277
|
-
|
|
293
|
+
const start = Date.now();
|
|
278
294
|
const { cwd, workspace } = devShared.Locals.impl();
|
|
279
295
|
const { packageSourceDir: srcDir, packageOptions, packageName, packageDir } = this;
|
|
280
296
|
if (workspace && packageOptions?.scripts?.build && packageDir !== cwd) {
|
|
@@ -283,7 +299,7 @@ class Build {
|
|
|
283
299
|
});
|
|
284
300
|
return;
|
|
285
301
|
}
|
|
286
|
-
|
|
302
|
+
const files = fs.existsSync(srcDir) ? fs.readdirSync(srcDir).filter((i) => /^index(.*)\.(ts|js|s?css)$/.test(i)) : [];
|
|
287
303
|
if (!files.length)
|
|
288
304
|
return;
|
|
289
305
|
const spinner = ora(`${packageName} Build ...`);
|
|
@@ -331,7 +347,7 @@ const run = (options) => devShared.Utils.autoCatch(async () => {
|
|
|
331
347
|
options.vuePackage = devShared.Locals.getRealPackageName(options.vuePackage);
|
|
332
348
|
options.reactPackage = devShared.Locals.getRealPackageName(options.reactPackage);
|
|
333
349
|
options.nodePackage = devShared.Locals.getRealPackageName(options.nodePackage);
|
|
334
|
-
|
|
350
|
+
const packageFolderName = devShared.Locals.getPackageFolderName(options.packageName || "*");
|
|
335
351
|
let inputs = [];
|
|
336
352
|
if (locals.workspace && packageFolderName === "*") {
|
|
337
353
|
inputs = locals.normalizePackageFolderNames;
|
package/dist/index.js
CHANGED
|
@@ -35,7 +35,7 @@ const run$3 = async (options) => {
|
|
|
35
35
|
} = options || {};
|
|
36
36
|
const { scriptFormats, external, globals } = commandOptions;
|
|
37
37
|
const stats = [];
|
|
38
|
-
|
|
38
|
+
const files = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index\.(.*)\.?(t|j)s$/.test(i)) : [];
|
|
39
39
|
if (!files.length)
|
|
40
40
|
return stats;
|
|
41
41
|
const build = async (format, filepath) => {
|
|
@@ -71,11 +71,11 @@ const run$3 = async (options) => {
|
|
|
71
71
|
options$ = isVuePackage ? mergeConfig(sharedVueConfig, options$) : isReactPackage ? mergeConfig(sharedReactConfig, options$) : options$;
|
|
72
72
|
}
|
|
73
73
|
process.env.BUILD_OPTIONS = encodeURIComponent(JSON.stringify(buildOptions));
|
|
74
|
-
|
|
74
|
+
const outputs2 = await build$1(options$);
|
|
75
75
|
outputs2.forEach((i) => {
|
|
76
76
|
i.output.forEach((j) => {
|
|
77
77
|
if (j.type === "asset") {
|
|
78
|
-
|
|
78
|
+
const fileName = filepath.replace(/^(.*)((\..*\.js)|\.cjs|\.ts)/, `$1.${j.fileName}`);
|
|
79
79
|
fs$1.outputFileSync(`${outDir}/${fileName}`, j.source);
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
@@ -97,9 +97,9 @@ const run$3 = async (options) => {
|
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
await serial;
|
|
100
|
-
|
|
100
|
+
const outputs = fs$1.readdirSync(outDir).filter((i) => /^index(.*)(?!=(\.d))\.(cjs|js|style\.css)$/.test(i));
|
|
101
101
|
outputs.forEach((file) => {
|
|
102
|
-
|
|
102
|
+
const stat = fs$1.statSync(path.resolve(outDir, file));
|
|
103
103
|
stats.push({
|
|
104
104
|
file: file.replace(/^(.*)(\.umd\.cjs|\.iife\.js)/, "$1.ts").replace(/^(.*)(\.js|\.cjs)/, "$1.ts"),
|
|
105
105
|
format: /\.style\.css$/.test(file) ? "css" : /\.umd\.cjs$/.test(file) ? "umd" : /\.cjs$/.test(file) ? "cjs" : /\.iife\.js$/.test(file) ? "iife" : "es",
|
|
@@ -116,11 +116,11 @@ const run$2 = async (options) => {
|
|
|
116
116
|
await styles.reduce(
|
|
117
117
|
(preProcess, file) => {
|
|
118
118
|
preProcess = preProcess.then(() => {
|
|
119
|
-
|
|
119
|
+
const filepath = path.resolve(srcDir, file);
|
|
120
120
|
const data = sass.compile(filepath, { style: "compressed" });
|
|
121
121
|
return postcss().use(atImport()).use(atUrl()).use(flexBugs()).use(cssnano()).use(autoprefixer({ remove: false })).process(data.css, { from: filepath });
|
|
122
122
|
}).then((source) => {
|
|
123
|
-
|
|
123
|
+
const output = path.resolve(outDir, `${file.replace(/\.scss$/g, ".css")}`);
|
|
124
124
|
fs$1.outputFileSync(output, source.css);
|
|
125
125
|
return fs$1.stat(output);
|
|
126
126
|
}).then((stat) => {
|
|
@@ -142,9 +142,9 @@ const run$1 = async (options) => {
|
|
|
142
142
|
const { isVuePackage, packageDir, packageOutDir, packageSourceDir, packageOptions, commandOptions } = options;
|
|
143
143
|
const done = () => {
|
|
144
144
|
const stats = [];
|
|
145
|
-
|
|
145
|
+
const fullpath = `${packageOutDir}/index.d.ts`;
|
|
146
146
|
if (fs$1.existsSync(fullpath)) {
|
|
147
|
-
|
|
147
|
+
const stat = fs$1.statSync(fullpath);
|
|
148
148
|
stats.push({
|
|
149
149
|
file: "index.d.ts",
|
|
150
150
|
size: stat.size
|
|
@@ -161,22 +161,30 @@ const run$1 = async (options) => {
|
|
|
161
161
|
});
|
|
162
162
|
return done();
|
|
163
163
|
}
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
164
|
+
const tempDir = `${packageOutDir}/temp`;
|
|
165
|
+
const rootDir = path.relative(tempDir, process.cwd());
|
|
166
|
+
const tsc = async (skipLibCheck) => {
|
|
167
|
+
fs$1.outputFileSync(`${tempDir}/tsconfig.json`, JSON.stringify({
|
|
168
|
+
extends: `${rootDir}/tsconfig.json`,
|
|
169
|
+
compilerOptions: {
|
|
170
|
+
declaration: true,
|
|
171
|
+
emitDeclarationOnly: true,
|
|
172
|
+
allowJs: true,
|
|
173
|
+
outDir: ".",
|
|
174
|
+
skipLibCheck,
|
|
175
|
+
rootDir
|
|
176
|
+
},
|
|
177
|
+
include: [
|
|
178
|
+
path.relative(tempDir, path.resolve(packageSourceDir, `*`))
|
|
179
|
+
]
|
|
180
|
+
}, null, " "));
|
|
181
|
+
await Shell.spawn(isVuePackage ? "vue-tsc" : "tsc", ["-p", `${tempDir}/tsconfig.json`]);
|
|
182
|
+
};
|
|
183
|
+
try {
|
|
184
|
+
await tsc(false);
|
|
185
|
+
} catch (e) {
|
|
186
|
+
await tsc(true);
|
|
187
|
+
}
|
|
180
188
|
const configPath = `${tempDir}/api-extractor.json`;
|
|
181
189
|
fs$1.outputFileSync(configPath, JSON.stringify({
|
|
182
190
|
extends: path.relative(tempDir, path.resolve(dirname, "../api-extractor.shared.json")),
|
|
@@ -198,13 +206,21 @@ const run$1 = async (options) => {
|
|
|
198
206
|
*
|
|
199
207
|
* 版本提示:
|
|
200
208
|
* 2. console-compiler-version-notice
|
|
201
|
-
* *** The target project appears to use TypeScript 5.1.6 which is newer
|
|
209
|
+
* *** The target project appears to use TypeScript 5.1.6 which is newer
|
|
202
210
|
* than the bundled compiler engine; consider upgrading API Extractor.
|
|
203
211
|
* 3. console-preamble
|
|
204
212
|
* Analysis will use the bundled TypeScript version 5.0.4
|
|
213
|
+
*
|
|
214
|
+
*
|
|
215
|
+
* 4. TS2590, TS2320, TS2344, TS2430
|
|
216
|
+
* 打包vue项目时,出现的warning
|
|
217
|
+
* (TS2344) Type 'C' does not satisfy the constraint 'ElementType<any>'.
|
|
218
|
+
* (TS2320) Interface 'Element' cannot simultaneously extend types 'VNode<RendererNode,
|
|
219
|
+
* (TS2430) Interface 'IntrinsicElements' incorrectly extends interface 'NativeElements'
|
|
220
|
+
* (TS2590) Expression produces a union type that is too complex to represent
|
|
205
221
|
*/
|
|
206
222
|
messageCallback: (message) => {
|
|
207
|
-
if (message.messageId === "console-compiler-version-notice" || message.messageId === "console-preamble" ||
|
|
223
|
+
if (message.messageId === "console-compiler-version-notice" || message.messageId === "console-preamble" || ["TS18028", "TS2590", "TS2320", "TS2344", "TS2430"].includes(message.messageId)) {
|
|
208
224
|
message.handled = true;
|
|
209
225
|
}
|
|
210
226
|
}
|
|
@@ -248,7 +264,7 @@ class Build {
|
|
|
248
264
|
this.isNodePackage = typeof nodePackage === "string" && (nodePackage === "*" || nodePackage.split(",").includes(this.packageName));
|
|
249
265
|
}
|
|
250
266
|
async process() {
|
|
251
|
-
|
|
267
|
+
const start = Date.now();
|
|
252
268
|
const { cwd, workspace } = Locals.impl();
|
|
253
269
|
const { packageSourceDir: srcDir, packageOptions, packageName, packageDir } = this;
|
|
254
270
|
if (workspace && packageOptions?.scripts?.build && packageDir !== cwd) {
|
|
@@ -257,7 +273,7 @@ class Build {
|
|
|
257
273
|
});
|
|
258
274
|
return;
|
|
259
275
|
}
|
|
260
|
-
|
|
276
|
+
const files = fs$1.existsSync(srcDir) ? fs$1.readdirSync(srcDir).filter((i) => /^index(.*)\.(ts|js|s?css)$/.test(i)) : [];
|
|
261
277
|
if (!files.length)
|
|
262
278
|
return;
|
|
263
279
|
const spinner = ora(`${packageName} Build ...`);
|
|
@@ -305,7 +321,7 @@ const run = (options) => Utils.autoCatch(async () => {
|
|
|
305
321
|
options.vuePackage = Locals.getRealPackageName(options.vuePackage);
|
|
306
322
|
options.reactPackage = Locals.getRealPackageName(options.reactPackage);
|
|
307
323
|
options.nodePackage = Locals.getRealPackageName(options.nodePackage);
|
|
308
|
-
|
|
324
|
+
const packageFolderName = Locals.getPackageFolderName(options.packageName || "*");
|
|
309
325
|
let inputs = [];
|
|
310
326
|
if (locals.workspace && packageFolderName === "*") {
|
|
311
327
|
inputs = locals.normalizePackageFolderNames;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deot/dev-builder",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@deot/dev-react": "^2.
|
|
33
|
-
"@deot/dev-shared": "^2.
|
|
34
|
-
"@deot/dev-vue": "^2.
|
|
35
|
-
"@microsoft/api-extractor": "^7.38.
|
|
32
|
+
"@deot/dev-react": "^2.8.0",
|
|
33
|
+
"@deot/dev-shared": "^2.8.0",
|
|
34
|
+
"@deot/dev-vue": "^2.8.0",
|
|
35
|
+
"@microsoft/api-extractor": "^7.38.5",
|
|
36
36
|
"autoprefixer": "^10.4.16",
|
|
37
37
|
"chalk": "^5.3.0",
|
|
38
38
|
"cssnano": "^6.0.1",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"postcss-import": "^15.1.0",
|
|
44
44
|
"postcss-url": "^10.1.3",
|
|
45
45
|
"sass": "^1.69.5",
|
|
46
|
-
"vite": "^5.0.
|
|
46
|
+
"vite": "^5.0.8"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"typescript": "^5.3.
|
|
49
|
+
"typescript": "^5.3.3"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/shared.config.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import { createRequire } from
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
2
|
import * as path from 'node:path';
|
|
3
3
|
import { defineConfig } from 'vite';
|
|
4
|
-
import atImport from
|
|
5
|
-
import atUrl from
|
|
6
|
-
import flexBugs from
|
|
7
|
-
import cssnano from
|
|
8
|
-
import autoprefixer from
|
|
9
|
-
import type { UserConfig } from
|
|
4
|
+
import atImport from 'postcss-import';
|
|
5
|
+
import atUrl from 'postcss-url';
|
|
6
|
+
import flexBugs from 'postcss-flexbugs-fixes';
|
|
7
|
+
import cssnano from 'cssnano';
|
|
8
|
+
import autoprefixer from 'autoprefixer';
|
|
9
|
+
import type { UserConfig } from 'vite';
|
|
10
10
|
|
|
11
11
|
const cwd = process.cwd();
|
|
12
12
|
|
|
13
13
|
// options
|
|
14
14
|
const buildOptions = JSON.parse(decodeURIComponent(process.env.BUILD_OPTIONS || '{}'));
|
|
15
15
|
|
|
16
|
-
const {
|
|
17
|
-
format,
|
|
16
|
+
const {
|
|
17
|
+
format,
|
|
18
18
|
external = '',
|
|
19
19
|
globals = '',
|
|
20
20
|
workspace,
|
|
21
|
-
files = [],
|
|
22
|
-
packageName,
|
|
23
|
-
packageSourceDir,
|
|
24
|
-
packageOptions = {}
|
|
21
|
+
files = [],
|
|
22
|
+
packageName,
|
|
23
|
+
packageSourceDir,
|
|
24
|
+
packageOptions = {}
|
|
25
25
|
} = buildOptions;
|
|
26
26
|
|
|
27
27
|
const usedForBrowser = /(iife|umd)/.test(format);
|
|
28
28
|
const external$ = !usedForBrowser
|
|
29
29
|
? [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
/^node:/,
|
|
31
|
+
/^[a-zA-Z@]/,
|
|
32
|
+
...Object
|
|
33
|
+
.keys({
|
|
34
|
+
...packageOptions.dependencies,
|
|
35
|
+
...packageOptions.peerDependencies
|
|
36
|
+
})
|
|
37
|
+
.map(i => new RegExp(`^${i}$`))
|
|
38
|
+
]
|
|
39
39
|
: external.split(',')
|
|
40
40
|
.filter((i: string) => !!i)
|
|
41
41
|
.map((i: string) => new RegExp(`^${i}$`));
|
|
@@ -46,25 +46,25 @@ const { name } = createRequire(cwd)(path.resolve(cwd, workspace ? `${workspace}/
|
|
|
46
46
|
|
|
47
47
|
const alias = workspace && usedForBrowser
|
|
48
48
|
? [
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
49
|
+
{
|
|
50
|
+
find: new RegExp(`^${name}$`),
|
|
51
|
+
replacement: replacement('index')
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
find: new RegExp(`^${name}-(.*?)$`),
|
|
56
|
+
replacement: replacement('$1')
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
59
|
: [];
|
|
60
60
|
|
|
61
61
|
const getGlobalName = (name$: string) => name$.replace(/(_|-|^|.*\/)([^-_\/@])/g, (_match: any, _$1: any, $2: string) => $2.toUpperCase());
|
|
62
62
|
|
|
63
63
|
export default defineConfig({
|
|
64
|
-
define: usedForBrowser
|
|
64
|
+
define: usedForBrowser
|
|
65
65
|
? {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
|
|
67
|
+
}
|
|
68
68
|
: {},
|
|
69
69
|
logLevel: 'silent',
|
|
70
70
|
plugins: [],
|
|
@@ -88,19 +88,19 @@ export default defineConfig({
|
|
|
88
88
|
formats: [format],
|
|
89
89
|
name: getGlobalName(packageName)
|
|
90
90
|
},
|
|
91
|
-
rollupOptions: {
|
|
91
|
+
rollupOptions: {
|
|
92
92
|
external: external$,
|
|
93
93
|
output: {
|
|
94
|
-
globals: usedForBrowser
|
|
94
|
+
globals: usedForBrowser
|
|
95
95
|
? (globals || external).split(',')
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
104
|
: {}
|
|
105
105
|
|
|
106
106
|
}
|