@modern-js/app-tools 2.0.0-beta.0 → 2.0.0-beta.2
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 +375 -0
- package/dist/js/modern/analyze/generateCode.js +30 -38
- package/dist/js/modern/analyze/getBundleEntry.js +5 -13
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +5 -30
- package/dist/js/modern/analyze/getClientRoutes/getRoutesLegacy.js +5 -30
- package/dist/js/modern/analyze/getClientRoutes/utils.js +0 -3
- package/dist/js/modern/analyze/getFileSystemEntry.js +5 -18
- package/dist/js/modern/analyze/getHtmlTemplate.js +3 -10
- package/dist/js/modern/analyze/getServerRoutes.js +25 -38
- package/dist/js/modern/analyze/index.js +90 -48
- package/dist/js/modern/analyze/isDefaultExportFunction.js +0 -4
- package/dist/js/modern/analyze/makeLegalIdentifier.js +0 -2
- package/dist/js/modern/analyze/nestedRoutes.js +8 -33
- package/dist/js/modern/analyze/templates.js +22 -37
- package/dist/js/modern/analyze/utils.js +0 -7
- package/dist/js/modern/builder/builderPlugins/compatModern.js +41 -58
- package/dist/js/modern/builder/index.js +56 -37
- package/dist/js/modern/builder/share.js +1 -5
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -8
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +2 -13
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
- package/dist/js/modern/commands/build.js +12 -46
- package/dist/js/modern/commands/dev.js +20 -23
- package/dist/js/modern/commands/inspect.js +4 -19
- package/dist/js/modern/commands/start.js +1 -2
- package/dist/js/modern/config/default.js +207 -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 +19 -18
- 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 +12 -19
- 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 +2 -13
- package/dist/js/modern/utils/createFileWatcher.js +82 -0
- package/dist/js/modern/utils/createServer.js +0 -5
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
- package/dist/js/modern/utils/printInstructions.js +2 -1
- package/dist/js/modern/utils/restart.js +17 -0
- package/dist/js/modern/utils/routes.js +0 -2
- package/dist/js/node/analyze/generateCode.js +30 -61
- package/dist/js/node/analyze/getBundleEntry.js +5 -19
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +5 -45
- package/dist/js/node/analyze/getClientRoutes/getRoutesLegacy.js +5 -45
- package/dist/js/node/analyze/getClientRoutes/index.js +0 -2
- package/dist/js/node/analyze/getClientRoutes/utils.js +0 -14
- package/dist/js/node/analyze/getFileSystemEntry.js +5 -26
- package/dist/js/node/analyze/getHtmlTemplate.js +3 -24
- package/dist/js/node/analyze/getServerRoutes.js +24 -46
- package/dist/js/node/analyze/index.js +91 -70
- package/dist/js/node/analyze/isDefaultExportFunction.js +0 -12
- package/dist/js/node/analyze/makeLegalIdentifier.js +0 -4
- package/dist/js/node/analyze/nestedRoutes.js +8 -41
- package/dist/js/node/analyze/templates.js +22 -47
- package/dist/js/node/analyze/utils.js +0 -20
- package/dist/js/node/builder/builderPlugins/compatModern.js +41 -69
- package/dist/js/node/builder/index.js +57 -51
- package/dist/js/node/builder/share.js +1 -13
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +0 -10
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +2 -15
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
- package/dist/js/node/commands/build.js +10 -57
- package/dist/js/node/commands/deploy.js +0 -2
- package/dist/js/node/commands/dev.js +19 -34
- package/dist/js/node/commands/index.js +0 -6
- package/dist/js/node/commands/inspect.js +4 -26
- package/dist/js/node/commands/start.js +1 -11
- package/dist/js/node/config/default.js +214 -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 +19 -20
- 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/exports/server.js +0 -1
- package/dist/js/node/hooks.js +23 -30
- package/dist/js/node/index.js +35 -48
- package/dist/js/node/initialize/index.js +79 -0
- package/dist/js/node/locale/index.js +0 -4
- 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/commands.js +0 -2
- package/dist/js/node/utils/config.js +2 -26
- package/dist/js/node/utils/createFileWatcher.js +90 -0
- package/dist/js/node/utils/createServer.js +0 -15
- package/dist/js/node/utils/getSpecifiedEntries.js +0 -9
- package/dist/js/node/utils/language.js +0 -2
- package/dist/js/node/utils/printInstructions.js +2 -5
- package/dist/js/node/utils/restart.js +23 -0
- package/dist/js/node/utils/routes.js +0 -5
- package/dist/js/treeshaking/analyze/generateCode.js +58 -101
- package/dist/js/treeshaking/analyze/getBundleEntry.js +12 -20
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +16 -42
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +16 -42
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +0 -3
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +5 -18
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +3 -27
- package/dist/js/treeshaking/analyze/getServerRoutes.js +29 -41
- package/dist/js/treeshaking/analyze/index.js +195 -91
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +0 -4
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +0 -2
- package/dist/js/treeshaking/analyze/nestedRoutes.js +9 -51
- package/dist/js/treeshaking/analyze/templates.js +31 -50
- package/dist/js/treeshaking/analyze/utils.js +7 -14
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +50 -68
- package/dist/js/treeshaking/builder/index.js +69 -65
- package/dist/js/treeshaking/builder/share.js +1 -5
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +1 -13
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +2 -14
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
- package/dist/js/treeshaking/commands/build.js +41 -116
- package/dist/js/treeshaking/commands/deploy.js +0 -3
- package/dist/js/treeshaking/commands/dev.js +38 -46
- package/dist/js/treeshaking/commands/inspect.js +9 -27
- package/dist/js/treeshaking/commands/start.js +1 -9
- package/dist/js/treeshaking/config/default.js +200 -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 +67 -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 +8 -43
- 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 +2 -18
- package/dist/js/treeshaking/utils/createFileWatcher.js +123 -0
- package/dist/js/treeshaking/utils/createServer.js +0 -10
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +0 -10
- package/dist/js/treeshaking/utils/printInstructions.js +0 -5
- package/dist/js/treeshaking/utils/restart.js +45 -0
- package/dist/js/treeshaking/utils/routes.js +0 -4
- 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 -42
- package/dist/types/analyze/nestedRoutes.d.ts +1 -1
- package/dist/types/analyze/templates.d.ts +4 -2
- package/dist/types/analyze/utils.d.ts +1 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +2 -3
- package/dist/types/builder/index.d.ts +7 -8
- package/dist/types/builder/share.d.ts +2 -2
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
- 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 +6 -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 -7
- 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 +15 -0
- package/dist/types/types/hooks.d.ts +80 -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 -3
- package/dist/types/utils/createFileWatcher.d.ts +3 -0
- package/dist/types/utils/printInstructions.d.ts +3 -3
- package/dist/types/utils/restart.d.ts +3 -0
- package/package.json +26 -25
- package/dist/js/modern/builder/createHtmlConfig.js +0 -58
- package/dist/js/modern/builder/createSourceConfig.js +0 -85
- package/dist/js/modern/builder/createToolsConfig.js +0 -94
- package/dist/js/modern/utils/createCompiler.js +0 -58
- package/dist/js/node/builder/createHtmlConfig.js +0 -76
- package/dist/js/node/builder/createSourceConfig.js +0 -99
- package/dist/js/node/builder/createToolsConfig.js +0 -103
- package/dist/js/node/utils/createCompiler.js +0 -75
- package/dist/js/treeshaking/builder/createHtmlConfig.js +0 -59
- package/dist/js/treeshaking/builder/createOutputConfig.js +0 -67
- package/dist/js/treeshaking/builder/createSourceConfig.js +0 -100
- package/dist/js/treeshaking/builder/createToolsConfig.js +0 -90
- package/dist/js/treeshaking/utils/createCompiler.js +0 -117
- 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
- package/dist/types/utils/createCompiler.d.ts +0 -12
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
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; }
|
|
2
|
-
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
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; }
|
|
6
|
-
|
|
7
4
|
import { ResolvedConfigContext } from '@modern-js/core';
|
|
8
|
-
import { logger,
|
|
5
|
+
import { logger, printBuildError } from '@modern-js/utils';
|
|
9
6
|
import { generateRoutes } from "../utils/routes";
|
|
10
|
-
import { buildServerConfig
|
|
11
|
-
import createBuilder from "../builder";
|
|
7
|
+
import { buildServerConfig } from "../utils/config";
|
|
12
8
|
export const build = async (api, options) => {
|
|
9
|
+
if (options !== null && options !== void 0 && options.analyze) {
|
|
10
|
+
// Builder will read this env var to enable bundle analyzer
|
|
11
|
+
process.env.BUNDLE_ANALYZE = 'true';
|
|
12
|
+
}
|
|
13
13
|
let resolvedConfig = api.useResolvedConfigContext();
|
|
14
14
|
const appContext = api.useAppContext();
|
|
15
15
|
const hookRunners = api.useHookRunners();
|
|
16
16
|
const {
|
|
17
17
|
apiOnly
|
|
18
18
|
} = appContext;
|
|
19
|
-
|
|
20
19
|
if (apiOnly) {
|
|
21
20
|
const {
|
|
22
21
|
appDirectory,
|
|
@@ -39,7 +38,6 @@ export const build = async (api, options) => {
|
|
|
39
38
|
});
|
|
40
39
|
return;
|
|
41
40
|
}
|
|
42
|
-
|
|
43
41
|
resolvedConfig = _objectSpread(_objectSpread({}, resolvedConfig), {}, {
|
|
44
42
|
cliOptions: options
|
|
45
43
|
});
|
|
@@ -54,47 +52,15 @@ export const build = async (api, options) => {
|
|
|
54
52
|
distDirectory,
|
|
55
53
|
configFile: serverConfigFile
|
|
56
54
|
});
|
|
57
|
-
const targets = ['web'];
|
|
58
|
-
|
|
59
|
-
if (resolvedConfig.output.enableModernMode) {
|
|
60
|
-
targets.push('modern-web');
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (isUseSSRBundle(resolvedConfig)) {
|
|
64
|
-
targets.push('node');
|
|
65
|
-
}
|
|
66
|
-
|
|
67
55
|
try {
|
|
68
|
-
const builder = await createBuilder({
|
|
69
|
-
target: targets,
|
|
70
|
-
appContext,
|
|
71
|
-
normalizedConfig: resolvedConfig,
|
|
72
|
-
compatPluginConfig: {
|
|
73
|
-
async onBeforeBuild({
|
|
74
|
-
bundlerConfigs
|
|
75
|
-
}) {
|
|
76
|
-
await generateRoutes(appContext);
|
|
77
|
-
await hookRunners.beforeBuild({
|
|
78
|
-
bundlerConfigs
|
|
79
|
-
});
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
async onAfterBuild({
|
|
83
|
-
stats
|
|
84
|
-
}) {
|
|
85
|
-
await hookRunners.afterBuild({
|
|
86
|
-
stats
|
|
87
|
-
});
|
|
88
|
-
await emitResolvedConfig(appDirectory, resolvedConfig);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
56
|
logger.info('Create a production build...\n');
|
|
94
|
-
|
|
57
|
+
if (!appContext.builder) {
|
|
58
|
+
throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
59
|
+
}
|
|
60
|
+
await appContext.builder.build();
|
|
95
61
|
} catch (error) {
|
|
96
|
-
printBuildError(error);
|
|
97
|
-
|
|
62
|
+
printBuildError(error);
|
|
63
|
+
// eslint-disable-next-line no-process-exit
|
|
98
64
|
process.exit(1);
|
|
99
65
|
}
|
|
100
66
|
};
|
|
@@ -1,25 +1,27 @@
|
|
|
1
1
|
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; }
|
|
2
|
-
|
|
3
2
|
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; }
|
|
4
|
-
|
|
5
3
|
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; }
|
|
6
|
-
|
|
7
|
-
import { logger, isSSR } from '@modern-js/utils';
|
|
4
|
+
import { logger } from '@modern-js/utils';
|
|
8
5
|
import { ResolvedConfigContext } from '@modern-js/core';
|
|
6
|
+
import { createFileWatcher } from "../utils/createFileWatcher";
|
|
9
7
|
import { printInstructions } from "../utils/printInstructions";
|
|
10
|
-
import { createDevCompiler } from "../utils/createCompiler";
|
|
11
8
|
import { createServer, injectDataLoaderPlugin } from "../utils/createServer";
|
|
12
9
|
import { generateRoutes } from "../utils/routes";
|
|
13
10
|
import { getSpecifiedEntries } from "../utils/getSpecifiedEntries";
|
|
14
11
|
import { buildServerConfig } from "../utils/config";
|
|
15
12
|
export const dev = async (api, options) => {
|
|
16
|
-
|
|
13
|
+
var _normalizedConfig$too;
|
|
14
|
+
if (options.analyze) {
|
|
15
|
+
// Builder will read this env var to enable bundle analyzer
|
|
16
|
+
process.env.BUNDLE_ANALYZE = 'true';
|
|
17
|
+
}
|
|
18
|
+
let normalizedConfig = api.useResolvedConfigContext();
|
|
17
19
|
const appContext = api.useAppContext();
|
|
18
20
|
const hookRunners = api.useHookRunners();
|
|
19
|
-
|
|
21
|
+
normalizedConfig = _objectSpread(_objectSpread({}, normalizedConfig), {}, {
|
|
20
22
|
cliOptions: options
|
|
21
23
|
});
|
|
22
|
-
ResolvedConfigContext.set(
|
|
24
|
+
ResolvedConfigContext.set(normalizedConfig);
|
|
23
25
|
const {
|
|
24
26
|
appDirectory,
|
|
25
27
|
distDirectory,
|
|
@@ -46,17 +48,12 @@ export const dev = async (api, options) => {
|
|
|
46
48
|
});
|
|
47
49
|
await hookRunners.beforeDev();
|
|
48
50
|
let compiler = null;
|
|
49
|
-
|
|
50
51
|
if (!apiOnly) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
normalizedConfig: userConfig,
|
|
56
|
-
appContext
|
|
57
|
-
});
|
|
52
|
+
if (!appContext.builder) {
|
|
53
|
+
throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
54
|
+
}
|
|
55
|
+
compiler = await appContext.builder.createCompiler();
|
|
58
56
|
}
|
|
59
|
-
|
|
60
57
|
await generateRoutes(appContext);
|
|
61
58
|
const app = await createServer({
|
|
62
59
|
dev: _objectSpread(_objectSpread({}, {
|
|
@@ -69,11 +66,11 @@ export const dev = async (api, options) => {
|
|
|
69
66
|
hot: true,
|
|
70
67
|
liveReload: true,
|
|
71
68
|
port,
|
|
72
|
-
https:
|
|
73
|
-
}),
|
|
69
|
+
https: normalizedConfig.dev.https
|
|
70
|
+
}), (_normalizedConfig$too = normalizedConfig.tools) === null || _normalizedConfig$too === void 0 ? void 0 : _normalizedConfig$too.devServer),
|
|
74
71
|
compiler,
|
|
75
72
|
pwd: appDirectory,
|
|
76
|
-
config:
|
|
73
|
+
config: normalizedConfig,
|
|
77
74
|
serverConfigFile,
|
|
78
75
|
internalPlugins: injectDataLoaderPlugin(serverInternalPlugins)
|
|
79
76
|
});
|
|
@@ -81,11 +78,11 @@ export const dev = async (api, options) => {
|
|
|
81
78
|
if (err) {
|
|
82
79
|
throw err;
|
|
83
80
|
}
|
|
84
|
-
|
|
85
81
|
if (!apiOnly) {
|
|
86
|
-
logger.info(`Starting dev server
|
|
82
|
+
logger.info(`Starting dev server...\n`);
|
|
87
83
|
} else {
|
|
88
|
-
printInstructions(hookRunners, appContext,
|
|
84
|
+
printInstructions(hookRunners, appContext, normalizedConfig);
|
|
89
85
|
}
|
|
90
86
|
});
|
|
87
|
+
await createFileWatcher(appContext, normalizedConfig.source.configDir, hookRunners);
|
|
91
88
|
};
|
|
@@ -1,28 +1,13 @@
|
|
|
1
1
|
import { join } from 'path';
|
|
2
|
-
import { isUseSSRBundle } from '@modern-js/utils';
|
|
3
|
-
import createBuilder from "../builder";
|
|
4
2
|
export const inspect = async (api, options) => {
|
|
5
|
-
const resolvedConfig = api.useResolvedConfigContext();
|
|
6
3
|
const appContext = api.useAppContext();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (resolvedConfig.output.enableModernMode) {
|
|
10
|
-
targets.push('modern-web');
|
|
4
|
+
if (!appContext.builder) {
|
|
5
|
+
throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
11
6
|
}
|
|
12
|
-
|
|
13
|
-
if (isUseSSRBundle(resolvedConfig)) {
|
|
14
|
-
targets.push('node');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const builder = await createBuilder({
|
|
18
|
-
target: targets,
|
|
19
|
-
appContext,
|
|
20
|
-
normalizedConfig: resolvedConfig
|
|
21
|
-
});
|
|
22
|
-
return builder.inspectConfig({
|
|
7
|
+
return appContext.builder.inspectConfig({
|
|
23
8
|
env: options.env,
|
|
24
9
|
verbose: options.verbose,
|
|
25
|
-
outputPath: join(builder.context.distPath, options.output),
|
|
10
|
+
outputPath: join(appContext === null || appContext === void 0 ? void 0 : appContext.builder.context.distPath, options.output),
|
|
26
11
|
writeToDisk: true
|
|
27
12
|
});
|
|
28
13
|
};
|
|
@@ -4,7 +4,6 @@ import { printInstructions } from "../utils/printInstructions";
|
|
|
4
4
|
import { injectDataLoaderPlugin } from "../utils/createServer";
|
|
5
5
|
export const start = async api => {
|
|
6
6
|
var _userConfig$source;
|
|
7
|
-
|
|
8
7
|
const appContext = api.useAppContext();
|
|
9
8
|
const userConfig = api.useResolvedConfigContext();
|
|
10
9
|
const hookRunners = api.useHookRunners();
|
|
@@ -17,6 +16,7 @@ export const start = async api => {
|
|
|
17
16
|
const apiOnly = await isApiOnly(appContext.appDirectory, userConfig === null || userConfig === void 0 ? void 0 : (_userConfig$source = userConfig.source) === null || _userConfig$source === void 0 ? void 0 : _userConfig$source.entriesDir);
|
|
18
17
|
const app = await server({
|
|
19
18
|
pwd: appDirectory,
|
|
19
|
+
// FIXME: remove the `any` type
|
|
20
20
|
config: userConfig,
|
|
21
21
|
serverConfigFile,
|
|
22
22
|
internalPlugins: injectDataLoaderPlugin(appContext.serverInternalPlugins),
|
|
@@ -26,7 +26,6 @@ export const start = async api => {
|
|
|
26
26
|
if (err) {
|
|
27
27
|
throw err;
|
|
28
28
|
}
|
|
29
|
-
|
|
30
29
|
await printInstructions(hookRunners, appContext, userConfig);
|
|
31
30
|
});
|
|
32
31
|
};
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
export function createDefaultConfig(appContext) {
|
|
2
|
+
const defaultAlias = appContext ? {
|
|
3
|
+
[appContext.internalDirAlias]: appContext.internalDirectory,
|
|
4
|
+
[appContext.internalSrcAlias]: appContext.srcDirectory,
|
|
5
|
+
'@': appContext.srcDirectory,
|
|
6
|
+
'@shared': appContext.sharedDirectory
|
|
7
|
+
} : {};
|
|
8
|
+
const source = {
|
|
9
|
+
entries: undefined,
|
|
10
|
+
enableAsyncEntry: false,
|
|
11
|
+
disableDefaultEntries: false,
|
|
12
|
+
entriesDir: './src',
|
|
13
|
+
configDir: './config',
|
|
14
|
+
globalVars: undefined,
|
|
15
|
+
moduleScopes: undefined,
|
|
16
|
+
include: [],
|
|
17
|
+
alias: defaultAlias
|
|
18
|
+
};
|
|
19
|
+
const output = {
|
|
20
|
+
assetPrefix: '/',
|
|
21
|
+
distPath: {
|
|
22
|
+
html: 'html',
|
|
23
|
+
js: 'static/js',
|
|
24
|
+
css: 'static/css',
|
|
25
|
+
media: 'static/media',
|
|
26
|
+
root: 'dist'
|
|
27
|
+
},
|
|
28
|
+
copy: undefined,
|
|
29
|
+
disableCssModuleExtension: false,
|
|
30
|
+
enableCssModuleTSDeclaration: false,
|
|
31
|
+
disableMinimize: false,
|
|
32
|
+
enableInlineStyles: false,
|
|
33
|
+
enableInlineScripts: false,
|
|
34
|
+
disableSourceMap: false,
|
|
35
|
+
disableInlineRuntimeChunk: false,
|
|
36
|
+
disableFilenameHash: false,
|
|
37
|
+
enableLatestDecorators: false,
|
|
38
|
+
polyfill: 'entry',
|
|
39
|
+
dataUriLimit: 10000,
|
|
40
|
+
cssModuleLocalIdentName: undefined
|
|
41
|
+
};
|
|
42
|
+
const html = {
|
|
43
|
+
title: '',
|
|
44
|
+
titleByEntries: undefined,
|
|
45
|
+
meta: {
|
|
46
|
+
charset: {
|
|
47
|
+
charset: 'utf-8'
|
|
48
|
+
},
|
|
49
|
+
viewport: 'width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
|
|
50
|
+
'http-equiv': {
|
|
51
|
+
'http-equiv': 'x-ua-compatible',
|
|
52
|
+
content: 'ie=edge'
|
|
53
|
+
},
|
|
54
|
+
renderer: 'webkit',
|
|
55
|
+
layoutmode: 'standard',
|
|
56
|
+
imagemode: 'force',
|
|
57
|
+
'wap-font-scale': 'no',
|
|
58
|
+
'format-detection': 'telephone=no'
|
|
59
|
+
},
|
|
60
|
+
metaByEntries: undefined,
|
|
61
|
+
inject: 'head',
|
|
62
|
+
injectByEntries: undefined,
|
|
63
|
+
mountId: 'root',
|
|
64
|
+
favicon: '',
|
|
65
|
+
faviconByEntries: undefined,
|
|
66
|
+
disableHtmlFolder: false,
|
|
67
|
+
templateParameters: {},
|
|
68
|
+
templateParametersByEntries: undefined
|
|
69
|
+
};
|
|
70
|
+
const server = {
|
|
71
|
+
routes: undefined,
|
|
72
|
+
publicRoutes: undefined,
|
|
73
|
+
ssr: undefined,
|
|
74
|
+
ssrByEntries: undefined,
|
|
75
|
+
baseUrl: '/',
|
|
76
|
+
port: 8080
|
|
77
|
+
};
|
|
78
|
+
const dev = {
|
|
79
|
+
assetPrefix: false,
|
|
80
|
+
https: false
|
|
81
|
+
};
|
|
82
|
+
const tools = {
|
|
83
|
+
webpack: undefined,
|
|
84
|
+
babel: undefined,
|
|
85
|
+
postcss: undefined,
|
|
86
|
+
autoprefixer: undefined,
|
|
87
|
+
devServer: undefined,
|
|
88
|
+
tsLoader: undefined,
|
|
89
|
+
terser: undefined,
|
|
90
|
+
minifyCss: undefined
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
source,
|
|
94
|
+
output,
|
|
95
|
+
server,
|
|
96
|
+
dev,
|
|
97
|
+
html,
|
|
98
|
+
tools,
|
|
99
|
+
plugins: [],
|
|
100
|
+
runtime: {},
|
|
101
|
+
runtimeByEntries: {}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
export function createLegacyDefaultConfig(appContext) {
|
|
105
|
+
const defaultAlias = appContext ? {
|
|
106
|
+
[appContext.internalDirAlias]: appContext.internalDirectory,
|
|
107
|
+
[appContext.internalSrcAlias]: appContext.srcDirectory,
|
|
108
|
+
'@': appContext.srcDirectory,
|
|
109
|
+
'@shared': appContext.sharedDirectory
|
|
110
|
+
} : {};
|
|
111
|
+
const sourceDefaults = {
|
|
112
|
+
entries: undefined,
|
|
113
|
+
enableAsyncEntry: false,
|
|
114
|
+
disableDefaultEntries: false,
|
|
115
|
+
entriesDir: './src',
|
|
116
|
+
configDir: './config',
|
|
117
|
+
apiDir: './api',
|
|
118
|
+
envVars: [],
|
|
119
|
+
globalVars: undefined,
|
|
120
|
+
alias: defaultAlias,
|
|
121
|
+
moduleScopes: undefined,
|
|
122
|
+
include: []
|
|
123
|
+
};
|
|
124
|
+
const outputDefaults = {
|
|
125
|
+
assetPrefix: '/',
|
|
126
|
+
htmlPath: 'html',
|
|
127
|
+
jsPath: 'static/js',
|
|
128
|
+
cssPath: 'static/css',
|
|
129
|
+
mediaPath: 'static/media',
|
|
130
|
+
path: 'dist',
|
|
131
|
+
title: '',
|
|
132
|
+
titleByEntries: undefined,
|
|
133
|
+
meta: {
|
|
134
|
+
charset: {
|
|
135
|
+
charset: 'utf-8'
|
|
136
|
+
},
|
|
137
|
+
viewport: 'width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
|
|
138
|
+
'http-equiv': {
|
|
139
|
+
'http-equiv': 'x-ua-compatible',
|
|
140
|
+
content: 'ie=edge'
|
|
141
|
+
},
|
|
142
|
+
renderer: 'webkit',
|
|
143
|
+
layoutmode: 'standard',
|
|
144
|
+
imagemode: 'force',
|
|
145
|
+
'wap-font-scale': 'no',
|
|
146
|
+
'format-detection': 'telephone=no'
|
|
147
|
+
},
|
|
148
|
+
metaByEntries: undefined,
|
|
149
|
+
inject: 'head',
|
|
150
|
+
injectByEntries: undefined,
|
|
151
|
+
mountId: 'root',
|
|
152
|
+
favicon: '',
|
|
153
|
+
faviconByEntries: undefined,
|
|
154
|
+
copy: undefined,
|
|
155
|
+
disableHtmlFolder: false,
|
|
156
|
+
disableCssModuleExtension: false,
|
|
157
|
+
disableCssExtract: false,
|
|
158
|
+
enableCssModuleTSDeclaration: false,
|
|
159
|
+
disableMinimize: false,
|
|
160
|
+
enableInlineStyles: false,
|
|
161
|
+
enableInlineScripts: false,
|
|
162
|
+
disableSourceMap: false,
|
|
163
|
+
disableInlineRuntimeChunk: false,
|
|
164
|
+
disableAssetsCache: false,
|
|
165
|
+
enableLatestDecorators: false,
|
|
166
|
+
polyfill: 'entry',
|
|
167
|
+
dataUriLimit: 10000,
|
|
168
|
+
templateParameters: {},
|
|
169
|
+
templateParametersByEntries: undefined,
|
|
170
|
+
cssModuleLocalIdentName: undefined,
|
|
171
|
+
enableModernMode: false,
|
|
172
|
+
disableNodePolyfill: false,
|
|
173
|
+
enableTsLoader: false
|
|
174
|
+
};
|
|
175
|
+
const serverDefaults = {
|
|
176
|
+
routes: undefined,
|
|
177
|
+
publicRoutes: undefined,
|
|
178
|
+
ssr: undefined,
|
|
179
|
+
ssrByEntries: undefined,
|
|
180
|
+
baseUrl: '/',
|
|
181
|
+
port: 8080
|
|
182
|
+
};
|
|
183
|
+
const devDefaults = {
|
|
184
|
+
assetPrefix: false,
|
|
185
|
+
https: false
|
|
186
|
+
};
|
|
187
|
+
const toolsDefaults = {
|
|
188
|
+
webpack: undefined,
|
|
189
|
+
babel: undefined,
|
|
190
|
+
postcss: undefined,
|
|
191
|
+
autoprefixer: undefined,
|
|
192
|
+
lodash: undefined,
|
|
193
|
+
devServer: undefined,
|
|
194
|
+
tsLoader: undefined,
|
|
195
|
+
terser: undefined,
|
|
196
|
+
minifyCss: undefined
|
|
197
|
+
};
|
|
198
|
+
return {
|
|
199
|
+
source: sourceDefaults,
|
|
200
|
+
output: outputDefaults,
|
|
201
|
+
server: serverDefaults,
|
|
202
|
+
dev: devDefaults,
|
|
203
|
+
tools: toolsDefaults,
|
|
204
|
+
runtime: {},
|
|
205
|
+
runtimeByEntries: {}
|
|
206
|
+
};
|
|
207
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function createHtmlConfig(config) {
|
|
2
|
+
const {
|
|
3
|
+
disableHtmlFolder,
|
|
4
|
+
favicon,
|
|
5
|
+
faviconByEntries,
|
|
6
|
+
inject,
|
|
7
|
+
injectByEntries,
|
|
8
|
+
meta,
|
|
9
|
+
metaByEntries,
|
|
10
|
+
mountId,
|
|
11
|
+
title,
|
|
12
|
+
titleByEntries,
|
|
13
|
+
templateParameters,
|
|
14
|
+
templateParametersByEntries,
|
|
15
|
+
crossorigin
|
|
16
|
+
} = config.output;
|
|
17
|
+
return {
|
|
18
|
+
disableHtmlFolder,
|
|
19
|
+
favicon,
|
|
20
|
+
faviconByEntries,
|
|
21
|
+
inject,
|
|
22
|
+
injectByEntries,
|
|
23
|
+
meta,
|
|
24
|
+
metaByEntries,
|
|
25
|
+
mountId,
|
|
26
|
+
title,
|
|
27
|
+
titleByEntries,
|
|
28
|
+
crossorigin,
|
|
29
|
+
templateParameters,
|
|
30
|
+
templateParametersByEntries
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
export function createOutputConfig(normalizedConfig, appContext) {
|
|
3
|
-
// TODO: add `externals` options in Modern.
|
|
1
|
+
export function createOutputConfig(config) {
|
|
4
2
|
const {
|
|
5
3
|
assetPrefix,
|
|
6
4
|
copy,
|
|
@@ -9,10 +7,13 @@ export function createOutputConfig(normalizedConfig, appContext) {
|
|
|
9
7
|
jsPath,
|
|
10
8
|
htmlPath,
|
|
11
9
|
mediaPath,
|
|
10
|
+
enableTsLoader,
|
|
12
11
|
path,
|
|
13
12
|
disableInlineRuntimeChunk,
|
|
13
|
+
disableCssExtract,
|
|
14
14
|
disableMinimize,
|
|
15
15
|
disableSourceMap,
|
|
16
|
+
disableTsChecker,
|
|
16
17
|
enableCssModuleTSDeclaration,
|
|
17
18
|
enableInlineScripts,
|
|
18
19
|
enableInlineStyles,
|
|
@@ -20,23 +21,24 @@ export function createOutputConfig(normalizedConfig, appContext) {
|
|
|
20
21
|
dataUriLimit,
|
|
21
22
|
disableAssetsCache,
|
|
22
23
|
enableLatestDecorators,
|
|
23
|
-
disableCssModuleExtension
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
disableCssModuleExtension,
|
|
25
|
+
ssg,
|
|
26
|
+
enableModernMode,
|
|
27
|
+
disableNodePolyfill
|
|
28
|
+
} = config.output;
|
|
27
29
|
return {
|
|
28
30
|
assetPrefix,
|
|
29
|
-
copy
|
|
31
|
+
copy,
|
|
30
32
|
distPath: {
|
|
31
33
|
root: path,
|
|
32
34
|
css: cssPath,
|
|
33
35
|
js: jsPath,
|
|
34
36
|
html: htmlPath,
|
|
35
37
|
// `@modern-js/webpack` output all media files to `dist/media` by default
|
|
36
|
-
svg: mediaPath || '
|
|
37
|
-
image: mediaPath || '
|
|
38
|
-
font: mediaPath || '
|
|
39
|
-
media: mediaPath || '
|
|
38
|
+
svg: mediaPath || 'media',
|
|
39
|
+
image: mediaPath || 'media',
|
|
40
|
+
font: mediaPath || 'media',
|
|
41
|
+
media: mediaPath || 'media'
|
|
40
42
|
},
|
|
41
43
|
dataUriLimit: {
|
|
42
44
|
svg: dataUriLimit,
|
|
@@ -44,24 +46,23 @@ export function createOutputConfig(normalizedConfig, appContext) {
|
|
|
44
46
|
font: dataUriLimit,
|
|
45
47
|
media: dataUriLimit
|
|
46
48
|
},
|
|
49
|
+
disableCssExtract,
|
|
47
50
|
disableCssModuleExtension,
|
|
48
51
|
disableInlineRuntimeChunk,
|
|
49
52
|
disableMinimize,
|
|
50
53
|
disableSourceMap,
|
|
54
|
+
disableTsChecker: disableTsChecker || enableTsLoader,
|
|
51
55
|
enableCssModuleTSDeclaration,
|
|
52
56
|
enableInlineScripts,
|
|
53
57
|
enableInlineStyles,
|
|
54
58
|
polyfill,
|
|
55
|
-
// 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
|
|
56
|
-
cleanDistPath: false,
|
|
57
59
|
disableFilenameHash: disableAssetsCache,
|
|
58
60
|
enableLatestDecorators,
|
|
59
61
|
filename: {
|
|
60
62
|
css: cssModuleLocalIdentName
|
|
61
63
|
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
enableAssetFallback: true
|
|
64
|
+
ssg,
|
|
65
|
+
enableModernMode,
|
|
66
|
+
disableNodePolyfill
|
|
66
67
|
};
|
|
67
68
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function createSourceConfig(config) {
|
|
2
|
+
const {
|
|
3
|
+
alias,
|
|
4
|
+
envVars,
|
|
5
|
+
globalVars,
|
|
6
|
+
include,
|
|
7
|
+
moduleScopes,
|
|
8
|
+
preEntry,
|
|
9
|
+
entries,
|
|
10
|
+
enableAsyncEntry,
|
|
11
|
+
disableDefaultEntries,
|
|
12
|
+
entriesDir,
|
|
13
|
+
configDir
|
|
14
|
+
} = config.source;
|
|
15
|
+
const builderGlobalVars = globalVars || {};
|
|
16
|
+
for (const envVar of envVars || []) {
|
|
17
|
+
const envVarValue = process.env[envVar];
|
|
18
|
+
envVarValue && (builderGlobalVars[`process.env.${envVar}`] = envVarValue);
|
|
19
|
+
}
|
|
20
|
+
return {
|
|
21
|
+
alias,
|
|
22
|
+
moduleScopes,
|
|
23
|
+
globalVars: builderGlobalVars,
|
|
24
|
+
include,
|
|
25
|
+
preEntry,
|
|
26
|
+
entries,
|
|
27
|
+
enableAsyncEntry,
|
|
28
|
+
disableDefaultEntries,
|
|
29
|
+
entriesDir,
|
|
30
|
+
configDir
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export function createToolsConfig(config) {
|
|
2
|
+
const {
|
|
3
|
+
autoprefixer,
|
|
4
|
+
babel,
|
|
5
|
+
minifyCss,
|
|
6
|
+
terser,
|
|
7
|
+
webpack,
|
|
8
|
+
webpackChain,
|
|
9
|
+
tsLoader,
|
|
10
|
+
styledComponents,
|
|
11
|
+
sass,
|
|
12
|
+
postcss,
|
|
13
|
+
less,
|
|
14
|
+
htmlPlugin,
|
|
15
|
+
devServer,
|
|
16
|
+
tailwindcss,
|
|
17
|
+
jest,
|
|
18
|
+
esbuild
|
|
19
|
+
} = config.tools;
|
|
20
|
+
const {
|
|
21
|
+
enableTsLoader
|
|
22
|
+
} = config.output;
|
|
23
|
+
return {
|
|
24
|
+
tsLoader: enableTsLoader ? tsLoader : undefined,
|
|
25
|
+
autoprefixer,
|
|
26
|
+
babel,
|
|
27
|
+
minifyCss,
|
|
28
|
+
terser,
|
|
29
|
+
webpack,
|
|
30
|
+
webpackChain,
|
|
31
|
+
styledComponents,
|
|
32
|
+
sass,
|
|
33
|
+
postcss,
|
|
34
|
+
less,
|
|
35
|
+
htmlPlugin,
|
|
36
|
+
devServer,
|
|
37
|
+
tailwindcss,
|
|
38
|
+
jest,
|
|
39
|
+
esbuild
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { initHtmlConfig, initSourceConfig, initToolsConfig } from "./inits";
|
|
2
|
+
export { transformNormalizedConfig } from "./transformNormalizedConfig";
|
|
3
|
+
export function checkIsLegacyConfig(config) {
|
|
4
|
+
return Boolean(config.legacy);
|
|
5
|
+
}
|
|
6
|
+
export function initialNormalizedConfig(config, appContext) {
|
|
7
|
+
initHtmlConfig(config, appContext);
|
|
8
|
+
initSourceConfig(config, appContext);
|
|
9
|
+
initToolsConfig(config);
|
|
10
|
+
return config;
|
|
11
|
+
}
|