@modern-js/module-tools 1.6.0-alpha.0 → 1.6.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/CHANGELOG.md +41 -27
- package/dist/js/modern/commands/build.js +19 -5
- package/dist/js/modern/features/build/bundle/index.js +5 -2
- package/dist/js/modern/features/build/bundle/runSpeedy.js +3 -3
- package/dist/js/modern/features/build/bundleless/generator-dts/utils.js +5 -5
- package/dist/js/modern/features/build/bundleless/index.js +12 -2
- package/dist/js/modern/features/build/bundleless/runBabel.js +2 -2
- package/dist/js/modern/features/build/bundleless/style.js +2 -2
- package/dist/js/modern/features/build/index.js +20 -16
- package/dist/js/modern/features/build/normalize.js +21 -13
- package/dist/js/modern/features/build/utils.js +12 -1
- package/dist/js/modern/index.js +1 -0
- package/dist/js/modern/schema/build-config.js +10 -3
- package/dist/js/modern/utils/copy.js +2 -2
- package/dist/js/node/commands/build.js +18 -6
- package/dist/js/node/features/build/bundle/index.js +8 -2
- package/dist/js/node/features/build/bundle/runSpeedy.js +3 -3
- package/dist/js/node/features/build/bundleless/generator-dts/utils.js +4 -5
- package/dist/js/node/features/build/bundleless/index.js +16 -2
- package/dist/js/node/features/build/bundleless/runBabel.js +1 -1
- package/dist/js/node/features/build/bundleless/style.js +1 -1
- package/dist/js/node/features/build/index.js +27 -14
- package/dist/js/node/features/build/normalize.js +20 -12
- package/dist/js/node/features/build/utils.js +19 -2
- package/dist/js/node/index.js +17 -0
- package/dist/js/node/schema/build-config.js +10 -3
- package/dist/js/node/utils/copy.js +1 -1
- package/dist/types/features/build/bundle/runSpeedy.d.ts +1 -1
- package/dist/types/features/build/index.d.ts +9 -1
- package/dist/types/features/build/normalize.d.ts +2 -1
- package/dist/types/features/build/utils.d.ts +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/schema/build-config.d.ts +22 -4
- package/dist/types/schema/index.d.ts +22 -4
- package/dist/types/schema/output.d.ts +22 -4
- package/dist/types/schema/types.d.ts +1 -0
- package/package.json +19 -17
|
@@ -5,6 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.build = void 0;
|
|
7
7
|
|
|
8
|
+
var _utils = require("@modern-js/utils");
|
|
9
|
+
|
|
10
|
+
var _pMap = _interopRequireDefault(require("p-map"));
|
|
11
|
+
|
|
8
12
|
var _runBabel = require("./runBabel");
|
|
9
13
|
|
|
10
14
|
var _style = require("./style");
|
|
@@ -13,14 +17,24 @@ var _generatorDts = require("./generator-dts");
|
|
|
13
17
|
|
|
14
18
|
var _copyAssets = require("./copy-assets");
|
|
15
19
|
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
+
|
|
16
22
|
const build = async (api, config, legacyOptions) => {
|
|
23
|
+
// valid format is umd
|
|
24
|
+
if (config.format === 'umd') {
|
|
25
|
+
console.info(_utils.chalk.yellowBright('bundleless 构建暂时不支持 umd 格式'));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
|
|
17
29
|
if (legacyOptions !== null && legacyOptions !== void 0 && legacyOptions.styleOnly) {
|
|
18
30
|
await (0, _style.buildStyle)(api, config);
|
|
19
31
|
return;
|
|
20
32
|
}
|
|
21
33
|
|
|
22
|
-
const tasks = config.dtsOnly ? [
|
|
23
|
-
await
|
|
34
|
+
const tasks = config.dtsOnly ? [_generatorDts.genDts] : [_runBabel.runBabelBuild, _generatorDts.genDts, _style.buildStyle, _copyAssets.copyStaticAssets];
|
|
35
|
+
await (0, _pMap.default)(tasks, async task => {
|
|
36
|
+
await task(api, config);
|
|
37
|
+
});
|
|
24
38
|
};
|
|
25
39
|
|
|
26
40
|
exports.build = build;
|
|
@@ -198,7 +198,7 @@ const jsFileSuffix = ['js', 'jsx', 'ts', 'tsx'];
|
|
|
198
198
|
exports.jsFileSuffix = jsFileSuffix;
|
|
199
199
|
|
|
200
200
|
const haveNotAnyJsFile = async sourceDir => {
|
|
201
|
-
const files = await (0, _utils.globby)(`${sourceDir}/**/*.{${jsFileSuffix.join(',')}}`);
|
|
201
|
+
const files = await (0, _utils.globby)((0, _utils.slash)(`${sourceDir}/**/*.{${jsFileSuffix.join(',')}}`));
|
|
202
202
|
return files.length === 0;
|
|
203
203
|
};
|
|
204
204
|
|
|
@@ -174,7 +174,7 @@ const styleFileSuffix = ['css', 'less', 'sass', 'scss'];
|
|
|
174
174
|
exports.styleFileSuffix = styleFileSuffix;
|
|
175
175
|
|
|
176
176
|
const haveNotAnyStyles = async sourceDir => {
|
|
177
|
-
const files = await (0, _utils.globby)(`${sourceDir}/**/*.{${styleFileSuffix.join(',')}}`);
|
|
177
|
+
const files = await (0, _utils.globby)((0, _utils.slash)(`${sourceDir}/**/*.{${styleFileSuffix.join(',')}}`));
|
|
178
178
|
return files.length === 0;
|
|
179
179
|
};
|
|
180
180
|
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.buildInNormalMode = exports.build = void 0;
|
|
6
|
+
exports.runBuild = exports.checkPlatformAndRunBuild = exports.buildInNormalMode = exports.build = void 0;
|
|
7
7
|
|
|
8
8
|
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
10
10
|
var _utils = require("@modern-js/utils");
|
|
11
11
|
|
|
12
|
+
var _pMap = _interopRequireDefault(require("p-map"));
|
|
13
|
+
|
|
12
14
|
var _readline = require("../../utils/readline");
|
|
13
15
|
|
|
14
16
|
var _normalize = require("./normalize");
|
|
@@ -17,6 +19,8 @@ var _constants = require("./constants");
|
|
|
17
19
|
|
|
18
20
|
var _error = require("./error");
|
|
19
21
|
|
|
22
|
+
var _utils2 = require("./utils");
|
|
23
|
+
|
|
20
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
25
|
|
|
22
26
|
const bundle = _utils.Import.lazy('./bundle', require);
|
|
@@ -62,13 +66,27 @@ const checkPlatformAndRunBuild = async (platform, options) => {
|
|
|
62
66
|
};
|
|
63
67
|
};
|
|
64
68
|
|
|
65
|
-
|
|
69
|
+
exports.checkPlatformAndRunBuild = checkPlatformAndRunBuild;
|
|
70
|
+
|
|
71
|
+
const runBuild = async (api, normalizedModuleConfig, config) => {
|
|
72
|
+
await (0, _pMap.default)(normalizedModuleConfig, async moduleConfig => {
|
|
73
|
+
if (moduleConfig.buildType === 'bundle') {
|
|
74
|
+
await bundle.build(api, moduleConfig);
|
|
75
|
+
} else {
|
|
76
|
+
await bundleless.build(api, moduleConfig, config);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
exports.runBuild = runBuild;
|
|
82
|
+
|
|
83
|
+
const buildInNormalMode = async (api, normalizedModuleConfig, config) => {
|
|
66
84
|
console.info(_utils.chalk.blue.bold(_constants.buildingText));
|
|
67
85
|
|
|
68
86
|
try {
|
|
69
87
|
// eslint-disable-next-line no-console
|
|
70
88
|
console.time(_constants.buildSuccessText);
|
|
71
|
-
await
|
|
89
|
+
await runBuild(api, normalizedModuleConfig, config);
|
|
72
90
|
|
|
73
91
|
_readline.ReadlineUtils.clearPrevLine(process.stdout); // eslint-disable-next-line no-console
|
|
74
92
|
|
|
@@ -114,26 +132,21 @@ const build = async (api, config) => {
|
|
|
114
132
|
|
|
115
133
|
if (clear) {
|
|
116
134
|
_utils.fs.removeSync(_path.default.join(appDirectory, outputPath));
|
|
117
|
-
}
|
|
135
|
+
}
|
|
118
136
|
|
|
137
|
+
const deps = (0, _utils2.getAllDeps)(appDirectory); // should normalize module tool config here, ensure the same config for build
|
|
119
138
|
|
|
120
139
|
const normalizedModuleConfig = (0, _normalize.normalizeModuleConfig)({
|
|
121
140
|
buildFeatOption: config,
|
|
122
|
-
api
|
|
123
|
-
|
|
124
|
-
const buildTasks = normalizedModuleConfig.map(moduleConfig => {
|
|
125
|
-
if (moduleConfig.buildType === 'bundle') {
|
|
126
|
-
return bundle.build(api, moduleConfig);
|
|
127
|
-
} else {
|
|
128
|
-
return bundleless.build(api, moduleConfig, config);
|
|
129
|
-
}
|
|
141
|
+
api,
|
|
142
|
+
deps
|
|
130
143
|
});
|
|
131
144
|
|
|
132
145
|
if (config.enableWatchMode) {
|
|
133
146
|
console.info(_utils.chalk.blue.underline('start build in watch mode...\n'));
|
|
134
|
-
await
|
|
147
|
+
await runBuild(api, normalizedModuleConfig, config);
|
|
135
148
|
} else {
|
|
136
|
-
await buildInNormalMode(
|
|
149
|
+
await buildInNormalMode(api, normalizedModuleConfig, config);
|
|
137
150
|
}
|
|
138
151
|
};
|
|
139
152
|
|
|
@@ -105,15 +105,15 @@ const getNormalizeModuleConfigByPackageModeAndFileds = (api, buildFeatOption) =>
|
|
|
105
105
|
|
|
106
106
|
|
|
107
107
|
if (packageFields['jsnext:modern']) {
|
|
108
|
-
configs.push(getConfigsByJsSyntaxType(packageFields['jsnext:modern'], 'modern'));
|
|
108
|
+
configs.push(getConfigsByJsSyntaxType(packageFields['jsnext:modern'], 'js/modern'));
|
|
109
109
|
}
|
|
110
110
|
|
|
111
111
|
if (packageFields.main) {
|
|
112
|
-
configs.push(getConfigsByJsSyntaxType(packageFields.main, 'node'));
|
|
112
|
+
configs.push(getConfigsByJsSyntaxType(packageFields.main, 'js/node'));
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
if (packageFields.module) {
|
|
116
|
-
configs.push(getConfigsByJsSyntaxType(packageFields.module, 'treeshaking'));
|
|
116
|
+
configs.push(getConfigsByJsSyntaxType(packageFields.module, 'js/treeshaking'));
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
119
|
|
|
@@ -205,27 +205,32 @@ const getSourceMap = (config, buildType, api) => {
|
|
|
205
205
|
|
|
206
206
|
exports.getSourceMap = getSourceMap;
|
|
207
207
|
|
|
208
|
-
const normalizeBuildConfig = (context, buildConfig) => {
|
|
208
|
+
const normalizeBuildConfig = (context, buildConfig, deps = []) => {
|
|
209
209
|
const {
|
|
210
210
|
buildFeatOption,
|
|
211
211
|
api
|
|
212
212
|
} = context;
|
|
213
213
|
const configArray = Array.isArray(buildConfig) ? buildConfig : [buildConfig];
|
|
214
214
|
const normalizedModule = configArray.map(config => {
|
|
215
|
-
var _config$format, _config$target, _bundleOptions$minify, _config$outputPath, _config$dtsOnly;
|
|
215
|
+
var _config$format, _config$target, _bundleOptions$skipDe, _bundleOptions$minify, _bundleOptions$splitt, _config$outputPath, _config$dtsOnly;
|
|
216
216
|
|
|
217
217
|
const format = (_config$format = config.format) !== null && _config$format !== void 0 ? _config$format : 'cjs';
|
|
218
218
|
const target = (_config$target = config.target) !== null && _config$target !== void 0 ? _config$target : 'esnext';
|
|
219
219
|
const {
|
|
220
220
|
bundleOptions
|
|
221
221
|
} = config;
|
|
222
|
+
const skipDeps = (_bundleOptions$skipDe = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.skipDeps) !== null && _bundleOptions$skipDe !== void 0 ? _bundleOptions$skipDe : true;
|
|
223
|
+
const externals = skipDeps === false ? (bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.externals) || [] : [...deps.map(dep => new RegExp(`^${dep}($|\\/|\\\\)`)), ...((bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.externals) || [])];
|
|
222
224
|
|
|
223
225
|
const normalizedBundleOption = _objectSpread(_objectSpread({}, bundleOptions), {}, {
|
|
224
226
|
entry: (bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.entry) || {
|
|
225
227
|
index: `src/index.${buildFeatOption.isTsProject ? 'ts' : 'js'}`
|
|
226
228
|
},
|
|
227
229
|
platform: (bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.platform) || 'node',
|
|
228
|
-
minify: (_bundleOptions$minify = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.minify) !== null && _bundleOptions$minify !== void 0 ? _bundleOptions$minify : false
|
|
230
|
+
minify: (_bundleOptions$minify = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.minify) !== null && _bundleOptions$minify !== void 0 ? _bundleOptions$minify : false,
|
|
231
|
+
externals,
|
|
232
|
+
splitting: (_bundleOptions$splitt = bundleOptions === null || bundleOptions === void 0 ? void 0 : bundleOptions.splitting) !== null && _bundleOptions$splitt !== void 0 ? _bundleOptions$splitt : false,
|
|
233
|
+
skipDeps
|
|
229
234
|
});
|
|
230
235
|
|
|
231
236
|
const normalizedBundlelessOptions = (0, _lodash.mergeWith)({}, {
|
|
@@ -281,7 +286,8 @@ exports.normalizeBuildConfig = normalizeBuildConfig;
|
|
|
281
286
|
const normalizeModuleConfig = context => {
|
|
282
287
|
const {
|
|
283
288
|
buildFeatOption,
|
|
284
|
-
api
|
|
289
|
+
api,
|
|
290
|
+
deps
|
|
285
291
|
} = context;
|
|
286
292
|
const {
|
|
287
293
|
output: {
|
|
@@ -291,7 +297,7 @@ const normalizeModuleConfig = context => {
|
|
|
291
297
|
} = api.useResolvedConfigContext(); // buildConfig is the most important.
|
|
292
298
|
|
|
293
299
|
if (buildConfig) {
|
|
294
|
-
return normalizeBuildConfig(context, buildConfig);
|
|
300
|
+
return normalizeBuildConfig(context, buildConfig, deps);
|
|
295
301
|
} // buildPreset is the second important. It can be used when buildConfig is not defined.
|
|
296
302
|
// buildPreset -> buildConfig
|
|
297
303
|
|
|
@@ -303,20 +309,22 @@ const normalizeModuleConfig = context => {
|
|
|
303
309
|
} = constants;
|
|
304
310
|
|
|
305
311
|
if (unPresetConfigs[buildPreset]) {
|
|
306
|
-
return normalizeBuildConfig(context, unPresetConfigs[buildPreset]);
|
|
312
|
+
return normalizeBuildConfig(context, unPresetConfigs[buildPreset], deps);
|
|
307
313
|
} else if (unPresetWithTargetConfigs[buildPreset]) {
|
|
308
|
-
return normalizeBuildConfig(context, unPresetWithTargetConfigs[buildPreset]);
|
|
314
|
+
return normalizeBuildConfig(context, unPresetWithTargetConfigs[buildPreset], deps);
|
|
309
315
|
} // If the buildPreset is not found, then it is used 'npm-library'
|
|
310
316
|
// TODO: Warning: The buildPreset 'npm-library' is not supported.
|
|
311
317
|
|
|
312
318
|
|
|
313
|
-
return normalizeBuildConfig(context, unPresetConfigs['npm-library']);
|
|
319
|
+
return normalizeBuildConfig(context, unPresetConfigs['npm-library'], deps);
|
|
314
320
|
} // If the user does not configure buildConfig and buildPreset,
|
|
315
321
|
// the configuration is generated based on packageMode and packageField
|
|
316
322
|
|
|
317
323
|
|
|
318
324
|
const legacyBuildConfig = getNormalizeModuleConfigByPackageModeAndFileds(api, buildFeatOption);
|
|
319
|
-
return normalizeBuildConfig(context, legacyBuildConfig);
|
|
325
|
+
return normalizeBuildConfig(context, legacyBuildConfig, deps);
|
|
320
326
|
};
|
|
327
|
+
/* eslint-enable max-lines */
|
|
328
|
+
|
|
321
329
|
|
|
322
330
|
exports.normalizeModuleConfig = normalizeModuleConfig;
|
|
@@ -3,12 +3,16 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.watchSectionTitle = exports.logTemplate = exports.getPostcssOption = exports.SectionTitleStatus = exports.LogStack = void 0;
|
|
6
|
+
exports.watchSectionTitle = exports.logTemplate = exports.getPostcssOption = exports.getAllDeps = exports.SectionTitleStatus = exports.LogStack = void 0;
|
|
7
7
|
|
|
8
8
|
var os = _interopRequireWildcard(require("os"));
|
|
9
9
|
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
|
|
10
12
|
var _utils = require("@modern-js/utils");
|
|
11
13
|
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
12
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
13
17
|
|
|
14
18
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -109,4 +113,17 @@ const getPostcssOption = (appDirectory, modernConfig) => {
|
|
|
109
113
|
};
|
|
110
114
|
};
|
|
111
115
|
|
|
112
|
-
exports.getPostcssOption = getPostcssOption;
|
|
116
|
+
exports.getPostcssOption = getPostcssOption;
|
|
117
|
+
|
|
118
|
+
const getAllDeps = appDirectory => {
|
|
119
|
+
try {
|
|
120
|
+
const json = JSON.parse(_utils.fs.readFileSync(_path.default.resolve(appDirectory, './package.json'), 'utf8')); // return json[packageJsonConfig ?? PACKAGE_JSON_CONFIG_NAME] as T | undefined;
|
|
121
|
+
|
|
122
|
+
return [...Object.keys(json.dependencies || {}), ...Object.keys(json.devDependencies || {}), ...Object.keys(json.peerDependencies || {})];
|
|
123
|
+
} catch (e) {
|
|
124
|
+
console.warn('[WARN] package.json is broken');
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
exports.getAllDeps = getAllDeps;
|
package/dist/js/node/index.js
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
defineConfig: true
|
|
8
|
+
};
|
|
6
9
|
exports.default = void 0;
|
|
7
10
|
Object.defineProperty(exports, "defineConfig", {
|
|
8
11
|
enumerable: true,
|
|
@@ -21,6 +24,20 @@ var _pluginJarvis = _interopRequireDefault(require("@modern-js/plugin-jarvis"));
|
|
|
21
24
|
|
|
22
25
|
var _hooks = require("./hooks");
|
|
23
26
|
|
|
27
|
+
var _types = require("./types");
|
|
28
|
+
|
|
29
|
+
Object.keys(_types).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
32
|
+
if (key in exports && exports[key] === _types[key]) return;
|
|
33
|
+
Object.defineProperty(exports, key, {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () {
|
|
36
|
+
return _types[key];
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
24
41
|
var _core = require("@modern-js/core");
|
|
25
42
|
|
|
26
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -35,15 +35,22 @@ const properties = {
|
|
|
35
35
|
},
|
|
36
36
|
externals: {
|
|
37
37
|
type: 'array',
|
|
38
|
-
items:
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
items: {
|
|
39
|
+
anyOf: [{
|
|
40
|
+
instanceof: 'RegExp'
|
|
41
|
+
}, {
|
|
42
|
+
typeof: 'string'
|
|
43
|
+
}]
|
|
44
|
+
}
|
|
41
45
|
},
|
|
42
46
|
platform: {
|
|
43
47
|
enum: ['node', 'browser']
|
|
44
48
|
},
|
|
45
49
|
minify: {
|
|
46
50
|
enum: ['esbuild', 'terser', false]
|
|
51
|
+
},
|
|
52
|
+
skipDeps: {
|
|
53
|
+
type: 'boolean'
|
|
47
54
|
}
|
|
48
55
|
}
|
|
49
56
|
},
|
|
@@ -71,7 +71,7 @@ const copyTask = async option => {
|
|
|
71
71
|
|
|
72
72
|
glob = path.isAbsolute(fromOrigin) ? fromOrigin : path.posix.join(_utils.fastGlob.escapePath(normalizePath(path.resolve(context))), fromOrigin); // 计算 glob,获取目标文件
|
|
73
73
|
|
|
74
|
-
const paths = await (0, _utils.globby)(glob, options);
|
|
74
|
+
const paths = await (0, _utils.globby)((0, _utils.slash)(glob), options);
|
|
75
75
|
|
|
76
76
|
if (!paths.length) {
|
|
77
77
|
return;
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import type { PluginAPI } from '@modern-js/core';
|
|
2
2
|
import type { IBuildFeatOption } from '../../types';
|
|
3
|
-
|
|
3
|
+
import type { NormalizedBuildConfig } from './types';
|
|
4
|
+
export declare const checkPlatformAndRunBuild: (platform: IBuildFeatOption['platform'], options: {
|
|
5
|
+
api: PluginAPI;
|
|
6
|
+
isTsProject: boolean;
|
|
7
|
+
}) => Promise<{
|
|
8
|
+
exit: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
export declare const runBuild: (api: PluginAPI, normalizedModuleConfig: NormalizedBuildConfig[], config: IBuildFeatOption) => Promise<void>;
|
|
11
|
+
export declare const buildInNormalMode: (api: PluginAPI, normalizedModuleConfig: NormalizedBuildConfig[], config: IBuildFeatOption) => Promise<void>;
|
|
4
12
|
export declare const build: (api: PluginAPI, config: IBuildFeatOption) => Promise<void>;
|
|
@@ -11,8 +11,9 @@ export declare const getSourceMap: (config: Pick<BaseBuildConfig, 'sourceMap'>,
|
|
|
11
11
|
export declare const normalizeBuildConfig: (context: {
|
|
12
12
|
buildFeatOption: IBuildFeatOption;
|
|
13
13
|
api: PluginAPI;
|
|
14
|
-
}, buildConfig: BuildConfig) => NormalizedBuildConfig[];
|
|
14
|
+
}, buildConfig: BuildConfig, deps?: string[]) => NormalizedBuildConfig[];
|
|
15
15
|
export declare const normalizeModuleConfig: (context: {
|
|
16
16
|
buildFeatOption: IBuildFeatOption;
|
|
17
17
|
api: PluginAPI;
|
|
18
|
+
deps?: string[];
|
|
18
19
|
}) => NormalizedBuildConfig[];
|
|
@@ -34,4 +34,5 @@ export declare enum SectionTitleStatus {
|
|
|
34
34
|
Log = 2,
|
|
35
35
|
}
|
|
36
36
|
export declare const watchSectionTitle: (str: string, status: SectionTitleStatus) => string;
|
|
37
|
-
export declare const getPostcssOption: (appDirectory: string, modernConfig: NormalizedConfig) => PostcssOption;
|
|
37
|
+
export declare const getPostcssOption: (appDirectory: string, modernConfig: NormalizedConfig) => PostcssOption;
|
|
38
|
+
export declare const getAllDeps: <T>(appDirectory: string) => string[];
|
package/dist/types/index.d.ts
CHANGED
|
@@ -34,8 +34,14 @@ export declare const buildSchema: ({
|
|
|
34
34
|
externals: {
|
|
35
35
|
type: string;
|
|
36
36
|
items: {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
anyOf: ({
|
|
38
|
+
instanceof: string;
|
|
39
|
+
typeof?: undefined;
|
|
40
|
+
} | {
|
|
41
|
+
typeof: string;
|
|
42
|
+
instanceof?: undefined;
|
|
43
|
+
})[];
|
|
44
|
+
};
|
|
39
45
|
};
|
|
40
46
|
platform: {
|
|
41
47
|
enum: string[];
|
|
@@ -43,6 +49,9 @@ export declare const buildSchema: ({
|
|
|
43
49
|
minify: {
|
|
44
50
|
enum: (string | boolean)[];
|
|
45
51
|
};
|
|
52
|
+
skipDeps: {
|
|
53
|
+
type: string;
|
|
54
|
+
};
|
|
46
55
|
};
|
|
47
56
|
};
|
|
48
57
|
bundlelessOptions: {
|
|
@@ -114,8 +123,14 @@ export declare const buildSchema: ({
|
|
|
114
123
|
externals: {
|
|
115
124
|
type: string;
|
|
116
125
|
items: {
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
anyOf: ({
|
|
127
|
+
instanceof: string;
|
|
128
|
+
typeof?: undefined;
|
|
129
|
+
} | {
|
|
130
|
+
typeof: string;
|
|
131
|
+
instanceof?: undefined;
|
|
132
|
+
})[];
|
|
133
|
+
};
|
|
119
134
|
};
|
|
120
135
|
platform: {
|
|
121
136
|
enum: string[];
|
|
@@ -123,6 +138,9 @@ export declare const buildSchema: ({
|
|
|
123
138
|
minify: {
|
|
124
139
|
enum: (string | boolean)[];
|
|
125
140
|
};
|
|
141
|
+
skipDeps: {
|
|
142
|
+
type: string;
|
|
143
|
+
};
|
|
126
144
|
};
|
|
127
145
|
};
|
|
128
146
|
bundlelessOptions: {
|
|
@@ -37,8 +37,14 @@ export declare const addSchema: () => ({
|
|
|
37
37
|
externals: {
|
|
38
38
|
type: string;
|
|
39
39
|
items: {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
anyOf: ({
|
|
41
|
+
instanceof: string;
|
|
42
|
+
typeof?: undefined;
|
|
43
|
+
} | {
|
|
44
|
+
typeof: string;
|
|
45
|
+
instanceof?: undefined;
|
|
46
|
+
})[];
|
|
47
|
+
};
|
|
42
48
|
};
|
|
43
49
|
platform: {
|
|
44
50
|
enum: string[];
|
|
@@ -46,6 +52,9 @@ export declare const addSchema: () => ({
|
|
|
46
52
|
minify: {
|
|
47
53
|
enum: (string | boolean)[];
|
|
48
54
|
};
|
|
55
|
+
skipDeps: {
|
|
56
|
+
type: string;
|
|
57
|
+
};
|
|
49
58
|
};
|
|
50
59
|
};
|
|
51
60
|
bundlelessOptions: {
|
|
@@ -117,8 +126,14 @@ export declare const addSchema: () => ({
|
|
|
117
126
|
externals: {
|
|
118
127
|
type: string;
|
|
119
128
|
items: {
|
|
120
|
-
|
|
121
|
-
|
|
129
|
+
anyOf: ({
|
|
130
|
+
instanceof: string;
|
|
131
|
+
typeof?: undefined;
|
|
132
|
+
} | {
|
|
133
|
+
typeof: string;
|
|
134
|
+
instanceof?: undefined;
|
|
135
|
+
})[];
|
|
136
|
+
};
|
|
122
137
|
};
|
|
123
138
|
platform: {
|
|
124
139
|
enum: string[];
|
|
@@ -126,6 +141,9 @@ export declare const addSchema: () => ({
|
|
|
126
141
|
minify: {
|
|
127
142
|
enum: (string | boolean)[];
|
|
128
143
|
};
|
|
144
|
+
skipDeps: {
|
|
145
|
+
type: string;
|
|
146
|
+
};
|
|
129
147
|
};
|
|
130
148
|
};
|
|
131
149
|
bundlelessOptions: {
|
|
@@ -32,8 +32,14 @@ export declare const outputSchema: ({
|
|
|
32
32
|
externals: {
|
|
33
33
|
type: string;
|
|
34
34
|
items: {
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
anyOf: ({
|
|
36
|
+
instanceof: string;
|
|
37
|
+
typeof?: undefined;
|
|
38
|
+
} | {
|
|
39
|
+
typeof: string;
|
|
40
|
+
instanceof?: undefined;
|
|
41
|
+
})[];
|
|
42
|
+
};
|
|
37
43
|
};
|
|
38
44
|
platform: {
|
|
39
45
|
enum: string[];
|
|
@@ -41,6 +47,9 @@ export declare const outputSchema: ({
|
|
|
41
47
|
minify: {
|
|
42
48
|
enum: (string | boolean)[];
|
|
43
49
|
};
|
|
50
|
+
skipDeps: {
|
|
51
|
+
type: string;
|
|
52
|
+
};
|
|
44
53
|
};
|
|
45
54
|
};
|
|
46
55
|
bundlelessOptions: {
|
|
@@ -112,8 +121,14 @@ export declare const outputSchema: ({
|
|
|
112
121
|
externals: {
|
|
113
122
|
type: string;
|
|
114
123
|
items: {
|
|
115
|
-
|
|
116
|
-
|
|
124
|
+
anyOf: ({
|
|
125
|
+
instanceof: string;
|
|
126
|
+
typeof?: undefined;
|
|
127
|
+
} | {
|
|
128
|
+
typeof: string;
|
|
129
|
+
instanceof?: undefined;
|
|
130
|
+
})[];
|
|
131
|
+
};
|
|
117
132
|
};
|
|
118
133
|
platform: {
|
|
119
134
|
enum: string[];
|
|
@@ -121,6 +136,9 @@ export declare const outputSchema: ({
|
|
|
121
136
|
minify: {
|
|
122
137
|
enum: (string | boolean)[];
|
|
123
138
|
};
|
|
139
|
+
skipDeps: {
|
|
140
|
+
type: string;
|
|
141
|
+
};
|
|
124
142
|
};
|
|
125
143
|
};
|
|
126
144
|
bundlelessOptions: {
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.6.0
|
|
14
|
+
"version": "1.6.0",
|
|
15
15
|
"bin": {
|
|
16
16
|
"modern": "./bin/modern.js"
|
|
17
17
|
},
|
|
@@ -54,22 +54,23 @@
|
|
|
54
54
|
"@babel/runtime": "^7.18.0",
|
|
55
55
|
"@babel/traverse": "^7.18.0",
|
|
56
56
|
"@babel/types": "^7.18.0",
|
|
57
|
-
"@modern-js/babel-compiler": "^1.2.
|
|
58
|
-
"@modern-js/babel-preset-module": "^1.
|
|
59
|
-
"@modern-js/core": "^1.12.
|
|
60
|
-
"@modern-js/css-config": "^1.2.
|
|
57
|
+
"@modern-js/babel-compiler": "^1.2.6",
|
|
58
|
+
"@modern-js/babel-preset-module": "^1.3.9",
|
|
59
|
+
"@modern-js/core": "^1.12.3",
|
|
60
|
+
"@modern-js/css-config": "^1.2.7",
|
|
61
61
|
"@modern-js/i18n-cli-language-detector": "^1.2.4",
|
|
62
|
-
"@modern-js/new-action": "^1.3.11
|
|
63
|
-
"@modern-js/plugin": "^1.4.0
|
|
64
|
-
"@modern-js/plugin-analyze": "^1.4.7
|
|
65
|
-
"@modern-js/plugin-changeset": "^1.3.1
|
|
66
|
-
"@modern-js/plugin-i18n": "^1.2.
|
|
67
|
-
"@modern-js/plugin-jarvis": "^1.2.14
|
|
68
|
-
"@modern-js/style-compiler": "^1.2.11
|
|
69
|
-
"@modern-js/utils": "^1.7.
|
|
62
|
+
"@modern-js/new-action": "^1.3.11",
|
|
63
|
+
"@modern-js/plugin": "^1.4.0",
|
|
64
|
+
"@modern-js/plugin-analyze": "^1.4.7",
|
|
65
|
+
"@modern-js/plugin-changeset": "^1.3.1",
|
|
66
|
+
"@modern-js/plugin-i18n": "^1.2.7",
|
|
67
|
+
"@modern-js/plugin-jarvis": "^1.2.14",
|
|
68
|
+
"@modern-js/style-compiler": "^1.2.11",
|
|
69
|
+
"@modern-js/utils": "^1.7.10",
|
|
70
70
|
"@rollup/plugin-json": "~4.1.0",
|
|
71
|
-
"@speedy-js/speedy-
|
|
72
|
-
"@speedy-js/speedy-
|
|
71
|
+
"@speedy-js/speedy-types": "0.13.2-alpha.3",
|
|
72
|
+
"@speedy-js/speedy-core": "0.13.2-alpha.3",
|
|
73
|
+
"@speedy-js/speedy-plugin-es5": "0.13.2-alpha.3",
|
|
73
74
|
"normalize-path": "^3.0.0",
|
|
74
75
|
"p-map": "^4",
|
|
75
76
|
"process.argv": "^0.6.0",
|
|
@@ -81,7 +82,7 @@
|
|
|
81
82
|
"devDependencies": {
|
|
82
83
|
"@scripts/build": "0.0.0",
|
|
83
84
|
"@scripts/jest-config": "0.0.0",
|
|
84
|
-
"@speedy-js/speedy-types": "0.13.
|
|
85
|
+
"@speedy-js/speedy-types": "0.13.2-alpha.3",
|
|
85
86
|
"@types/babel__core": "^7.1.15",
|
|
86
87
|
"@types/babel__generator": "^7.6.3",
|
|
87
88
|
"@types/babel__traverse": "^7.14.2",
|
|
@@ -113,7 +114,8 @@
|
|
|
113
114
|
"files": [
|
|
114
115
|
"src/**/*",
|
|
115
116
|
"tsconfig.json",
|
|
116
|
-
"package.json"
|
|
117
|
+
"package.json",
|
|
118
|
+
"./modern.config.js"
|
|
117
119
|
],
|
|
118
120
|
"output": [
|
|
119
121
|
"dist/**/*"
|