@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,58 +0,0 @@
|
|
|
1
|
-
import { chalk, logger } from '@modern-js/utils';
|
|
2
|
-
import createBuilder from "../builder";
|
|
3
|
-
import { printInstructions } from "./printInstructions";
|
|
4
|
-
export const createDevCompiler = async ({
|
|
5
|
-
api,
|
|
6
|
-
target,
|
|
7
|
-
normalizedConfig,
|
|
8
|
-
appContext
|
|
9
|
-
}) => {
|
|
10
|
-
try {
|
|
11
|
-
const hookRunners = api.useHookRunners();
|
|
12
|
-
const builder = await createBuilder({
|
|
13
|
-
target,
|
|
14
|
-
normalizedConfig,
|
|
15
|
-
appContext,
|
|
16
|
-
compatPluginConfig: {
|
|
17
|
-
async onDevCompileDone({
|
|
18
|
-
isFirstCompile
|
|
19
|
-
}) {
|
|
20
|
-
if (process.stdout.isTTY || isFirstCompile) {
|
|
21
|
-
hookRunners.afterDev();
|
|
22
|
-
|
|
23
|
-
if (isFirstCompile) {
|
|
24
|
-
printInstructions(hookRunners, appContext, normalizedConfig);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
async onBeforeCreateCompiler({
|
|
30
|
-
bundlerConfigs
|
|
31
|
-
}) {
|
|
32
|
-
// run modernjs framework `beforeCreateCompiler` hook
|
|
33
|
-
await hookRunners.beforeCreateCompiler({
|
|
34
|
-
bundlerConfigs
|
|
35
|
-
});
|
|
36
|
-
},
|
|
37
|
-
|
|
38
|
-
async onAfterCreateCompiler({
|
|
39
|
-
compiler
|
|
40
|
-
}) {
|
|
41
|
-
// run modernjs framework afterCreateCompiler hooks
|
|
42
|
-
await hookRunners.afterCreateCompiler({
|
|
43
|
-
compiler
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
return builder.createCompiler();
|
|
50
|
-
} catch (err) {
|
|
51
|
-
logger.log(chalk.red(`Failed to compile.`));
|
|
52
|
-
logger.log();
|
|
53
|
-
logger.log(err); // FIXME: 这里最好抛出异常,执行 process.exit 的地方尽可能少或者控制在几个统一的地方比较合适
|
|
54
|
-
// eslint-disable-next-line no-process-exit
|
|
55
|
-
|
|
56
|
-
process.exit(1);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createBuilderAppIcon = createBuilderAppIcon;
|
|
7
|
-
exports.createBuilderCrossorigin = createBuilderCrossorigin;
|
|
8
|
-
exports.createBuilderFavicon = createBuilderFavicon;
|
|
9
|
-
exports.createHtmlConfig = createHtmlConfig;
|
|
10
|
-
|
|
11
|
-
var _path = _interopRequireDefault(require("path"));
|
|
12
|
-
|
|
13
|
-
var _utils = require("@modern-js/utils");
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
function createHtmlConfig(normalizedConfig, appContext) {
|
|
18
|
-
const {
|
|
19
|
-
disableHtmlFolder,
|
|
20
|
-
favicon,
|
|
21
|
-
faviconByEntries,
|
|
22
|
-
inject,
|
|
23
|
-
injectByEntries,
|
|
24
|
-
meta,
|
|
25
|
-
metaByEntries,
|
|
26
|
-
mountId,
|
|
27
|
-
title,
|
|
28
|
-
titleByEntries,
|
|
29
|
-
scriptExt,
|
|
30
|
-
templateParameters,
|
|
31
|
-
templateParametersByEntries
|
|
32
|
-
} = normalizedConfig.output;
|
|
33
|
-
const {
|
|
34
|
-
configDir
|
|
35
|
-
} = normalizedConfig.source; // transform Modernjs `output.scriptExt` to Builder `html.crossorigin` configuration
|
|
36
|
-
|
|
37
|
-
const builderCrossorigin = createBuilderCrossorigin(scriptExt);
|
|
38
|
-
const builderAppIcon = createBuilderAppIcon(configDir, appContext);
|
|
39
|
-
const builderFavicon = createBuilderFavicon(favicon, configDir, appContext);
|
|
40
|
-
return {
|
|
41
|
-
appIcon: builderAppIcon,
|
|
42
|
-
disableHtmlFolder,
|
|
43
|
-
favicon: builderFavicon,
|
|
44
|
-
faviconByEntries,
|
|
45
|
-
inject,
|
|
46
|
-
injectByEntries,
|
|
47
|
-
meta,
|
|
48
|
-
metaByEntries,
|
|
49
|
-
mountId,
|
|
50
|
-
title,
|
|
51
|
-
titleByEntries,
|
|
52
|
-
crossorigin: builderCrossorigin,
|
|
53
|
-
templateByEntries: appContext.htmlTemplates,
|
|
54
|
-
templateParameters,
|
|
55
|
-
templateParametersByEntries: templateParametersByEntries
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const ICON_EXTENSIONS = ['png', 'jpg', 'jpeg', 'svg', 'ico'];
|
|
60
|
-
|
|
61
|
-
function createBuilderAppIcon(configDir, appContext) {
|
|
62
|
-
const appIcon = (0, _utils.findExists)(ICON_EXTENSIONS.map(ext => _path.default.resolve(appContext.appDirectory, configDir, `icon.${ext}`)));
|
|
63
|
-
return typeof appIcon === 'string' ? appIcon : undefined;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function createBuilderCrossorigin(scriptExt) {
|
|
67
|
-
var _scriptExtCustomConfi;
|
|
68
|
-
|
|
69
|
-
const scriptExtCustomConfig = scriptExt === null || scriptExt === void 0 ? void 0 : scriptExt.custom;
|
|
70
|
-
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;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
function createBuilderFavicon(favicon, configDir, appContext) {
|
|
74
|
-
const defaultFavicon = (0, _utils.findExists)(ICON_EXTENSIONS.map(ext => _path.default.resolve(appContext.appDirectory, configDir, `favicon.${ext}`)));
|
|
75
|
-
return favicon || defaultFavicon || undefined;
|
|
76
|
-
}
|
|
@@ -1,99 +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
|
-
|
|
10
|
-
var _path = require("path");
|
|
11
|
-
|
|
12
|
-
var _utils = require("@modern-js/utils");
|
|
13
|
-
|
|
14
|
-
function createSourceConfig(normalizedConfig, appContext) {
|
|
15
|
-
const {
|
|
16
|
-
alias,
|
|
17
|
-
envVars,
|
|
18
|
-
globalVars,
|
|
19
|
-
include,
|
|
20
|
-
moduleScopes,
|
|
21
|
-
preEntry
|
|
22
|
-
} = normalizedConfig.source;
|
|
23
|
-
const builderGlobalVars = globalVars || {};
|
|
24
|
-
|
|
25
|
-
for (const envVar of envVars || []) {
|
|
26
|
-
const envVarValue = process.env[envVar];
|
|
27
|
-
envVarValue && (builderGlobalVars[`process.env.${envVar}`] = envVarValue);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const builderModuleScope = createBuilderModuleScope(moduleScopes);
|
|
31
|
-
const builderInclude = createBuilderInclude(include, appContext);
|
|
32
|
-
return {
|
|
33
|
-
alias: (0, _utils.mergeAlias)(alias),
|
|
34
|
-
moduleScopes: builderModuleScope,
|
|
35
|
-
globalVars: builderGlobalVars,
|
|
36
|
-
include: builderInclude,
|
|
37
|
-
preEntry,
|
|
38
|
-
// ensure resolve.extensions same as before
|
|
39
|
-
resolveExtensionPrefix: '.web'
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function createBuilderInclude(include, appContext) {
|
|
44
|
-
const defaultInclude = [appContext.internalDirectory];
|
|
45
|
-
const transformInclude = (include || []).map(include => {
|
|
46
|
-
if (typeof include === 'string') {
|
|
47
|
-
if ((0, _path.isAbsolute)(include)) {
|
|
48
|
-
return include;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return new RegExp(include);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return include;
|
|
55
|
-
}).concat(defaultInclude); // concat default Include
|
|
56
|
-
|
|
57
|
-
const root = (0, _utils.findMonorepoRoot)(appContext.appDirectory);
|
|
58
|
-
|
|
59
|
-
if (!root) {
|
|
60
|
-
return transformInclude;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const modernjsMonorepo = (0, _utils.isModernjsMonorepo)(root);
|
|
64
|
-
|
|
65
|
-
if (modernjsMonorepo) {
|
|
66
|
-
const paths = _utils.globby.sync(_path.posix.join(root, 'features', '**', 'package.json'), {
|
|
67
|
-
ignore: ['**/node_modules/**/*']
|
|
68
|
-
}).map(pathname => (0, _path.dirname)(pathname) + _path.sep);
|
|
69
|
-
|
|
70
|
-
return [...paths, ...transformInclude];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return transformInclude;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function createBuilderModuleScope(moduleScopes) {
|
|
77
|
-
if (moduleScopes) {
|
|
78
|
-
let builderModuleScope = [];
|
|
79
|
-
const DEFAULT_SCOPES = ['./src', './shared', /node_modules/];
|
|
80
|
-
|
|
81
|
-
if (Array.isArray(moduleScopes)) {
|
|
82
|
-
if (isPrimitiveScope(moduleScopes)) {
|
|
83
|
-
builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
|
|
84
|
-
} else {
|
|
85
|
-
builderModuleScope = [DEFAULT_SCOPES, ...moduleScopes];
|
|
86
|
-
}
|
|
87
|
-
} else {
|
|
88
|
-
builderModuleScope = [DEFAULT_SCOPES, moduleScopes];
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return builderModuleScope;
|
|
92
|
-
} else {
|
|
93
|
-
return undefined;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function isPrimitiveScope(items) {
|
|
97
|
-
return items.every(item => typeof item === 'string' || Object.prototype.toString.call(item) === '[object RegExp]');
|
|
98
|
-
}
|
|
99
|
-
}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createBuilderTsChecker = createBuilderTsChecker;
|
|
7
|
-
exports.createToolsConfig = createToolsConfig;
|
|
8
|
-
|
|
9
|
-
var _utils = require("@modern-js/utils");
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
|
|
13
|
-
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; }
|
|
14
|
-
|
|
15
|
-
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; }
|
|
16
|
-
|
|
17
|
-
function createToolsConfig(normalizedConfig) {
|
|
18
|
-
const {
|
|
19
|
-
disableCssExtract,
|
|
20
|
-
enableTsLoader
|
|
21
|
-
} = normalizedConfig.output;
|
|
22
|
-
const {
|
|
23
|
-
autoprefixer,
|
|
24
|
-
babel,
|
|
25
|
-
minifyCss,
|
|
26
|
-
terser,
|
|
27
|
-
webpack,
|
|
28
|
-
webpackChain,
|
|
29
|
-
tsLoader,
|
|
30
|
-
styledComponents,
|
|
31
|
-
sass,
|
|
32
|
-
postcss,
|
|
33
|
-
less,
|
|
34
|
-
htmlPlugin,
|
|
35
|
-
// TODO: remove modernjs tools.lodash config
|
|
36
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
37
|
-
lodash
|
|
38
|
-
} = normalizedConfig.tools;
|
|
39
|
-
const builderTsLoader = createBuilderTsLoader(tsLoader, enableTsLoader);
|
|
40
|
-
const builderTsChecker = createBuilderTsChecker(normalizedConfig.output);
|
|
41
|
-
return {
|
|
42
|
-
tsChecker: builderTsChecker,
|
|
43
|
-
styleLoader: disableCssExtract ? {} : undefined,
|
|
44
|
-
cssExtract: disableCssExtract ? false : undefined,
|
|
45
|
-
autoprefixer,
|
|
46
|
-
babel,
|
|
47
|
-
minifyCss,
|
|
48
|
-
terser,
|
|
49
|
-
webpack,
|
|
50
|
-
webpackChain: webpackChain,
|
|
51
|
-
tsLoader: builderTsLoader,
|
|
52
|
-
styledComponents: styledComponents,
|
|
53
|
-
sass: sass,
|
|
54
|
-
postcss: postcss,
|
|
55
|
-
less: less,
|
|
56
|
-
// can't remove comment in html minify.
|
|
57
|
-
// some html template insert by using those comments.
|
|
58
|
-
htmlPlugin: [config => _objectSpread(_objectSpread({}, config), {}, {
|
|
59
|
-
minify: typeof config.minify === 'object' ? _objectSpread(_objectSpread({}, config.minify), {}, {
|
|
60
|
-
removeComments: false
|
|
61
|
-
}) : config.minify
|
|
62
|
-
}), // eslint-disable-next-line no-nested-ternary
|
|
63
|
-
...(Array.isArray(htmlPlugin) ? htmlPlugin : htmlPlugin ? [htmlPlugin] : [])]
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
function createBuilderTsLoader(tsLoader, enableTsLoader) {
|
|
68
|
-
const useTsLoader = Boolean(enableTsLoader);
|
|
69
|
-
|
|
70
|
-
if (!useTsLoader) {
|
|
71
|
-
return undefined;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const defaultTsLoader = {
|
|
75
|
-
compilerOptions: {
|
|
76
|
-
target: 'es5',
|
|
77
|
-
module: 'ESNext'
|
|
78
|
-
},
|
|
79
|
-
transpileOnly: false,
|
|
80
|
-
allowTsInNodeModules: true
|
|
81
|
-
};
|
|
82
|
-
return (_, utils) => (0, _utils.applyOptionsChain)(defaultTsLoader, tsLoader, utils);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function createBuilderTsChecker(output) {
|
|
86
|
-
if (output.enableTsLoader || output.disableTsChecker) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const defaultTsChecker = {
|
|
91
|
-
issue: {
|
|
92
|
-
include: [{
|
|
93
|
-
file: '**/src/**/*'
|
|
94
|
-
}],
|
|
95
|
-
exclude: [{
|
|
96
|
-
file: '**/*.(spec|test).ts'
|
|
97
|
-
}, {
|
|
98
|
-
file: '**/node_modules/**/*'
|
|
99
|
-
}]
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
return defaultTsChecker;
|
|
103
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createDevCompiler = void 0;
|
|
7
|
-
|
|
8
|
-
var _utils = require("@modern-js/utils");
|
|
9
|
-
|
|
10
|
-
var _builder = _interopRequireDefault(require("../builder"));
|
|
11
|
-
|
|
12
|
-
var _printInstructions = require("./printInstructions");
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
const createDevCompiler = async ({
|
|
17
|
-
api,
|
|
18
|
-
target,
|
|
19
|
-
normalizedConfig,
|
|
20
|
-
appContext
|
|
21
|
-
}) => {
|
|
22
|
-
try {
|
|
23
|
-
const hookRunners = api.useHookRunners();
|
|
24
|
-
const builder = await (0, _builder.default)({
|
|
25
|
-
target,
|
|
26
|
-
normalizedConfig,
|
|
27
|
-
appContext,
|
|
28
|
-
compatPluginConfig: {
|
|
29
|
-
async onDevCompileDone({
|
|
30
|
-
isFirstCompile
|
|
31
|
-
}) {
|
|
32
|
-
if (process.stdout.isTTY || isFirstCompile) {
|
|
33
|
-
hookRunners.afterDev();
|
|
34
|
-
|
|
35
|
-
if (isFirstCompile) {
|
|
36
|
-
(0, _printInstructions.printInstructions)(hookRunners, appContext, normalizedConfig);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
async onBeforeCreateCompiler({
|
|
42
|
-
bundlerConfigs
|
|
43
|
-
}) {
|
|
44
|
-
// run modernjs framework `beforeCreateCompiler` hook
|
|
45
|
-
await hookRunners.beforeCreateCompiler({
|
|
46
|
-
bundlerConfigs
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
|
|
50
|
-
async onAfterCreateCompiler({
|
|
51
|
-
compiler
|
|
52
|
-
}) {
|
|
53
|
-
// run modernjs framework afterCreateCompiler hooks
|
|
54
|
-
await hookRunners.afterCreateCompiler({
|
|
55
|
-
compiler
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
return builder.createCompiler();
|
|
62
|
-
} catch (err) {
|
|
63
|
-
_utils.logger.log(_utils.chalk.red(`Failed to compile.`));
|
|
64
|
-
|
|
65
|
-
_utils.logger.log();
|
|
66
|
-
|
|
67
|
-
_utils.logger.log(err); // FIXME: 这里最好抛出异常,执行 process.exit 的地方尽可能少或者控制在几个统一的地方比较合适
|
|
68
|
-
// eslint-disable-next-line no-process-exit
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
process.exit(1);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
exports.createDevCompiler = createDevCompiler;
|
|
@@ -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; // transform Modernjs `output.scriptExt` to Builder `html.crossorigin` configuration
|
|
19
|
-
|
|
20
|
-
var builderCrossorigin = createBuilderCrossorigin(scriptExt);
|
|
21
|
-
var builderAppIcon = createBuilderAppIcon(configDir, appContext);
|
|
22
|
-
var builderFavicon = createBuilderFavicon(favicon, configDir, appContext);
|
|
23
|
-
return {
|
|
24
|
-
appIcon: builderAppIcon,
|
|
25
|
-
disableHtmlFolder: disableHtmlFolder,
|
|
26
|
-
favicon: builderFavicon,
|
|
27
|
-
faviconByEntries: faviconByEntries,
|
|
28
|
-
inject: inject,
|
|
29
|
-
injectByEntries: injectByEntries,
|
|
30
|
-
meta: meta,
|
|
31
|
-
metaByEntries: metaByEntries,
|
|
32
|
-
mountId: mountId,
|
|
33
|
-
title: title,
|
|
34
|
-
titleByEntries: titleByEntries,
|
|
35
|
-
crossorigin: builderCrossorigin,
|
|
36
|
-
templateByEntries: appContext.htmlTemplates,
|
|
37
|
-
templateParameters: templateParameters,
|
|
38
|
-
templateParametersByEntries: templateParametersByEntries
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
var ICON_EXTENSIONS = ['png', 'jpg', 'jpeg', 'svg', 'ico'];
|
|
42
|
-
export function createBuilderAppIcon(configDir, appContext) {
|
|
43
|
-
var appIcon = findExists(ICON_EXTENSIONS.map(function (ext) {
|
|
44
|
-
return path.resolve(appContext.appDirectory, configDir, "icon.".concat(ext));
|
|
45
|
-
}));
|
|
46
|
-
return typeof appIcon === 'string' ? appIcon : undefined;
|
|
47
|
-
}
|
|
48
|
-
export function createBuilderCrossorigin(scriptExt) {
|
|
49
|
-
var _scriptExtCustomConfi;
|
|
50
|
-
|
|
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,67 +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
|
-
var _normalizedConfig$out = normalizedConfig.output,
|
|
6
|
-
assetPrefix = _normalizedConfig$out.assetPrefix,
|
|
7
|
-
copy = _normalizedConfig$out.copy,
|
|
8
|
-
cssModuleLocalIdentName = _normalizedConfig$out.cssModuleLocalIdentName,
|
|
9
|
-
cssPath = _normalizedConfig$out.cssPath,
|
|
10
|
-
jsPath = _normalizedConfig$out.jsPath,
|
|
11
|
-
htmlPath = _normalizedConfig$out.htmlPath,
|
|
12
|
-
mediaPath = _normalizedConfig$out.mediaPath,
|
|
13
|
-
path = _normalizedConfig$out.path,
|
|
14
|
-
disableInlineRuntimeChunk = _normalizedConfig$out.disableInlineRuntimeChunk,
|
|
15
|
-
disableMinimize = _normalizedConfig$out.disableMinimize,
|
|
16
|
-
disableSourceMap = _normalizedConfig$out.disableSourceMap,
|
|
17
|
-
enableCssModuleTSDeclaration = _normalizedConfig$out.enableCssModuleTSDeclaration,
|
|
18
|
-
enableInlineScripts = _normalizedConfig$out.enableInlineScripts,
|
|
19
|
-
enableInlineStyles = _normalizedConfig$out.enableInlineStyles,
|
|
20
|
-
polyfill = _normalizedConfig$out.polyfill,
|
|
21
|
-
dataUriLimit = _normalizedConfig$out.dataUriLimit,
|
|
22
|
-
disableAssetsCache = _normalizedConfig$out.disableAssetsCache,
|
|
23
|
-
enableLatestDecorators = _normalizedConfig$out.enableLatestDecorators,
|
|
24
|
-
disableCssModuleExtension = _normalizedConfig$out.disableCssModuleExtension;
|
|
25
|
-
var defaultCopyPattern = createCopyPattern(appContext, normalizedConfig, 'upload');
|
|
26
|
-
var builderCopy = copy ? [].concat(_toConsumableArray(copy), [defaultCopyPattern]) : [defaultCopyPattern];
|
|
27
|
-
return {
|
|
28
|
-
assetPrefix: assetPrefix,
|
|
29
|
-
copy: builderCopy,
|
|
30
|
-
distPath: {
|
|
31
|
-
root: path,
|
|
32
|
-
css: cssPath,
|
|
33
|
-
js: jsPath,
|
|
34
|
-
html: htmlPath,
|
|
35
|
-
// `@modern-js/webpack` output all media files to `dist/media` by default
|
|
36
|
-
svg: mediaPath || 'midia',
|
|
37
|
-
image: mediaPath || 'midia',
|
|
38
|
-
font: mediaPath || 'midia',
|
|
39
|
-
media: mediaPath || 'midia'
|
|
40
|
-
},
|
|
41
|
-
dataUriLimit: {
|
|
42
|
-
svg: dataUriLimit,
|
|
43
|
-
image: dataUriLimit,
|
|
44
|
-
font: dataUriLimit,
|
|
45
|
-
media: dataUriLimit
|
|
46
|
-
},
|
|
47
|
-
disableCssModuleExtension: disableCssModuleExtension,
|
|
48
|
-
disableInlineRuntimeChunk: disableInlineRuntimeChunk,
|
|
49
|
-
disableMinimize: disableMinimize,
|
|
50
|
-
disableSourceMap: disableSourceMap,
|
|
51
|
-
enableCssModuleTSDeclaration: enableCssModuleTSDeclaration,
|
|
52
|
-
enableInlineScripts: enableInlineScripts,
|
|
53
|
-
enableInlineStyles: enableInlineStyles,
|
|
54
|
-
polyfill: 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
|
-
disableFilenameHash: disableAssetsCache,
|
|
58
|
-
enableLatestDecorators: enableLatestDecorators,
|
|
59
|
-
filename: {
|
|
60
|
-
css: cssModuleLocalIdentName
|
|
61
|
-
},
|
|
62
|
-
// `@modern-js/webpack` used to generate asset manifest by default
|
|
63
|
-
enableAssetManifest: true,
|
|
64
|
-
// compatible the modern-js with fallback behavior
|
|
65
|
-
enableAssetFallback: true
|
|
66
|
-
};
|
|
67
|
-
}
|
|
@@ -1,100 +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
|
-
|
|
15
|
-
var _iterator = _createForOfIteratorHelper(envVars || []),
|
|
16
|
-
_step;
|
|
17
|
-
|
|
18
|
-
try {
|
|
19
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
20
|
-
var envVar = _step.value;
|
|
21
|
-
var envVarValue = process.env[envVar];
|
|
22
|
-
envVarValue && (builderGlobalVars["process.env.".concat(envVar)] = envVarValue);
|
|
23
|
-
}
|
|
24
|
-
} catch (err) {
|
|
25
|
-
_iterator.e(err);
|
|
26
|
-
} finally {
|
|
27
|
-
_iterator.f();
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
var builderModuleScope = createBuilderModuleScope(moduleScopes);
|
|
31
|
-
var builderInclude = createBuilderInclude(include, appContext);
|
|
32
|
-
return {
|
|
33
|
-
alias: mergeAlias(alias),
|
|
34
|
-
moduleScopes: builderModuleScope,
|
|
35
|
-
globalVars: builderGlobalVars,
|
|
36
|
-
include: builderInclude,
|
|
37
|
-
preEntry: preEntry,
|
|
38
|
-
// ensure resolve.extensions same as before
|
|
39
|
-
resolveExtensionPrefix: '.web'
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export function createBuilderInclude(include, appContext) {
|
|
43
|
-
var defaultInclude = [appContext.internalDirectory];
|
|
44
|
-
var transformInclude = (include || []).map(function (include) {
|
|
45
|
-
if (typeof include === 'string') {
|
|
46
|
-
if (isAbsolute(include)) {
|
|
47
|
-
return include;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return new RegExp(include);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return include;
|
|
54
|
-
}).concat(defaultInclude); // concat default Include
|
|
55
|
-
|
|
56
|
-
var root = findMonorepoRoot(appContext.appDirectory);
|
|
57
|
-
|
|
58
|
-
if (!root) {
|
|
59
|
-
return transformInclude;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
var modernjsMonorepo = isModernjsMonorepo(root);
|
|
63
|
-
|
|
64
|
-
if (modernjsMonorepo) {
|
|
65
|
-
var paths = globby.sync(posix.join(root, 'features', '**', 'package.json'), {
|
|
66
|
-
ignore: ['**/node_modules/**/*']
|
|
67
|
-
}).map(function (pathname) {
|
|
68
|
-
return dirname(pathname) + sep;
|
|
69
|
-
});
|
|
70
|
-
return [].concat(_toConsumableArray(paths), _toConsumableArray(transformInclude));
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return transformInclude;
|
|
74
|
-
}
|
|
75
|
-
export function createBuilderModuleScope(moduleScopes) {
|
|
76
|
-
if (moduleScopes) {
|
|
77
|
-
var builderModuleScope = [];
|
|
78
|
-
var DEFAULT_SCOPES = ['./src', './shared', /node_modules/];
|
|
79
|
-
|
|
80
|
-
if (Array.isArray(moduleScopes)) {
|
|
81
|
-
if (isPrimitiveScope(moduleScopes)) {
|
|
82
|
-
builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
|
|
83
|
-
} else {
|
|
84
|
-
builderModuleScope = [DEFAULT_SCOPES].concat(_toConsumableArray(moduleScopes));
|
|
85
|
-
}
|
|
86
|
-
} else {
|
|
87
|
-
builderModuleScope = [DEFAULT_SCOPES, moduleScopes];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return builderModuleScope;
|
|
91
|
-
} else {
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
function isPrimitiveScope(items) {
|
|
96
|
-
return items.every(function (item) {
|
|
97
|
-
return typeof item === 'string' || Object.prototype.toString.call(item) === '[object RegExp]';
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|