@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
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
export declare type BuilderSecurityConfig = Required<BuilderConfig>['security'];
|
|
3
|
+
export declare type SecurityUserConfig = BuilderSecurityConfig;
|
|
4
|
+
export declare type SecurityNormalizedConfig = SecurityUserConfig;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
export declare type BuilderSourceConfig = Required<BuilderConfig>['source'];
|
|
3
|
+
export declare type Entry = string | {
|
|
4
|
+
entry: string;
|
|
5
|
+
enableFileSystemRoutes?: boolean;
|
|
6
|
+
disableMount?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare type Entries = Record<string, Entry>;
|
|
9
|
+
export interface SourceUserConfig extends BuilderSourceConfig {
|
|
10
|
+
entries?: Entries;
|
|
11
|
+
enableAsyncEntry?: boolean;
|
|
12
|
+
disableDefaultEntries?: boolean;
|
|
13
|
+
entriesDir?: string;
|
|
14
|
+
configDir?: string;
|
|
15
|
+
/**
|
|
16
|
+
* The configuration of `source.designSystem` is provided by `tailwindcss` plugin.
|
|
17
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
18
|
+
* @requires `tailwindcss` plugin
|
|
19
|
+
*/
|
|
20
|
+
designSystem?: Record<string, any>;
|
|
21
|
+
}
|
|
22
|
+
export declare type SourceNormalizedConfig = SourceUserConfig;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type { JestConfig } from '@modern-js/core';
|
|
3
|
+
export declare type BuilderToolsConfig = Required<BuilderConfig>['tools'];
|
|
4
|
+
/**
|
|
5
|
+
* The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
|
|
6
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
7
|
+
* @requires `tailwindcss` plugin
|
|
8
|
+
*/
|
|
9
|
+
export declare type Tailwindcss = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
|
|
10
|
+
export interface ToolsUserConfig extends BuilderToolsConfig {
|
|
11
|
+
tailwindcss?: Tailwindcss;
|
|
12
|
+
jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
|
|
13
|
+
esbuild?: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export declare type ToolsNormalizedConfig = ToolsUserConfig;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { webpack } from '@modern-js/builder-webpack-provider';
|
|
2
|
+
import type { AsyncWaterfall, AsyncWorkflow, ParallelWorkflow } from '@modern-js/plugin';
|
|
3
|
+
import type { Entrypoint, HtmlPartials, NestedRoute, PageRoute, RouteLegacy, ServerRoute } from '@modern-js/types';
|
|
4
|
+
export interface ImportSpecifier {
|
|
5
|
+
local?: string;
|
|
6
|
+
imported?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ImportStatement {
|
|
9
|
+
specifiers: ImportSpecifier[];
|
|
10
|
+
value: string;
|
|
11
|
+
initialize?: string;
|
|
12
|
+
}
|
|
13
|
+
export interface RuntimePlugin {
|
|
14
|
+
name: string;
|
|
15
|
+
options: string;
|
|
16
|
+
args?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare type AppToolsHooks = {
|
|
19
|
+
modifyEntryExport: AsyncWaterfall<{
|
|
20
|
+
entrypoint: Entrypoint;
|
|
21
|
+
exportStatement: string;
|
|
22
|
+
}>;
|
|
23
|
+
modifyEntryImports: AsyncWaterfall<{
|
|
24
|
+
imports: ImportStatement[];
|
|
25
|
+
entrypoint: Entrypoint;
|
|
26
|
+
}>;
|
|
27
|
+
modifyEntryRuntimePlugins: AsyncWaterfall<{
|
|
28
|
+
entrypoint: Entrypoint;
|
|
29
|
+
plugins: RuntimePlugin[];
|
|
30
|
+
}>;
|
|
31
|
+
modifyEntryRenderFunction: AsyncWaterfall<{
|
|
32
|
+
entrypoint: Entrypoint;
|
|
33
|
+
code: string;
|
|
34
|
+
}>;
|
|
35
|
+
modifyAsyncEntry: AsyncWaterfall<{
|
|
36
|
+
entrypoint: Entrypoint;
|
|
37
|
+
code: string;
|
|
38
|
+
}>;
|
|
39
|
+
modifyFileSystemRoutes: AsyncWaterfall<{
|
|
40
|
+
entrypoint: Entrypoint;
|
|
41
|
+
routes: RouteLegacy[] | (NestedRoute | PageRoute)[];
|
|
42
|
+
}>;
|
|
43
|
+
modifyServerRoutes: AsyncWaterfall<{
|
|
44
|
+
routes: ServerRoute[];
|
|
45
|
+
}>;
|
|
46
|
+
htmlPartials: AsyncWaterfall<{
|
|
47
|
+
entrypoint: Entrypoint;
|
|
48
|
+
partials: HtmlPartials;
|
|
49
|
+
}>;
|
|
50
|
+
beforeGenerateRoutes: AsyncWaterfall<{
|
|
51
|
+
entrypoint: Entrypoint;
|
|
52
|
+
code: string;
|
|
53
|
+
}>;
|
|
54
|
+
addDefineTypes: AsyncWaterfall<void>;
|
|
55
|
+
beforeDev: AsyncWorkflow<void, unknown>;
|
|
56
|
+
afterDev: AsyncWorkflow<void, unknown>;
|
|
57
|
+
beforeCreateCompiler: AsyncWorkflow<{
|
|
58
|
+
bundlerConfigs: webpack.Configuration[];
|
|
59
|
+
}, unknown>;
|
|
60
|
+
afterCreateCompiler: AsyncWorkflow<{
|
|
61
|
+
compiler?: webpack.Compiler | webpack.MultiCompiler;
|
|
62
|
+
}, unknown>;
|
|
63
|
+
beforePrintInstructions: AsyncWaterfall<{
|
|
64
|
+
instructions: string;
|
|
65
|
+
}>;
|
|
66
|
+
beforeBuild: AsyncWorkflow<{
|
|
67
|
+
bundlerConfigs?: webpack.Configuration[];
|
|
68
|
+
}, unknown>;
|
|
69
|
+
afterBuild: AsyncWorkflow<{
|
|
70
|
+
stats?: webpack.Stats | webpack.MultiStats;
|
|
71
|
+
}, unknown>;
|
|
72
|
+
beforeDeploy: AsyncWorkflow<Record<string, any>, unknown>;
|
|
73
|
+
afterDeploy: AsyncWorkflow<Record<string, any>, unknown>;
|
|
74
|
+
watchFiles: ParallelWorkflow<void>;
|
|
75
|
+
fileChange: AsyncWorkflow<{
|
|
76
|
+
filename: string;
|
|
77
|
+
eventType: 'add' | 'change' | 'unlink';
|
|
78
|
+
}, void>;
|
|
79
|
+
beforeRestart: AsyncWorkflow<void, void>;
|
|
80
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { NormalizedConfig, UserConfig } from '@modern-js/core';
|
|
2
|
+
import type { AppToolsUserConfig, AppToolsNormalizedConfig } from './config';
|
|
3
|
+
import type { AppToolsHooks } from './hooks';
|
|
4
|
+
import type { AppToolsLegacyUserConfig, AppToolsLegacyNormalizedConfig } from './legacyConfig';
|
|
5
|
+
export * from './hooks';
|
|
6
|
+
export * from './config';
|
|
7
|
+
export * from './legacyConfig';
|
|
8
|
+
export type { ServerUserConfig, ServerNormalizedConfig, BffUserConfig, BffNormalizedConfig, SSR, SSRByEntries } from '@modern-js/server-core';
|
|
9
|
+
export type { IAppContext, PluginAPI, CliPlugin, NormalizedConfig, UserConfig } from '@modern-js/core';
|
|
10
|
+
export declare type AppTools = {
|
|
11
|
+
hooks: AppToolsHooks;
|
|
12
|
+
userConfig: AppToolsUserConfig;
|
|
13
|
+
normalizedConfig: AppToolsNormalizedConfig;
|
|
14
|
+
};
|
|
15
|
+
export declare type LegacyAppTools = {
|
|
16
|
+
hooks: AppToolsHooks;
|
|
17
|
+
userConfig: AppToolsLegacyUserConfig;
|
|
18
|
+
normalizedConfig: AppToolsLegacyNormalizedConfig;
|
|
19
|
+
};
|
|
20
|
+
export declare type AppNormalizedConfig = NormalizedConfig<AppTools>;
|
|
21
|
+
export declare type AppLegacyNormalizedConfig = NormalizedConfig<LegacyAppTools>;
|
|
22
|
+
export declare type AppUserConfig = UserConfig<AppTools>;
|
|
23
|
+
export declare type AppLegacyUserConfig = UserConfig<LegacyAppTools>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DevServerHttpsOptions } from '@modern-js/types';
|
|
2
|
+
export declare type DevProxyOptions = string | Record<string, string>;
|
|
3
|
+
export declare type DevUserLegacyConfig = {
|
|
4
|
+
assetPrefix?: string | boolean;
|
|
5
|
+
https?: DevServerHttpsOptions;
|
|
6
|
+
/**
|
|
7
|
+
* The configuration of `dev.proxy` is provided by `proxy` plugin.
|
|
8
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
9
|
+
* @requires `proxy` plugin
|
|
10
|
+
*/
|
|
11
|
+
proxy?: DevProxyOptions;
|
|
12
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ServerUserConfig as LegacyServerUserConfig, BffUserConfig as LegacyBffUserConfig } from '@modern-js/server-core';
|
|
2
|
+
import type { DevUserLegacyConfig } from './dev';
|
|
3
|
+
import type { OutputLegacyUserConfig } from './output';
|
|
4
|
+
import type { SourceLegacyUserConfig } from './source';
|
|
5
|
+
import type { DeployLegacyUserConfig } from './deploy';
|
|
6
|
+
import type { ToolsLegacyUserConfig } from './tools';
|
|
7
|
+
export type { DevUserLegacyConfig } from './dev';
|
|
8
|
+
export type { OutputLegacyUserConfig } from './output';
|
|
9
|
+
export type { DeployLegacyUserConfig } from './deploy';
|
|
10
|
+
export type { SourceLegacyUserConfig } from './source';
|
|
11
|
+
export type { ToolsLegacyUserConfig } from './tools';
|
|
12
|
+
export interface RuntimeLegacyConfig {
|
|
13
|
+
[name: string]: any;
|
|
14
|
+
}
|
|
15
|
+
export interface RuntimeByEntriesLegacyConfig {
|
|
16
|
+
[name: string]: RuntimeLegacyConfig;
|
|
17
|
+
}
|
|
18
|
+
export declare type AppToolsLegacyUserConfig = {
|
|
19
|
+
source?: SourceLegacyUserConfig;
|
|
20
|
+
output?: OutputLegacyUserConfig;
|
|
21
|
+
server?: LegacyServerUserConfig;
|
|
22
|
+
dev?: DevUserLegacyConfig;
|
|
23
|
+
deploy?: DeployLegacyUserConfig;
|
|
24
|
+
tools?: ToolsLegacyUserConfig;
|
|
25
|
+
runtime?: RuntimeLegacyConfig;
|
|
26
|
+
runtimeByEntries?: RuntimeByEntriesLegacyConfig;
|
|
27
|
+
bff?: LegacyBffUserConfig;
|
|
28
|
+
legacy?: boolean;
|
|
29
|
+
};
|
|
30
|
+
export interface AppToolsLegacyNormalizedConfig extends Required<AppToolsLegacyUserConfig> {
|
|
31
|
+
cliOptions?: Record<string, any>;
|
|
32
|
+
_raw: AppToolsLegacyUserConfig;
|
|
33
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { MetaOptions } from '@modern-js/utils';
|
|
2
|
+
import { SSGConfig } from '../config';
|
|
3
|
+
declare type CrossOrigin = 'anonymous' | 'use-credentials';
|
|
4
|
+
export declare type OutputLegacyUserConfig = {
|
|
5
|
+
assetPrefix?: string;
|
|
6
|
+
htmlPath?: string;
|
|
7
|
+
jsPath?: string;
|
|
8
|
+
cssPath?: string;
|
|
9
|
+
mediaPath?: string;
|
|
10
|
+
path?: string;
|
|
11
|
+
title?: string;
|
|
12
|
+
titleByEntries?: Record<string, string>;
|
|
13
|
+
meta?: MetaOptions;
|
|
14
|
+
metaByEntries?: Record<string, MetaOptions>;
|
|
15
|
+
inject?: 'body' | 'head' | boolean;
|
|
16
|
+
injectByEntries?: Record<string, 'body' | 'head' | boolean>;
|
|
17
|
+
mountId?: string;
|
|
18
|
+
favicon?: string;
|
|
19
|
+
faviconByEntries?: Record<string, string | undefined>;
|
|
20
|
+
copy?: Array<Record<string, unknown> & {
|
|
21
|
+
from: string;
|
|
22
|
+
}>;
|
|
23
|
+
disableTsChecker?: boolean;
|
|
24
|
+
disableHtmlFolder?: boolean;
|
|
25
|
+
disableCssModuleExtension?: boolean;
|
|
26
|
+
disableCssExtract?: boolean;
|
|
27
|
+
enableCssModuleTSDeclaration?: boolean;
|
|
28
|
+
disableMinimize?: boolean;
|
|
29
|
+
enableInlineStyles?: boolean;
|
|
30
|
+
enableInlineScripts?: boolean;
|
|
31
|
+
disableSourceMap?: boolean;
|
|
32
|
+
disableInlineRuntimeChunk?: boolean;
|
|
33
|
+
disableAssetsCache?: boolean;
|
|
34
|
+
enableLatestDecorators?: boolean;
|
|
35
|
+
polyfill?: 'off' | 'usage' | 'entry' | 'ua';
|
|
36
|
+
dataUriLimit?: number;
|
|
37
|
+
templateParameters?: Record<string, unknown>;
|
|
38
|
+
templateParametersByEntries?: Record<string, Record<string, unknown>>;
|
|
39
|
+
crossorigin?: boolean | CrossOrigin;
|
|
40
|
+
cssModuleLocalIdentName?: string;
|
|
41
|
+
enableModernMode?: boolean;
|
|
42
|
+
disableNodePolyfill?: boolean;
|
|
43
|
+
enableTsLoader?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* The configuration of `output.ssg` is provided by `ssg` plugin.
|
|
46
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
47
|
+
* @requires `ssg` plugin
|
|
48
|
+
*/
|
|
49
|
+
ssg?: SSGConfig;
|
|
50
|
+
};
|
|
51
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { AliasOption } from '@modern-js/utils';
|
|
2
|
+
export declare type SourceLegacyUserConfig = {
|
|
3
|
+
alias?: AliasOption;
|
|
4
|
+
entries?: Record<string, string | {
|
|
5
|
+
entry: string;
|
|
6
|
+
enableFileSystemRoutes?: boolean;
|
|
7
|
+
disableMount?: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
preEntry?: string | string[];
|
|
10
|
+
enableAsyncEntry?: boolean;
|
|
11
|
+
disableDefaultEntries?: boolean;
|
|
12
|
+
entriesDir?: string;
|
|
13
|
+
configDir?: string;
|
|
14
|
+
apiDir?: string;
|
|
15
|
+
envVars?: Array<string>;
|
|
16
|
+
globalVars?: Record<string, string>;
|
|
17
|
+
moduleScopes?: Array<string | RegExp> | (((scopes: Array<string | RegExp>) => void) | ((scopes: Array<string | RegExp>) => Array<string | RegExp>))[] | ((scopes: Array<string | RegExp>) => Array<string | RegExp>) | ((scopes: Array<string | RegExp>) => void);
|
|
18
|
+
include?: Array<string | RegExp>;
|
|
19
|
+
/**
|
|
20
|
+
* The configuration of `source.designSystem` is provided by `tailwindcss` plugin.
|
|
21
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
22
|
+
* @requires `tailwindcss` plugin
|
|
23
|
+
*/
|
|
24
|
+
designSystem?: Record<string, any>;
|
|
25
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { DevServerOptions } from '@modern-js/types';
|
|
2
|
+
import type { BuilderConfig } from '@modern-js/builder-webpack-provider';
|
|
3
|
+
import type { JestConfig } from '@modern-js/core';
|
|
4
|
+
declare type BuilderToolsConfig = Required<BuilderConfig>['tools'];
|
|
5
|
+
export declare type ToolsLegacyUserConfig = BuilderToolsConfig & {
|
|
6
|
+
esbuild?: Record<string, unknown>;
|
|
7
|
+
devServer?: DevServerOptions;
|
|
8
|
+
/**
|
|
9
|
+
* The configuration of `tools.tailwindcss` is provided by `tailwindcss` plugin.
|
|
10
|
+
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
|
11
|
+
* @requires `tailwindcss` plugin
|
|
12
|
+
*/
|
|
13
|
+
tailwindcss?: Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
|
|
14
|
+
jest?: JestConfig | ((jestConfig: JestConfig) => JestConfig);
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { bundle } from '@modern-js/node-bundle-require';
|
|
2
|
-
import type { NormalizedConfig } from '@modern-js/core';
|
|
3
2
|
import type { ServerConfig } from '@modern-js/server-core';
|
|
3
|
+
import type { AppNormalizedConfig } from '../types';
|
|
4
4
|
export declare const defineServerConfig: (config: ServerConfig) => ServerConfig;
|
|
5
5
|
export declare const buildServerConfig: ({
|
|
6
6
|
appDirectory,
|
|
@@ -17,6 +17,5 @@ export declare const buildServerConfig: ({
|
|
|
17
17
|
*
|
|
18
18
|
* 处理循环引用的 replacer
|
|
19
19
|
*/
|
|
20
|
-
|
|
21
20
|
export declare const safeReplacer: () => (key: string, value: unknown) => unknown;
|
|
22
|
-
export declare const emitResolvedConfig: (appDirectory: string, resolvedConfig:
|
|
21
|
+
export declare const emitResolvedConfig: (appDirectory: string, resolvedConfig: AppNormalizedConfig) => Promise<void>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IAppContext, ToRunners } from '@modern-js/core';
|
|
2
|
+
import { AppToolsHooks } from '../types/hooks';
|
|
3
|
+
export declare const createFileWatcher: (appContext: IAppContext, configDir: string | undefined, hooksRunner: ToRunners<AppToolsHooks>) => Promise<import("@modern-js/utils").FSWatcher | undefined>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { IAppContext,
|
|
2
|
-
import type {
|
|
3
|
-
export declare const printInstructions: (hookRunners:
|
|
1
|
+
import type { IAppContext, CliHooksRunner } from '@modern-js/core';
|
|
2
|
+
import type { AppNormalizedConfig, AppTools } from '../types';
|
|
3
|
+
export declare const printInstructions: (hookRunners: CliHooksRunner<AppTools>, appContext: IAppContext, config: AppNormalizedConfig) => Promise<void>;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "2.0.0-beta.
|
|
14
|
+
"version": "2.0.0-beta.2",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -59,33 +59,34 @@
|
|
|
59
59
|
"@babel/runtime": "^7.18.0",
|
|
60
60
|
"@babel/traverse": "^7.18.0",
|
|
61
61
|
"@babel/types": "^7.18.0",
|
|
62
|
-
"@modern-js/
|
|
63
|
-
"@modern-js/
|
|
64
|
-
"@modern-js/node-
|
|
65
|
-
"@modern-js/
|
|
66
|
-
"@modern-js/
|
|
67
|
-
"@modern-js/
|
|
68
|
-
"@modern-js/
|
|
69
|
-
"@modern-js/
|
|
70
|
-
"@modern-js/
|
|
71
|
-
"@modern-js/
|
|
72
|
-
"@modern-js/
|
|
73
|
-
"@modern-js/
|
|
74
|
-
"@modern-js/
|
|
75
|
-
"@modern-js/
|
|
76
|
-
"@modern-js/
|
|
77
|
-
"@modern-js/
|
|
78
|
-
"@modern-js/
|
|
62
|
+
"@modern-js/builder": "2.0.0-beta.2",
|
|
63
|
+
"@modern-js/builder-plugin-esbuild": "2.0.0-beta.2",
|
|
64
|
+
"@modern-js/builder-plugin-node-polyfill": "2.0.0-beta.2",
|
|
65
|
+
"@modern-js/builder-shared": "2.0.0-beta.2",
|
|
66
|
+
"@modern-js/builder-webpack-provider": "2.0.0-beta.2",
|
|
67
|
+
"@modern-js/core": "2.0.0-beta.2",
|
|
68
|
+
"@modern-js/new-action": "2.0.0-beta.2",
|
|
69
|
+
"@modern-js/node-bundle-require": "2.0.0-beta.2",
|
|
70
|
+
"@modern-js/plugin": "2.0.0-beta.2",
|
|
71
|
+
"@modern-js/plugin-data-loader": "2.0.0-beta.2",
|
|
72
|
+
"@modern-js/plugin-i18n": "2.0.0-beta.2",
|
|
73
|
+
"@modern-js/plugin-lint": "2.0.0-beta.2",
|
|
74
|
+
"@modern-js/prod-server": "2.0.0-beta.2",
|
|
75
|
+
"@modern-js/server": "2.0.0-beta.2",
|
|
76
|
+
"@modern-js/types": "2.0.0-beta.2",
|
|
77
|
+
"@modern-js/upgrade": "2.0.0-beta.2",
|
|
78
|
+
"@modern-js/utils": "2.0.0-beta.2"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@modern-js/server-core": "2.0.0-beta.0",
|
|
82
|
-
"@scripts/build": "2.0.0-beta.0",
|
|
83
|
-
"@scripts/jest-config": "2.0.0-beta.0",
|
|
84
81
|
"@types/babel__traverse": "^7.14.2",
|
|
85
82
|
"@types/jest": "^27",
|
|
86
83
|
"@types/node": "^14",
|
|
87
84
|
"jest": "^27",
|
|
88
|
-
"typescript": "^4"
|
|
85
|
+
"typescript": "^4",
|
|
86
|
+
"webpack": "^5.75.0",
|
|
87
|
+
"@modern-js/server-core": "2.0.0-beta.2",
|
|
88
|
+
"@scripts/build": "2.0.0-beta.2",
|
|
89
|
+
"@scripts/jest-config": "2.0.0-beta.2"
|
|
89
90
|
},
|
|
90
91
|
"sideEffects": false,
|
|
91
92
|
"publishConfig": {
|
|
@@ -93,9 +94,9 @@
|
|
|
93
94
|
"access": "public"
|
|
94
95
|
},
|
|
95
96
|
"scripts": {
|
|
96
|
-
"new": "modern new",
|
|
97
|
-
"dev": "modern build --watch",
|
|
98
|
-
"build": "modern build",
|
|
97
|
+
"new": "modern-lib new",
|
|
98
|
+
"dev": "modern-lib build --watch",
|
|
99
|
+
"build": "modern-lib build",
|
|
99
100
|
"test": "jest --passWithNoTests"
|
|
100
101
|
}
|
|
101
102
|
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { findExists } from '@modern-js/utils';
|
|
3
|
-
export function createHtmlConfig(normalizedConfig, appContext) {
|
|
4
|
-
const {
|
|
5
|
-
disableHtmlFolder,
|
|
6
|
-
favicon,
|
|
7
|
-
faviconByEntries,
|
|
8
|
-
inject,
|
|
9
|
-
injectByEntries,
|
|
10
|
-
meta,
|
|
11
|
-
metaByEntries,
|
|
12
|
-
mountId,
|
|
13
|
-
title,
|
|
14
|
-
titleByEntries,
|
|
15
|
-
scriptExt,
|
|
16
|
-
templateParameters,
|
|
17
|
-
templateParametersByEntries
|
|
18
|
-
} = normalizedConfig.output;
|
|
19
|
-
const {
|
|
20
|
-
configDir
|
|
21
|
-
} = normalizedConfig.source; // transform Modernjs `output.scriptExt` to Builder `html.crossorigin` configuration
|
|
22
|
-
|
|
23
|
-
const builderCrossorigin = createBuilderCrossorigin(scriptExt);
|
|
24
|
-
const builderAppIcon = createBuilderAppIcon(configDir, appContext);
|
|
25
|
-
const builderFavicon = createBuilderFavicon(favicon, configDir, appContext);
|
|
26
|
-
return {
|
|
27
|
-
appIcon: builderAppIcon,
|
|
28
|
-
disableHtmlFolder,
|
|
29
|
-
favicon: builderFavicon,
|
|
30
|
-
faviconByEntries,
|
|
31
|
-
inject,
|
|
32
|
-
injectByEntries,
|
|
33
|
-
meta,
|
|
34
|
-
metaByEntries,
|
|
35
|
-
mountId,
|
|
36
|
-
title,
|
|
37
|
-
titleByEntries,
|
|
38
|
-
crossorigin: builderCrossorigin,
|
|
39
|
-
templateByEntries: appContext.htmlTemplates,
|
|
40
|
-
templateParameters,
|
|
41
|
-
templateParametersByEntries: templateParametersByEntries
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
const ICON_EXTENSIONS = ['png', 'jpg', 'jpeg', 'svg', 'ico'];
|
|
45
|
-
export function createBuilderAppIcon(configDir, appContext) {
|
|
46
|
-
const appIcon = findExists(ICON_EXTENSIONS.map(ext => path.resolve(appContext.appDirectory, configDir, `icon.${ext}`)));
|
|
47
|
-
return typeof appIcon === 'string' ? appIcon : undefined;
|
|
48
|
-
}
|
|
49
|
-
export function createBuilderCrossorigin(scriptExt) {
|
|
50
|
-
var _scriptExtCustomConfi;
|
|
51
|
-
|
|
52
|
-
const scriptExtCustomConfig = scriptExt === null || scriptExt === void 0 ? void 0 : scriptExt.custom;
|
|
53
|
-
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;
|
|
54
|
-
}
|
|
55
|
-
export function createBuilderFavicon(favicon, configDir, appContext) {
|
|
56
|
-
const defaultFavicon = findExists(ICON_EXTENSIONS.map(ext => path.resolve(appContext.appDirectory, configDir, `favicon.${ext}`)));
|
|
57
|
-
return favicon || defaultFavicon || undefined;
|
|
58
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { dirname, isAbsolute, posix, sep } from 'path';
|
|
2
|
-
import { globby, mergeAlias, findMonorepoRoot, isModernjsMonorepo } from '@modern-js/utils';
|
|
3
|
-
export function createSourceConfig(normalizedConfig, appContext) {
|
|
4
|
-
const {
|
|
5
|
-
alias,
|
|
6
|
-
envVars,
|
|
7
|
-
globalVars,
|
|
8
|
-
include,
|
|
9
|
-
moduleScopes,
|
|
10
|
-
preEntry
|
|
11
|
-
} = normalizedConfig.source;
|
|
12
|
-
const builderGlobalVars = globalVars || {};
|
|
13
|
-
|
|
14
|
-
for (const envVar of envVars || []) {
|
|
15
|
-
const envVarValue = process.env[envVar];
|
|
16
|
-
envVarValue && (builderGlobalVars[`process.env.${envVar}`] = envVarValue);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const builderModuleScope = createBuilderModuleScope(moduleScopes);
|
|
20
|
-
const builderInclude = createBuilderInclude(include, appContext);
|
|
21
|
-
return {
|
|
22
|
-
alias: mergeAlias(alias),
|
|
23
|
-
moduleScopes: builderModuleScope,
|
|
24
|
-
globalVars: builderGlobalVars,
|
|
25
|
-
include: builderInclude,
|
|
26
|
-
preEntry,
|
|
27
|
-
// ensure resolve.extensions same as before
|
|
28
|
-
resolveExtensionPrefix: '.web'
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
export function createBuilderInclude(include, appContext) {
|
|
32
|
-
const defaultInclude = [appContext.internalDirectory];
|
|
33
|
-
const transformInclude = (include || []).map(include => {
|
|
34
|
-
if (typeof include === 'string') {
|
|
35
|
-
if (isAbsolute(include)) {
|
|
36
|
-
return include;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return new RegExp(include);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return include;
|
|
43
|
-
}).concat(defaultInclude); // concat default Include
|
|
44
|
-
|
|
45
|
-
const root = findMonorepoRoot(appContext.appDirectory);
|
|
46
|
-
|
|
47
|
-
if (!root) {
|
|
48
|
-
return transformInclude;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const modernjsMonorepo = isModernjsMonorepo(root);
|
|
52
|
-
|
|
53
|
-
if (modernjsMonorepo) {
|
|
54
|
-
const paths = globby.sync(posix.join(root, 'features', '**', 'package.json'), {
|
|
55
|
-
ignore: ['**/node_modules/**/*']
|
|
56
|
-
}).map(pathname => dirname(pathname) + sep);
|
|
57
|
-
return [...paths, ...transformInclude];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
return transformInclude;
|
|
61
|
-
}
|
|
62
|
-
export function createBuilderModuleScope(moduleScopes) {
|
|
63
|
-
if (moduleScopes) {
|
|
64
|
-
let builderModuleScope = [];
|
|
65
|
-
const DEFAULT_SCOPES = ['./src', './shared', /node_modules/];
|
|
66
|
-
|
|
67
|
-
if (Array.isArray(moduleScopes)) {
|
|
68
|
-
if (isPrimitiveScope(moduleScopes)) {
|
|
69
|
-
builderModuleScope = DEFAULT_SCOPES.concat(moduleScopes);
|
|
70
|
-
} else {
|
|
71
|
-
builderModuleScope = [DEFAULT_SCOPES, ...moduleScopes];
|
|
72
|
-
}
|
|
73
|
-
} else {
|
|
74
|
-
builderModuleScope = [DEFAULT_SCOPES, moduleScopes];
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return builderModuleScope;
|
|
78
|
-
} else {
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function isPrimitiveScope(items) {
|
|
83
|
-
return items.every(item => typeof item === 'string' || Object.prototype.toString.call(item) === '[object RegExp]');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,94 +0,0 @@
|
|
|
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
|
-
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
|
-
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 { applyOptionsChain } from '@modern-js/utils';
|
|
8
|
-
export function createToolsConfig(normalizedConfig) {
|
|
9
|
-
const {
|
|
10
|
-
disableCssExtract,
|
|
11
|
-
enableTsLoader
|
|
12
|
-
} = normalizedConfig.output;
|
|
13
|
-
const {
|
|
14
|
-
autoprefixer,
|
|
15
|
-
babel,
|
|
16
|
-
minifyCss,
|
|
17
|
-
terser,
|
|
18
|
-
webpack,
|
|
19
|
-
webpackChain,
|
|
20
|
-
tsLoader,
|
|
21
|
-
styledComponents,
|
|
22
|
-
sass,
|
|
23
|
-
postcss,
|
|
24
|
-
less,
|
|
25
|
-
htmlPlugin,
|
|
26
|
-
// TODO: remove modernjs tools.lodash config
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
-
lodash
|
|
29
|
-
} = normalizedConfig.tools;
|
|
30
|
-
const builderTsLoader = createBuilderTsLoader(tsLoader, enableTsLoader);
|
|
31
|
-
const builderTsChecker = createBuilderTsChecker(normalizedConfig.output);
|
|
32
|
-
return {
|
|
33
|
-
tsChecker: builderTsChecker,
|
|
34
|
-
styleLoader: disableCssExtract ? {} : undefined,
|
|
35
|
-
cssExtract: disableCssExtract ? false : undefined,
|
|
36
|
-
autoprefixer,
|
|
37
|
-
babel,
|
|
38
|
-
minifyCss,
|
|
39
|
-
terser,
|
|
40
|
-
webpack,
|
|
41
|
-
webpackChain: webpackChain,
|
|
42
|
-
tsLoader: builderTsLoader,
|
|
43
|
-
styledComponents: styledComponents,
|
|
44
|
-
sass: sass,
|
|
45
|
-
postcss: postcss,
|
|
46
|
-
less: less,
|
|
47
|
-
// can't remove comment in html minify.
|
|
48
|
-
// some html template insert by using those comments.
|
|
49
|
-
htmlPlugin: [config => _objectSpread(_objectSpread({}, config), {}, {
|
|
50
|
-
minify: typeof config.minify === 'object' ? _objectSpread(_objectSpread({}, config.minify), {}, {
|
|
51
|
-
removeComments: false
|
|
52
|
-
}) : config.minify
|
|
53
|
-
}), // eslint-disable-next-line no-nested-ternary
|
|
54
|
-
...(Array.isArray(htmlPlugin) ? htmlPlugin : htmlPlugin ? [htmlPlugin] : [])]
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
function createBuilderTsLoader(tsLoader, enableTsLoader) {
|
|
59
|
-
const useTsLoader = Boolean(enableTsLoader);
|
|
60
|
-
|
|
61
|
-
if (!useTsLoader) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const defaultTsLoader = {
|
|
66
|
-
compilerOptions: {
|
|
67
|
-
target: 'es5',
|
|
68
|
-
module: 'ESNext'
|
|
69
|
-
},
|
|
70
|
-
transpileOnly: false,
|
|
71
|
-
allowTsInNodeModules: true
|
|
72
|
-
};
|
|
73
|
-
return (_, utils) => applyOptionsChain(defaultTsLoader, tsLoader, utils);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function createBuilderTsChecker(output) {
|
|
77
|
-
if (output.enableTsLoader || output.disableTsChecker) {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
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
|
-
}
|