@modern-js/app-tools 2.0.0-beta.1 → 2.0.0-beta.3
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 +445 -0
- package/bin/modern.js +10 -1
- package/dist/js/modern/analyze/constants.js +2 -0
- package/dist/js/modern/analyze/generateCode.js +39 -19
- package/dist/js/modern/analyze/getBundleEntry.js +1 -1
- package/dist/js/modern/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/modern/analyze/getHtmlTemplate.js +1 -1
- package/dist/js/modern/analyze/getServerRoutes.js +8 -4
- package/dist/js/modern/analyze/index.js +12 -27
- package/dist/js/modern/analyze/nestedRoutes.js +17 -6
- package/dist/js/modern/analyze/templates.js +59 -27
- package/dist/js/modern/analyze/utils.js +30 -4
- package/dist/js/modern/builder/builderPlugins/compatModern.js +18 -12
- package/dist/js/modern/builder/index.js +31 -16
- package/dist/js/modern/builder/loaders/routerLoader.js +20 -0
- package/dist/js/modern/builder/loaders/serverModuleLoader.js +4 -0
- package/dist/js/modern/builder/share.js +1 -1
- package/dist/js/modern/commands/build.js +8 -2
- package/dist/js/modern/commands/dev.js +37 -32
- package/dist/js/modern/commands/inspect.js +4 -2
- package/dist/js/modern/config/default.js +206 -0
- package/dist/js/modern/config/index.js +2 -0
- package/dist/js/modern/config/initial/createHtmlConfig.js +32 -0
- package/dist/js/modern/{builder → config/initial}/createOutputConfig.js +16 -15
- package/dist/js/modern/config/initial/createSourceConfig.js +32 -0
- package/dist/js/modern/config/initial/createToolsConfig.js +41 -0
- package/dist/js/modern/config/initial/index.js +11 -0
- package/dist/js/modern/config/initial/inits.js +117 -0
- package/dist/js/modern/config/initial/transformNormalizedConfig.js +40 -0
- package/dist/js/modern/defineConfig.js +12 -0
- package/dist/js/modern/hooks.js +23 -19
- package/dist/js/modern/index.js +7 -5
- package/dist/js/modern/initialize/index.js +72 -0
- package/dist/js/modern/schema/Schema.js +39 -0
- package/dist/js/modern/schema/index.js +139 -0
- package/dist/js/modern/schema/legacy.js +284 -0
- package/dist/js/modern/types/config/deploy.js +0 -0
- package/dist/js/modern/types/config/dev.js +0 -0
- package/dist/js/modern/types/config/experiments.js +0 -0
- package/dist/js/modern/types/config/html.js +0 -0
- package/dist/js/modern/types/config/index.js +2 -0
- package/dist/js/modern/types/config/output.js +0 -0
- package/dist/js/modern/types/config/performance.js +0 -0
- package/dist/js/modern/types/config/security.js +0 -0
- package/dist/js/modern/types/config/source.js +0 -0
- package/dist/js/modern/types/config/tools.js +0 -0
- package/dist/js/modern/types/hooks.js +0 -0
- package/dist/js/modern/types/index.js +4 -0
- package/dist/js/modern/types/legacyConfig/deploy.js +0 -0
- package/dist/js/modern/types/legacyConfig/dev.js +0 -0
- package/dist/js/modern/types/legacyConfig/index.js +0 -0
- package/dist/js/modern/types/legacyConfig/output.js +1 -0
- package/dist/js/modern/types/legacyConfig/source.js +0 -0
- package/dist/js/modern/types/legacyConfig/tools.js +0 -0
- package/dist/js/modern/utils/config.js +1 -1
- package/dist/js/modern/utils/createFileWatcher.js +82 -0
- package/dist/js/modern/utils/restart.js +17 -0
- package/dist/js/node/analyze/constants.js +5 -1
- package/dist/js/node/analyze/generateCode.js +37 -17
- package/dist/js/node/analyze/getBundleEntry.js +1 -1
- package/dist/js/node/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/node/analyze/getHtmlTemplate.js +1 -1
- package/dist/js/node/analyze/getServerRoutes.js +8 -4
- package/dist/js/node/analyze/index.js +13 -39
- package/dist/js/node/analyze/nestedRoutes.js +15 -4
- package/dist/js/node/analyze/templates.js +60 -27
- package/dist/js/node/analyze/utils.js +31 -3
- package/dist/js/node/builder/builderPlugins/compatModern.js +18 -12
- package/dist/js/node/builder/index.js +32 -16
- package/dist/js/node/builder/loaders/routerLoader.js +27 -0
- package/dist/js/node/builder/loaders/serverModuleLoader.js +11 -0
- package/dist/js/node/builder/share.js +1 -1
- package/dist/js/node/commands/build.js +8 -2
- package/dist/js/node/commands/dev.js +37 -32
- package/dist/js/node/commands/inspect.js +4 -2
- package/dist/js/node/config/default.js +213 -0
- package/dist/js/node/config/index.js +31 -0
- package/dist/js/node/config/initial/createHtmlConfig.js +38 -0
- package/dist/js/node/{builder → config/initial}/createOutputConfig.js +16 -15
- package/dist/js/node/config/initial/createSourceConfig.js +38 -0
- package/dist/js/node/config/initial/createToolsConfig.js +47 -0
- package/dist/js/node/config/initial/index.js +24 -0
- package/dist/js/node/config/initial/inits.js +127 -0
- package/dist/js/node/config/initial/transformNormalizedConfig.js +46 -0
- package/dist/js/node/defineConfig.js +20 -0
- package/dist/js/node/hooks.js +23 -28
- package/dist/js/node/index.js +30 -16
- package/dist/js/node/initialize/index.js +79 -0
- package/dist/js/node/schema/Schema.js +46 -0
- package/dist/js/node/schema/index.js +152 -0
- package/dist/js/node/schema/legacy.js +291 -0
- package/dist/js/node/types/config/deploy.js +0 -0
- package/dist/js/node/types/config/dev.js +0 -0
- package/dist/js/node/types/config/experiments.js +0 -0
- package/dist/js/node/types/config/html.js +0 -0
- package/dist/js/node/types/config/index.js +16 -0
- package/dist/js/node/types/config/output.js +0 -0
- package/dist/js/node/types/config/performance.js +0 -0
- package/dist/js/node/types/config/security.js +0 -0
- package/dist/js/node/types/config/source.js +0 -0
- package/dist/js/node/types/config/tools.js +0 -0
- package/dist/js/node/types/hooks.js +0 -0
- package/dist/js/node/types/index.js +38 -0
- package/dist/js/node/types/legacyConfig/deploy.js +0 -0
- package/dist/js/node/types/legacyConfig/dev.js +0 -0
- package/dist/js/node/types/legacyConfig/index.js +0 -0
- package/dist/js/node/types/legacyConfig/output.js +5 -0
- package/dist/js/node/types/legacyConfig/source.js +0 -0
- package/dist/js/node/types/legacyConfig/tools.js +0 -0
- package/dist/js/node/utils/config.js +1 -1
- package/dist/js/node/utils/createFileWatcher.js +91 -0
- package/dist/js/node/utils/restart.js +23 -0
- package/dist/js/treeshaking/analyze/constants.js +2 -0
- package/dist/js/treeshaking/analyze/generateCode.js +138 -82
- package/dist/js/treeshaking/analyze/getBundleEntry.js +1 -1
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +1 -1
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +1 -1
- package/dist/js/treeshaking/analyze/getServerRoutes.js +7 -5
- package/dist/js/treeshaking/analyze/index.js +10 -26
- package/dist/js/treeshaking/analyze/nestedRoutes.js +98 -55
- package/dist/js/treeshaking/analyze/templates.js +175 -101
- package/dist/js/treeshaking/analyze/utils.js +80 -4
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +18 -12
- package/dist/js/treeshaking/builder/index.js +29 -16
- package/dist/js/treeshaking/builder/loaders/routerLoader.js +14 -0
- package/dist/js/treeshaking/builder/loaders/serverModuleLoader.js +4 -0
- package/dist/js/treeshaking/builder/share.js +1 -1
- package/dist/js/treeshaking/commands/build.js +33 -23
- package/dist/js/treeshaking/commands/dev.js +56 -43
- package/dist/js/treeshaking/commands/inspect.js +8 -3
- package/dist/js/treeshaking/config/default.js +199 -0
- package/dist/js/treeshaking/config/index.js +2 -0
- package/dist/js/treeshaking/config/initial/createHtmlConfig.js +31 -0
- package/dist/js/treeshaking/config/initial/createOutputConfig.js +70 -0
- package/dist/js/treeshaking/config/initial/createSourceConfig.js +41 -0
- package/dist/js/treeshaking/config/initial/createToolsConfig.js +38 -0
- package/dist/js/treeshaking/config/initial/index.js +11 -0
- package/dist/js/treeshaking/config/initial/inits.js +114 -0
- package/dist/js/treeshaking/config/initial/transformNormalizedConfig.js +38 -0
- package/dist/js/treeshaking/defineConfig.js +14 -0
- package/dist/js/treeshaking/hooks.js +23 -19
- package/dist/js/treeshaking/index.js +7 -5
- package/dist/js/treeshaking/initialize/index.js +121 -0
- package/dist/js/treeshaking/schema/Schema.js +75 -0
- package/dist/js/treeshaking/schema/index.js +138 -0
- package/dist/js/treeshaking/schema/legacy.js +273 -0
- package/dist/js/treeshaking/types/config/deploy.js +0 -0
- package/dist/js/treeshaking/types/config/dev.js +0 -0
- package/dist/js/treeshaking/types/config/experiments.js +0 -0
- package/dist/js/treeshaking/types/config/html.js +0 -0
- package/dist/js/treeshaking/types/config/index.js +2 -0
- package/dist/js/treeshaking/types/config/output.js +0 -0
- package/dist/js/treeshaking/types/config/performance.js +0 -0
- package/dist/js/treeshaking/types/config/security.js +0 -0
- package/dist/js/treeshaking/types/config/source.js +0 -0
- package/dist/js/treeshaking/types/config/tools.js +0 -0
- package/dist/js/treeshaking/types/hooks.js +0 -0
- package/dist/js/treeshaking/types/index.js +4 -0
- package/dist/js/treeshaking/types/legacyConfig/deploy.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/dev.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/index.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/output.js +1 -0
- package/dist/js/treeshaking/types/legacyConfig/source.js +0 -0
- package/dist/js/treeshaking/types/legacyConfig/tools.js +0 -0
- package/dist/js/treeshaking/utils/config.js +1 -1
- package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
- package/dist/js/treeshaking/utils/restart.js +45 -0
- package/dist/types/analyze/constants.d.ts +2 -0
- package/dist/types/analyze/generateCode.d.ts +3 -2
- package/dist/types/analyze/getBundleEntry.d.ts +2 -2
- package/dist/types/analyze/getFileSystemEntry.d.ts +2 -2
- package/dist/types/analyze/getHtmlTemplate.d.ts +3 -3
- package/dist/types/analyze/getServerRoutes.d.ts +3 -2
- package/dist/types/analyze/index.d.ts +3 -41
- package/dist/types/analyze/templates.d.ts +9 -8
- package/dist/types/analyze/utils.d.ts +10 -2
- package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -2
- package/dist/types/builder/index.d.ts +5 -2
- package/dist/types/builder/loaders/routerLoader.d.ts +3 -0
- package/dist/types/builder/loaders/serverModuleLoader.d.ts +3 -0
- package/dist/types/builder/share.d.ts +2 -2
- package/dist/types/commands/build.d.ts +2 -2
- package/dist/types/commands/deploy.d.ts +2 -2
- package/dist/types/commands/dev.d.ts +2 -2
- package/dist/types/commands/inspect.d.ts +9 -1
- package/dist/types/commands/start.d.ts +2 -2
- package/dist/types/config/default.d.ts +3 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/config/initial/createHtmlConfig.d.ts +2 -0
- package/dist/types/config/initial/createOutputConfig.d.ts +2 -0
- package/dist/types/config/initial/createSourceConfig.d.ts +2 -0
- package/dist/types/config/initial/createToolsConfig.d.ts +2 -0
- package/dist/types/config/initial/index.d.ts +4 -0
- package/dist/types/config/initial/inits.d.ts +4 -0
- package/dist/types/config/initial/transformNormalizedConfig.d.ts +2 -0
- package/dist/types/defineConfig.d.ts +7 -0
- package/dist/types/hooks.d.ts +2 -42
- package/dist/types/index.d.ts +5 -5
- package/dist/types/initialize/index.d.ts +3 -0
- package/dist/types/schema/Schema.d.ts +14 -0
- package/dist/types/schema/index.d.ts +4 -0
- package/dist/types/schema/legacy.d.ts +3 -0
- package/dist/types/types/config/deploy.d.ts +9 -0
- package/dist/types/types/config/dev.d.ts +13 -0
- package/dist/types/types/config/experiments.d.ts +4 -0
- package/dist/types/types/config/html.d.ts +4 -0
- package/dist/types/types/config/index.d.ts +62 -0
- package/dist/types/types/config/output.d.ts +23 -0
- package/dist/types/types/config/performance.d.ts +4 -0
- package/dist/types/types/config/security.d.ts +4 -0
- package/dist/types/types/config/source.d.ts +22 -0
- package/dist/types/types/config/tools.d.ts +22 -0
- package/dist/types/types/hooks.d.ts +81 -0
- package/dist/types/types/index.d.ts +23 -0
- package/dist/types/types/legacyConfig/deploy.d.ts +8 -0
- package/dist/types/types/legacyConfig/dev.d.ts +12 -0
- package/dist/types/types/legacyConfig/index.d.ts +33 -0
- package/dist/types/types/legacyConfig/output.d.ts +51 -0
- package/dist/types/types/legacyConfig/source.d.ts +25 -0
- package/dist/types/types/legacyConfig/tools.d.ts +16 -0
- package/dist/types/utils/config.d.ts +2 -2
- package/dist/types/utils/createFileWatcher.d.ts +4 -0
- package/dist/types/utils/printInstructions.d.ts +3 -3
- package/dist/types/utils/restart.d.ts +3 -0
- package/lib/types.d.ts +1 -1
- package/package.json +28 -25
- package/dist/js/modern/builder/createHtmlConfig.js +0 -58
- package/dist/js/modern/builder/createSourceConfig.js +0 -74
- package/dist/js/modern/builder/createToolsConfig.js +0 -87
- package/dist/js/node/builder/createHtmlConfig.js +0 -68
- package/dist/js/node/builder/createSourceConfig.js +0 -82
- package/dist/js/node/builder/createToolsConfig.js +0 -94
- package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
- package/dist/js/treeshaking/builder/createOutputConfig.js +0 -70
- package/dist/js/treeshaking/builder/createSourceConfig.js +0 -88
- package/dist/js/treeshaking/builder/createToolsConfig.js +0 -85
- package/dist/types/builder/createHtmlConfig.d.ts +0 -6
- package/dist/types/builder/createOutputConfig.d.ts +0 -3
- package/dist/types/builder/createSourceConfig.d.ts +0 -5
- package/dist/types/builder/createToolsConfig.d.ts +0 -13
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createBuilderInclude = createBuilderInclude;
|
|
7
|
-
exports.createBuilderModuleScope = createBuilderModuleScope;
|
|
8
|
-
exports.createSourceConfig = createSourceConfig;
|
|
9
|
-
var _path = require("path");
|
|
10
|
-
var _utils = require("@modern-js/utils");
|
|
11
|
-
function createSourceConfig(normalizedConfig, appContext) {
|
|
12
|
-
const {
|
|
13
|
-
alias,
|
|
14
|
-
envVars,
|
|
15
|
-
globalVars,
|
|
16
|
-
include,
|
|
17
|
-
moduleScopes,
|
|
18
|
-
preEntry
|
|
19
|
-
} = normalizedConfig.source;
|
|
20
|
-
const builderGlobalVars = globalVars || {};
|
|
21
|
-
for (const envVar of envVars || []) {
|
|
22
|
-
const envVarValue = process.env[envVar];
|
|
23
|
-
envVarValue && (builderGlobalVars[`process.env.${envVar}`] = envVarValue);
|
|
24
|
-
}
|
|
25
|
-
const builderModuleScope = createBuilderModuleScope(moduleScopes);
|
|
26
|
-
const builderInclude = createBuilderInclude(include, appContext);
|
|
27
|
-
return {
|
|
28
|
-
alias: (0, _utils.mergeAlias)(alias),
|
|
29
|
-
moduleScopes: builderModuleScope,
|
|
30
|
-
globalVars: builderGlobalVars,
|
|
31
|
-
include: builderInclude,
|
|
32
|
-
preEntry,
|
|
33
|
-
// ensure resolve.extensions same as before
|
|
34
|
-
resolveExtensionPrefix: '.web'
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function createBuilderInclude(include, appContext) {
|
|
38
|
-
const defaultInclude = [appContext.internalDirectory];
|
|
39
|
-
const transformInclude = (include || []).map(include => {
|
|
40
|
-
if (typeof include === 'string') {
|
|
41
|
-
if ((0, _path.isAbsolute)(include)) {
|
|
42
|
-
return include;
|
|
43
|
-
}
|
|
44
|
-
return new RegExp(include);
|
|
45
|
-
}
|
|
46
|
-
return include;
|
|
47
|
-
}).concat(defaultInclude); // concat default Include
|
|
48
|
-
|
|
49
|
-
const root = (0, _utils.findMonorepoRoot)(appContext.appDirectory);
|
|
50
|
-
if (!root) {
|
|
51
|
-
return transformInclude;
|
|
52
|
-
}
|
|
53
|
-
const modernjsMonorepo = (0, _utils.isModernjsMonorepo)(root);
|
|
54
|
-
if (modernjsMonorepo) {
|
|
55
|
-
const paths = _utils.globby.sync(_path.posix.join(root, 'features', '**', 'package.json'), {
|
|
56
|
-
ignore: ['**/node_modules/**/*']
|
|
57
|
-
}).map(pathname => (0, _path.dirname)(pathname) + _path.sep);
|
|
58
|
-
return [...paths, ...transformInclude];
|
|
59
|
-
}
|
|
60
|
-
return transformInclude;
|
|
61
|
-
}
|
|
62
|
-
function createBuilderModuleScope(moduleScopes) {
|
|
63
|
-
if (moduleScopes) {
|
|
64
|
-
let builderModuleScope = [];
|
|
65
|
-
const DEFAULT_SCOPES = ['./src', './shared', /node_modules/];
|
|
66
|
-
if (Array.isArray(moduleScopes)) {
|
|
67
|
-
if (isPrimitiveScope(moduleScopes)) {
|
|
68
|
-
builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
|
|
69
|
-
} else {
|
|
70
|
-
builderModuleScope = [DEFAULT_SCOPES, ...moduleScopes];
|
|
71
|
-
}
|
|
72
|
-
} else {
|
|
73
|
-
builderModuleScope = [DEFAULT_SCOPES, moduleScopes];
|
|
74
|
-
}
|
|
75
|
-
return builderModuleScope;
|
|
76
|
-
} else {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
function isPrimitiveScope(items) {
|
|
80
|
-
return items.every(item => typeof item === 'string' || Object.prototype.toString.call(item) === '[object RegExp]');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createBuilderTsChecker = createBuilderTsChecker;
|
|
7
|
-
exports.createToolsConfig = createToolsConfig;
|
|
8
|
-
var _utils = require("@modern-js/utils");
|
|
9
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
10
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
12
|
-
function createToolsConfig(normalizedConfig) {
|
|
13
|
-
const {
|
|
14
|
-
disableCssExtract,
|
|
15
|
-
enableTsLoader
|
|
16
|
-
} = normalizedConfig.output;
|
|
17
|
-
const {
|
|
18
|
-
autoprefixer,
|
|
19
|
-
babel,
|
|
20
|
-
minifyCss,
|
|
21
|
-
terser,
|
|
22
|
-
webpack,
|
|
23
|
-
webpackChain,
|
|
24
|
-
tsLoader,
|
|
25
|
-
styledComponents,
|
|
26
|
-
sass,
|
|
27
|
-
postcss,
|
|
28
|
-
less,
|
|
29
|
-
htmlPlugin,
|
|
30
|
-
// TODO: remove modernjs tools.lodash config
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
32
|
-
lodash
|
|
33
|
-
} = normalizedConfig.tools;
|
|
34
|
-
const builderTsLoader = createBuilderTsLoader(tsLoader, enableTsLoader);
|
|
35
|
-
const builderTsChecker = createBuilderTsChecker(normalizedConfig.output);
|
|
36
|
-
return {
|
|
37
|
-
tsChecker: builderTsChecker,
|
|
38
|
-
styleLoader: disableCssExtract ? {} : undefined,
|
|
39
|
-
cssExtract: disableCssExtract ? false : undefined,
|
|
40
|
-
autoprefixer,
|
|
41
|
-
babel,
|
|
42
|
-
minifyCss,
|
|
43
|
-
terser,
|
|
44
|
-
webpack,
|
|
45
|
-
webpackChain: webpackChain,
|
|
46
|
-
tsLoader: builderTsLoader,
|
|
47
|
-
styledComponents: styledComponents,
|
|
48
|
-
sass: sass,
|
|
49
|
-
postcss: postcss,
|
|
50
|
-
less: less,
|
|
51
|
-
// can't remove comment in html minify.
|
|
52
|
-
// some html template insert by using those comments.
|
|
53
|
-
htmlPlugin: [config => _objectSpread(_objectSpread({}, config), {}, {
|
|
54
|
-
minify: typeof config.minify === 'object' ? _objectSpread(_objectSpread({}, config.minify), {}, {
|
|
55
|
-
removeComments: false
|
|
56
|
-
}) : config.minify
|
|
57
|
-
}),
|
|
58
|
-
// eslint-disable-next-line no-nested-ternary
|
|
59
|
-
...(Array.isArray(htmlPlugin) ? htmlPlugin : htmlPlugin ? [htmlPlugin] : [])]
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function createBuilderTsLoader(tsLoader, enableTsLoader) {
|
|
63
|
-
const useTsLoader = Boolean(enableTsLoader);
|
|
64
|
-
if (!useTsLoader) {
|
|
65
|
-
return undefined;
|
|
66
|
-
}
|
|
67
|
-
const defaultTsLoader = {
|
|
68
|
-
compilerOptions: {
|
|
69
|
-
target: 'es5',
|
|
70
|
-
module: 'ESNext'
|
|
71
|
-
},
|
|
72
|
-
transpileOnly: false,
|
|
73
|
-
allowTsInNodeModules: true
|
|
74
|
-
};
|
|
75
|
-
return (_, utils) => (0, _utils.applyOptionsChain)(defaultTsLoader, tsLoader, utils);
|
|
76
|
-
}
|
|
77
|
-
function createBuilderTsChecker(output) {
|
|
78
|
-
if (output.enableTsLoader) {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
const defaultTsChecker = {
|
|
82
|
-
issue: {
|
|
83
|
-
include: [{
|
|
84
|
-
file: '**/src/**/*'
|
|
85
|
-
}],
|
|
86
|
-
exclude: [{
|
|
87
|
-
file: '**/*.(spec|test).ts'
|
|
88
|
-
}, {
|
|
89
|
-
file: '**/node_modules/**/*'
|
|
90
|
-
}]
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
return defaultTsChecker;
|
|
94
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { findExists } from '@modern-js/utils';
|
|
3
|
-
export function createHtmlConfig(normalizedConfig, appContext) {
|
|
4
|
-
var _normalizedConfig$out = normalizedConfig.output,
|
|
5
|
-
disableHtmlFolder = _normalizedConfig$out.disableHtmlFolder,
|
|
6
|
-
favicon = _normalizedConfig$out.favicon,
|
|
7
|
-
faviconByEntries = _normalizedConfig$out.faviconByEntries,
|
|
8
|
-
inject = _normalizedConfig$out.inject,
|
|
9
|
-
injectByEntries = _normalizedConfig$out.injectByEntries,
|
|
10
|
-
meta = _normalizedConfig$out.meta,
|
|
11
|
-
metaByEntries = _normalizedConfig$out.metaByEntries,
|
|
12
|
-
mountId = _normalizedConfig$out.mountId,
|
|
13
|
-
title = _normalizedConfig$out.title,
|
|
14
|
-
titleByEntries = _normalizedConfig$out.titleByEntries,
|
|
15
|
-
scriptExt = _normalizedConfig$out.scriptExt,
|
|
16
|
-
templateParameters = _normalizedConfig$out.templateParameters,
|
|
17
|
-
templateParametersByEntries = _normalizedConfig$out.templateParametersByEntries;
|
|
18
|
-
var configDir = normalizedConfig.source.configDir;
|
|
19
|
-
|
|
20
|
-
// transform Modernjs `output.scriptExt` to Builder `html.crossorigin` configuration
|
|
21
|
-
var builderCrossorigin = createBuilderCrossorigin(scriptExt);
|
|
22
|
-
var builderAppIcon = createBuilderAppIcon(configDir, appContext);
|
|
23
|
-
var builderFavicon = createBuilderFavicon(favicon, configDir, appContext);
|
|
24
|
-
return {
|
|
25
|
-
appIcon: builderAppIcon,
|
|
26
|
-
disableHtmlFolder: disableHtmlFolder,
|
|
27
|
-
favicon: builderFavicon,
|
|
28
|
-
faviconByEntries: faviconByEntries,
|
|
29
|
-
inject: inject,
|
|
30
|
-
injectByEntries: injectByEntries,
|
|
31
|
-
meta: meta,
|
|
32
|
-
metaByEntries: metaByEntries,
|
|
33
|
-
mountId: mountId,
|
|
34
|
-
title: title,
|
|
35
|
-
titleByEntries: titleByEntries,
|
|
36
|
-
crossorigin: builderCrossorigin,
|
|
37
|
-
templateByEntries: appContext.htmlTemplates,
|
|
38
|
-
templateParameters: templateParameters,
|
|
39
|
-
templateParametersByEntries: templateParametersByEntries
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
var ICON_EXTENSIONS = ['png', 'jpg', 'jpeg', 'svg', 'ico'];
|
|
43
|
-
export function createBuilderAppIcon(configDir, appContext) {
|
|
44
|
-
var appIcon = findExists(ICON_EXTENSIONS.map(function (ext) {
|
|
45
|
-
return path.resolve(appContext.appDirectory, configDir, "icon.".concat(ext));
|
|
46
|
-
}));
|
|
47
|
-
return typeof appIcon === 'string' ? appIcon : undefined;
|
|
48
|
-
}
|
|
49
|
-
export function createBuilderCrossorigin(scriptExt) {
|
|
50
|
-
var _scriptExtCustomConfi;
|
|
51
|
-
var scriptExtCustomConfig = scriptExt === null || scriptExt === void 0 ? void 0 : scriptExt.custom;
|
|
52
|
-
return scriptExtCustomConfig !== null && scriptExtCustomConfig !== void 0 && (_scriptExtCustomConfi = scriptExtCustomConfig.test) !== null && _scriptExtCustomConfi !== void 0 && _scriptExtCustomConfi.test('.js') && (scriptExtCustomConfig === null || scriptExtCustomConfig === void 0 ? void 0 : scriptExtCustomConfig.attribute) === 'crossorigin' ? scriptExtCustomConfig.value : undefined;
|
|
53
|
-
}
|
|
54
|
-
export function createBuilderFavicon(favicon, configDir, appContext) {
|
|
55
|
-
var defaultFavicon = findExists(ICON_EXTENSIONS.map(function (ext) {
|
|
56
|
-
return path.resolve(appContext.appDirectory, configDir, "favicon.".concat(ext));
|
|
57
|
-
}));
|
|
58
|
-
return favicon || defaultFavicon || undefined;
|
|
59
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import { createCopyPattern } from "./share";
|
|
3
|
-
export function createOutputConfig(normalizedConfig, appContext) {
|
|
4
|
-
// TODO: add `externals` options in Modern.
|
|
5
|
-
|
|
6
|
-
var _normalizedConfig$out = normalizedConfig.output,
|
|
7
|
-
assetPrefix = _normalizedConfig$out.assetPrefix,
|
|
8
|
-
copy = _normalizedConfig$out.copy,
|
|
9
|
-
cssModuleLocalIdentName = _normalizedConfig$out.cssModuleLocalIdentName,
|
|
10
|
-
cssPath = _normalizedConfig$out.cssPath,
|
|
11
|
-
jsPath = _normalizedConfig$out.jsPath,
|
|
12
|
-
htmlPath = _normalizedConfig$out.htmlPath,
|
|
13
|
-
mediaPath = _normalizedConfig$out.mediaPath,
|
|
14
|
-
path = _normalizedConfig$out.path,
|
|
15
|
-
disableInlineRuntimeChunk = _normalizedConfig$out.disableInlineRuntimeChunk,
|
|
16
|
-
disableMinimize = _normalizedConfig$out.disableMinimize,
|
|
17
|
-
disableSourceMap = _normalizedConfig$out.disableSourceMap,
|
|
18
|
-
disableTsChecker = _normalizedConfig$out.disableTsChecker,
|
|
19
|
-
enableCssModuleTSDeclaration = _normalizedConfig$out.enableCssModuleTSDeclaration,
|
|
20
|
-
enableInlineScripts = _normalizedConfig$out.enableInlineScripts,
|
|
21
|
-
enableInlineStyles = _normalizedConfig$out.enableInlineStyles,
|
|
22
|
-
polyfill = _normalizedConfig$out.polyfill,
|
|
23
|
-
dataUriLimit = _normalizedConfig$out.dataUriLimit,
|
|
24
|
-
disableAssetsCache = _normalizedConfig$out.disableAssetsCache,
|
|
25
|
-
enableLatestDecorators = _normalizedConfig$out.enableLatestDecorators,
|
|
26
|
-
disableCssModuleExtension = _normalizedConfig$out.disableCssModuleExtension;
|
|
27
|
-
var defaultCopyPattern = createCopyPattern(appContext, normalizedConfig, 'upload');
|
|
28
|
-
var builderCopy = copy ? [].concat(_toConsumableArray(copy), [defaultCopyPattern]) : [defaultCopyPattern];
|
|
29
|
-
return {
|
|
30
|
-
assetPrefix: assetPrefix,
|
|
31
|
-
copy: builderCopy,
|
|
32
|
-
distPath: {
|
|
33
|
-
root: path,
|
|
34
|
-
css: cssPath,
|
|
35
|
-
js: jsPath,
|
|
36
|
-
html: htmlPath,
|
|
37
|
-
// `@modern-js/webpack` output all media files to `dist/media` by default
|
|
38
|
-
svg: mediaPath || 'media',
|
|
39
|
-
image: mediaPath || 'media',
|
|
40
|
-
font: mediaPath || 'media',
|
|
41
|
-
media: mediaPath || 'media'
|
|
42
|
-
},
|
|
43
|
-
dataUriLimit: {
|
|
44
|
-
svg: dataUriLimit,
|
|
45
|
-
image: dataUriLimit,
|
|
46
|
-
font: dataUriLimit,
|
|
47
|
-
media: dataUriLimit
|
|
48
|
-
},
|
|
49
|
-
disableCssModuleExtension: disableCssModuleExtension,
|
|
50
|
-
disableInlineRuntimeChunk: disableInlineRuntimeChunk,
|
|
51
|
-
disableMinimize: disableMinimize,
|
|
52
|
-
disableSourceMap: disableSourceMap,
|
|
53
|
-
disableTsChecker: disableTsChecker,
|
|
54
|
-
enableCssModuleTSDeclaration: enableCssModuleTSDeclaration,
|
|
55
|
-
enableInlineScripts: enableInlineScripts,
|
|
56
|
-
enableInlineStyles: enableInlineStyles,
|
|
57
|
-
polyfill: polyfill,
|
|
58
|
-
// We need to do this in the app-tools prepare hook because some files will be generated into the dist directory in the analyze process
|
|
59
|
-
cleanDistPath: false,
|
|
60
|
-
disableFilenameHash: disableAssetsCache,
|
|
61
|
-
enableLatestDecorators: enableLatestDecorators,
|
|
62
|
-
filename: {
|
|
63
|
-
css: cssModuleLocalIdentName
|
|
64
|
-
},
|
|
65
|
-
// `@modern-js/webpack` used to generate asset manifest by default
|
|
66
|
-
enableAssetManifest: true,
|
|
67
|
-
// compatible the modern-js with fallback behavior
|
|
68
|
-
enableAssetFallback: true
|
|
69
|
-
};
|
|
70
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
3
|
-
import { dirname, isAbsolute, posix, sep } from 'path';
|
|
4
|
-
import { globby, mergeAlias, findMonorepoRoot, isModernjsMonorepo } from '@modern-js/utils';
|
|
5
|
-
export function createSourceConfig(normalizedConfig, appContext) {
|
|
6
|
-
var _normalizedConfig$sou = normalizedConfig.source,
|
|
7
|
-
alias = _normalizedConfig$sou.alias,
|
|
8
|
-
envVars = _normalizedConfig$sou.envVars,
|
|
9
|
-
globalVars = _normalizedConfig$sou.globalVars,
|
|
10
|
-
include = _normalizedConfig$sou.include,
|
|
11
|
-
moduleScopes = _normalizedConfig$sou.moduleScopes,
|
|
12
|
-
preEntry = _normalizedConfig$sou.preEntry;
|
|
13
|
-
var builderGlobalVars = globalVars || {};
|
|
14
|
-
var _iterator = _createForOfIteratorHelper(envVars || []),
|
|
15
|
-
_step;
|
|
16
|
-
try {
|
|
17
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
18
|
-
var envVar = _step.value;
|
|
19
|
-
var envVarValue = process.env[envVar];
|
|
20
|
-
envVarValue && (builderGlobalVars["process.env.".concat(envVar)] = envVarValue);
|
|
21
|
-
}
|
|
22
|
-
} catch (err) {
|
|
23
|
-
_iterator.e(err);
|
|
24
|
-
} finally {
|
|
25
|
-
_iterator.f();
|
|
26
|
-
}
|
|
27
|
-
var builderModuleScope = createBuilderModuleScope(moduleScopes);
|
|
28
|
-
var builderInclude = createBuilderInclude(include, appContext);
|
|
29
|
-
return {
|
|
30
|
-
alias: mergeAlias(alias),
|
|
31
|
-
moduleScopes: builderModuleScope,
|
|
32
|
-
globalVars: builderGlobalVars,
|
|
33
|
-
include: builderInclude,
|
|
34
|
-
preEntry: preEntry,
|
|
35
|
-
// ensure resolve.extensions same as before
|
|
36
|
-
resolveExtensionPrefix: '.web'
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
export function createBuilderInclude(include, appContext) {
|
|
40
|
-
var defaultInclude = [appContext.internalDirectory];
|
|
41
|
-
var transformInclude = (include || []).map(function (include) {
|
|
42
|
-
if (typeof include === 'string') {
|
|
43
|
-
if (isAbsolute(include)) {
|
|
44
|
-
return include;
|
|
45
|
-
}
|
|
46
|
-
return new RegExp(include);
|
|
47
|
-
}
|
|
48
|
-
return include;
|
|
49
|
-
}).concat(defaultInclude); // concat default Include
|
|
50
|
-
|
|
51
|
-
var root = findMonorepoRoot(appContext.appDirectory);
|
|
52
|
-
if (!root) {
|
|
53
|
-
return transformInclude;
|
|
54
|
-
}
|
|
55
|
-
var modernjsMonorepo = isModernjsMonorepo(root);
|
|
56
|
-
if (modernjsMonorepo) {
|
|
57
|
-
var paths = globby.sync(posix.join(root, 'features', '**', 'package.json'), {
|
|
58
|
-
ignore: ['**/node_modules/**/*']
|
|
59
|
-
}).map(function (pathname) {
|
|
60
|
-
return dirname(pathname) + sep;
|
|
61
|
-
});
|
|
62
|
-
return [].concat(_toConsumableArray(paths), _toConsumableArray(transformInclude));
|
|
63
|
-
}
|
|
64
|
-
return transformInclude;
|
|
65
|
-
}
|
|
66
|
-
export function createBuilderModuleScope(moduleScopes) {
|
|
67
|
-
if (moduleScopes) {
|
|
68
|
-
var builderModuleScope = [];
|
|
69
|
-
var DEFAULT_SCOPES = ['./src', './shared', /node_modules/];
|
|
70
|
-
if (Array.isArray(moduleScopes)) {
|
|
71
|
-
if (isPrimitiveScope(moduleScopes)) {
|
|
72
|
-
builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
|
|
73
|
-
} else {
|
|
74
|
-
builderModuleScope = [DEFAULT_SCOPES].concat(_toConsumableArray(moduleScopes));
|
|
75
|
-
}
|
|
76
|
-
} else {
|
|
77
|
-
builderModuleScope = [DEFAULT_SCOPES, moduleScopes];
|
|
78
|
-
}
|
|
79
|
-
return builderModuleScope;
|
|
80
|
-
} else {
|
|
81
|
-
return undefined;
|
|
82
|
-
}
|
|
83
|
-
function isPrimitiveScope(items) {
|
|
84
|
-
return items.every(function (item) {
|
|
85
|
-
return typeof item === 'string' || Object.prototype.toString.call(item) === '[object RegExp]';
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
4
|
-
import { applyOptionsChain } from '@modern-js/utils';
|
|
5
|
-
export function createToolsConfig(normalizedConfig) {
|
|
6
|
-
var _normalizedConfig$out = normalizedConfig.output,
|
|
7
|
-
disableCssExtract = _normalizedConfig$out.disableCssExtract,
|
|
8
|
-
enableTsLoader = _normalizedConfig$out.enableTsLoader;
|
|
9
|
-
var _normalizedConfig$too = normalizedConfig.tools,
|
|
10
|
-
autoprefixer = _normalizedConfig$too.autoprefixer,
|
|
11
|
-
babel = _normalizedConfig$too.babel,
|
|
12
|
-
minifyCss = _normalizedConfig$too.minifyCss,
|
|
13
|
-
terser = _normalizedConfig$too.terser,
|
|
14
|
-
webpack = _normalizedConfig$too.webpack,
|
|
15
|
-
webpackChain = _normalizedConfig$too.webpackChain,
|
|
16
|
-
tsLoader = _normalizedConfig$too.tsLoader,
|
|
17
|
-
styledComponents = _normalizedConfig$too.styledComponents,
|
|
18
|
-
sass = _normalizedConfig$too.sass,
|
|
19
|
-
postcss = _normalizedConfig$too.postcss,
|
|
20
|
-
less = _normalizedConfig$too.less,
|
|
21
|
-
htmlPlugin = _normalizedConfig$too.htmlPlugin,
|
|
22
|
-
lodash = _normalizedConfig$too.lodash;
|
|
23
|
-
var builderTsLoader = createBuilderTsLoader(tsLoader, enableTsLoader);
|
|
24
|
-
var builderTsChecker = createBuilderTsChecker(normalizedConfig.output);
|
|
25
|
-
return {
|
|
26
|
-
tsChecker: builderTsChecker,
|
|
27
|
-
styleLoader: disableCssExtract ? {} : undefined,
|
|
28
|
-
cssExtract: disableCssExtract ? false : undefined,
|
|
29
|
-
autoprefixer: autoprefixer,
|
|
30
|
-
babel: babel,
|
|
31
|
-
minifyCss: minifyCss,
|
|
32
|
-
terser: terser,
|
|
33
|
-
webpack: webpack,
|
|
34
|
-
webpackChain: webpackChain,
|
|
35
|
-
tsLoader: builderTsLoader,
|
|
36
|
-
styledComponents: styledComponents,
|
|
37
|
-
sass: sass,
|
|
38
|
-
postcss: postcss,
|
|
39
|
-
less: less,
|
|
40
|
-
// can't remove comment in html minify.
|
|
41
|
-
// some html template insert by using those comments.
|
|
42
|
-
htmlPlugin: [function (config) {
|
|
43
|
-
return _objectSpread(_objectSpread({}, config), {}, {
|
|
44
|
-
minify: _typeof(config.minify) === 'object' ? _objectSpread(_objectSpread({}, config.minify), {}, {
|
|
45
|
-
removeComments: false
|
|
46
|
-
}) : config.minify
|
|
47
|
-
});
|
|
48
|
-
}].concat(_toConsumableArray(Array.isArray(htmlPlugin) ? htmlPlugin : htmlPlugin ? [htmlPlugin] : []))
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function createBuilderTsLoader(tsLoader, enableTsLoader) {
|
|
52
|
-
var useTsLoader = Boolean(enableTsLoader);
|
|
53
|
-
if (!useTsLoader) {
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
56
|
-
var defaultTsLoader = {
|
|
57
|
-
compilerOptions: {
|
|
58
|
-
target: 'es5',
|
|
59
|
-
module: 'ESNext'
|
|
60
|
-
},
|
|
61
|
-
transpileOnly: false,
|
|
62
|
-
allowTsInNodeModules: true
|
|
63
|
-
};
|
|
64
|
-
return function (_, utils) {
|
|
65
|
-
return applyOptionsChain(defaultTsLoader, tsLoader, utils);
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export function createBuilderTsChecker(output) {
|
|
69
|
-
if (output.enableTsLoader) {
|
|
70
|
-
return false;
|
|
71
|
-
}
|
|
72
|
-
var defaultTsChecker = {
|
|
73
|
-
issue: {
|
|
74
|
-
include: [{
|
|
75
|
-
file: '**/src/**/*'
|
|
76
|
-
}],
|
|
77
|
-
exclude: [{
|
|
78
|
-
file: '**/*.(spec|test).ts'
|
|
79
|
-
}, {
|
|
80
|
-
file: '**/node_modules/**/*'
|
|
81
|
-
}]
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
return defaultTsChecker;
|
|
85
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
-
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
-
export declare function createHtmlConfig(normalizedConfig: NormalizedConfig, appContext: IAppContext): BuilderConfig['html'];
|
|
4
|
-
export declare function createBuilderAppIcon(configDir: NormalizedConfig['source']['configDir'], appContext: IAppContext): string | undefined;
|
|
5
|
-
export declare function createBuilderCrossorigin(scriptExt: NormalizedConfig['output']['scriptExt']): "anonymous" | "use-credentials" | undefined;
|
|
6
|
-
export declare function createBuilderFavicon(favicon: NormalizedConfig['output']['favicon'], configDir: NormalizedConfig['source']['configDir'], appContext: IAppContext): string | undefined;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
-
import type { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
-
export declare function createOutputConfig(normalizedConfig: NormalizedConfig, appContext: IAppContext): BuilderConfig['output'];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
-
import { IAppContext, NormalizedConfig } from '@modern-js/core';
|
|
3
|
-
export declare function createSourceConfig(normalizedConfig: NormalizedConfig, appContext: IAppContext): BuilderConfig['source'];
|
|
4
|
-
export declare function createBuilderInclude(include: NormalizedConfig['source']['include'], appContext: IAppContext): (string | RegExp)[];
|
|
5
|
-
export declare function createBuilderModuleScope(moduleScopes: NormalizedConfig['source']['moduleScopes']): any[] | undefined;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
-
import type { NormalizedConfig } from '@modern-js/core';
|
|
3
|
-
export declare function createToolsConfig(normalizedConfig: NormalizedConfig): BuilderConfig['tools'];
|
|
4
|
-
export declare function createBuilderTsChecker(output: NormalizedConfig['output']): false | {
|
|
5
|
-
issue: {
|
|
6
|
-
include: {
|
|
7
|
-
file: string;
|
|
8
|
-
}[];
|
|
9
|
-
exclude: {
|
|
10
|
-
file: string;
|
|
11
|
-
}[];
|
|
12
|
-
};
|
|
13
|
-
};
|