@modern-js/module-tools 2.39.2 → 2.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build.js +6 -4
- package/dist/builder/feature/style/lessAliasPlugin.js +3 -2
- package/dist/builder/index.d.ts +1 -1
- package/dist/builder/index.js +5 -5
- package/dist/cli.js +0 -8
- package/dist/config/normalize.d.ts +2 -3
- package/dist/config/normalize.js +2 -2
- package/dist/hooks/build.d.ts +2 -2
- package/dist/hooks/index.d.ts +2 -1
- package/dist/hooks/misc.d.ts +5 -0
- package/dist/hooks/misc.js +4 -0
- package/lib/types.d.ts +0 -36
- package/package.json +19 -19
- package/dist/config/legacySchema.d.ts +0 -649
- package/dist/config/legacySchema.js +0 -288
- package/dist/config/schema.d.ts +0 -889
- package/dist/config/schema.js +0 -360
package/dist/build.js
CHANGED
|
@@ -39,21 +39,23 @@ const build = async (api, options, context) => {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
const runner = api.useHookRunners();
|
|
42
|
+
const resolvedConfig = await runner.resolveModuleUserConfig(api.useConfigContext());
|
|
43
|
+
(0, import_debug.debug)("resolvedConfig", resolvedConfig);
|
|
42
44
|
(0, import_debug.debug)("normalize build config");
|
|
43
45
|
const { normalizeBuildConfig } = await Promise.resolve().then(() => __toESM(require("./config/normalize")));
|
|
44
|
-
const
|
|
46
|
+
const normalizedBuildConfig = await normalizeBuildConfig(resolvedConfig, context, options);
|
|
45
47
|
(0, import_debug.debug)("normalize build config done");
|
|
46
|
-
(0, import_debug.debug)("normalizedBuildConfig",
|
|
48
|
+
(0, import_debug.debug)("normalizedBuildConfig", normalizedBuildConfig);
|
|
47
49
|
(0, import_debug.debug)("run beforeBuild hooks");
|
|
48
50
|
await runner.beforeBuild({
|
|
49
|
-
config:
|
|
51
|
+
config: normalizedBuildConfig,
|
|
50
52
|
cliOptions: options
|
|
51
53
|
});
|
|
52
54
|
(0, import_debug.debug)("run beforeBuild hooks done");
|
|
53
55
|
const builder = await Promise.resolve().then(() => __toESM(require("./builder")));
|
|
54
56
|
await builder.run({
|
|
55
57
|
cmdOptions: options,
|
|
56
|
-
|
|
58
|
+
normalizedBuildConfig,
|
|
57
59
|
context
|
|
58
60
|
}, api);
|
|
59
61
|
};
|
|
@@ -34,7 +34,8 @@ module.exports = __toCommonJS(lessAliasPlugin_exports);
|
|
|
34
34
|
var import_define_property = require("@swc/helpers/_/_define_property");
|
|
35
35
|
var import_fs = __toESM(require("fs"));
|
|
36
36
|
var import_utils = require("./utils");
|
|
37
|
-
|
|
37
|
+
var LessAliasesPlugin;
|
|
38
|
+
LessAliasesPlugin = class LessAliasesPlugin2 {
|
|
38
39
|
install(less, pluginManager) {
|
|
39
40
|
const getResolve = (filename, currentDirectory) => {
|
|
40
41
|
return this.compiler.css_resolve(filename, currentDirectory || this.stdinDir);
|
|
@@ -67,4 +68,4 @@ class LessAliasesPlugin {
|
|
|
67
68
|
this.compiler = options.compiler;
|
|
68
69
|
this.stdinDir = options.stdinDir;
|
|
69
70
|
}
|
|
70
|
-
}
|
|
71
|
+
};
|
package/dist/builder/index.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import type { ModuleContext } from '../types/context';
|
|
|
3
3
|
import type { BuildCommandOptions, BaseBuildConfig, ModuleTools } from '../types';
|
|
4
4
|
export declare const run: (options: {
|
|
5
5
|
cmdOptions: BuildCommandOptions;
|
|
6
|
-
|
|
6
|
+
normalizedBuildConfig: BaseBuildConfig[];
|
|
7
7
|
context: ModuleContext;
|
|
8
8
|
}, api: PluginAPI<ModuleTools>) => Promise<void>;
|
package/dist/builder/index.js
CHANGED
|
@@ -38,15 +38,15 @@ var import_debug = require("../debug");
|
|
|
38
38
|
var import_build = require("./build");
|
|
39
39
|
var import_clear = require("./clear");
|
|
40
40
|
const run = async (options, api) => {
|
|
41
|
-
const {
|
|
41
|
+
const { normalizedBuildConfig, context, cmdOptions } = options;
|
|
42
42
|
const { watch, clear } = cmdOptions;
|
|
43
43
|
const runner = api.useHookRunners();
|
|
44
44
|
let totalDuration = 0;
|
|
45
|
-
if (
|
|
45
|
+
if (normalizedBuildConfig.length !== 0) {
|
|
46
46
|
totalDuration = Date.now();
|
|
47
47
|
if (clear) {
|
|
48
48
|
(0, import_debug.debug)("clear output paths");
|
|
49
|
-
await (0, import_clear.clearBuildConfigPaths)(
|
|
49
|
+
await (0, import_clear.clearBuildConfigPaths)(normalizedBuildConfig, context.appDirectory);
|
|
50
50
|
(0, import_debug.debug)("clear output paths done");
|
|
51
51
|
}
|
|
52
52
|
await (0, import_clear.clearDtsTemp)();
|
|
@@ -54,7 +54,7 @@ const run = async (options, api) => {
|
|
|
54
54
|
import_utils.logger.info("Start build in watch mode...");
|
|
55
55
|
}
|
|
56
56
|
try {
|
|
57
|
-
await (0, import_p_map.default)(
|
|
57
|
+
await (0, import_p_map.default)(normalizedBuildConfig, async (config) => {
|
|
58
58
|
(0, import_debug.debug)("run beforeBuildTask hooks");
|
|
59
59
|
const buildConfig = await runner.beforeBuildTask(config);
|
|
60
60
|
(0, import_debug.debug)("run beforeBuildTask hooks done");
|
|
@@ -92,7 +92,7 @@ const run = async (options, api) => {
|
|
|
92
92
|
(0, import_debug.debug)("run afterBuild hooks");
|
|
93
93
|
await runner.afterBuild({
|
|
94
94
|
status: "success",
|
|
95
|
-
config:
|
|
95
|
+
config: normalizedBuildConfig,
|
|
96
96
|
commandOptions: cmdOptions,
|
|
97
97
|
totalDuration
|
|
98
98
|
});
|
package/dist/cli.js
CHANGED
|
@@ -35,10 +35,7 @@ var import_utils = require("@modern-js/utils");
|
|
|
35
35
|
var import_hooks = require("./hooks");
|
|
36
36
|
var import_plugins = require("./plugins");
|
|
37
37
|
var import_command = require("./command");
|
|
38
|
-
var import_merge = require("./config/merge");
|
|
39
38
|
var import_onExit = require("./utils/onExit");
|
|
40
|
-
var import_legacySchema = require("./config/legacySchema");
|
|
41
|
-
var import_schema = require("./config/schema");
|
|
42
39
|
const moduleTools = () => ({
|
|
43
40
|
name: "@modern-js/module-tools",
|
|
44
41
|
registerHook: import_hooks.registerHook,
|
|
@@ -67,13 +64,8 @@ const setup = async (api) => {
|
|
|
67
64
|
await hookRunners.afterDev();
|
|
68
65
|
});
|
|
69
66
|
};
|
|
70
|
-
const validateSchema = async () => {
|
|
71
|
-
const userConfig = api.useConfigContext();
|
|
72
|
-
return (0, import_merge.isLegacyUserConfig)(userConfig) ? import_legacySchema.legacySchema : import_schema.schema;
|
|
73
|
-
};
|
|
74
67
|
return {
|
|
75
68
|
prepare,
|
|
76
|
-
validateSchema,
|
|
77
69
|
async commands({ program }) {
|
|
78
70
|
await (0, import_command.buildCommand)(program, api);
|
|
79
71
|
await (0, import_command.devCommand)(program, api);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { BaseBuildConfig, BuildPreset, PartialBuildConfig, PartialBaseBuildConfig, ModuleContext, BuildCommandOptions, ModuleTools } from '../types';
|
|
1
|
+
import type { ModuleUserConfig, BaseBuildConfig, BuildPreset, PartialBuildConfig, PartialBaseBuildConfig, ModuleContext, BuildCommandOptions } from '../types';
|
|
3
2
|
export declare const presetToConfig: (preset?: BuildPreset) => Promise<PartialBaseBuildConfig[] | undefined>;
|
|
4
3
|
export declare const mergeConfig: (low?: PartialBaseBuildConfig[], high?: PartialBuildConfig) => PartialBaseBuildConfig[];
|
|
5
|
-
export declare const normalizeBuildConfig: (
|
|
4
|
+
export declare const normalizeBuildConfig: (resolvedConfig: ModuleUserConfig, context: ModuleContext, buildCmdOptions: BuildCommandOptions) => Promise<BaseBuildConfig[]>;
|
|
6
5
|
export declare const transformToAbsPath: (baseConfig: BaseBuildConfig, options: {
|
|
7
6
|
context: ModuleContext;
|
|
8
7
|
buildCmdOptions: BuildCommandOptions;
|
package/dist/config/normalize.js
CHANGED
|
@@ -74,8 +74,8 @@ const mergeConfig = (low, high = {}) => {
|
|
|
74
74
|
return import_lodash.default.merge(config, high);
|
|
75
75
|
});
|
|
76
76
|
};
|
|
77
|
-
const normalizeBuildConfig = async (
|
|
78
|
-
let config =
|
|
77
|
+
const normalizeBuildConfig = async (resolvedConfig, context, buildCmdOptions) => {
|
|
78
|
+
let config = resolvedConfig;
|
|
79
79
|
if ((0, import_merge.isLegacyUserConfig)(config)) {
|
|
80
80
|
const { createUserConfigFromLegacy } = await Promise.resolve().then(() => __toESM(require("./transformLegacyConfig")));
|
|
81
81
|
config = await createUserConfigFromLegacy(config);
|
package/dist/hooks/build.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { RegisterBuildPlatformResult } from '@modern-js/core';
|
|
2
2
|
import { BuildCommandOptions } from '../types';
|
|
3
|
-
import type { BuildTaskResult, BuildResult, BuildPlatformResult, WatchDtsHookContext, WatchJsHookContext,
|
|
3
|
+
import type { BuildTaskResult, BuildResult, BuildPlatformResult, WatchDtsHookContext, WatchJsHookContext, BaseBuildConfig } from '../types';
|
|
4
4
|
export declare const buildHooks: {
|
|
5
5
|
beforeBuild: import("@modern-js/plugin").ParallelWorkflow<{
|
|
6
|
-
config:
|
|
6
|
+
config: BaseBuildConfig[];
|
|
7
7
|
cliOptions: BuildCommandOptions;
|
|
8
8
|
}, void>;
|
|
9
9
|
beforeBuildTask: import("@modern-js/plugin").AsyncWaterfall<BaseBuildConfig>;
|
package/dist/hooks/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export declare const registerHook: {
|
|
|
2
2
|
buildWatchJs: import("@modern-js/plugin").ParallelWorkflow<import("..").WatchJsHookContext, void>;
|
|
3
3
|
buildWatchDts: import("@modern-js/plugin").ParallelWorkflow<import("..").WatchDtsHookContext, void>;
|
|
4
4
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
5
|
+
resolveModuleUserConfig: import("@modern-js/plugin").AsyncWaterfall<import("..").ModuleUserConfig>;
|
|
5
6
|
modifyLibuild: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
|
|
6
7
|
registerDev: import("@modern-js/plugin").ParallelWorkflow<void, import("..").DevToolData>;
|
|
7
8
|
beforeDev: import("@modern-js/plugin").ParallelWorkflow<import("..").DevToolData[], void>;
|
|
@@ -14,7 +15,7 @@ export declare const registerHook: {
|
|
|
14
15
|
afterDev: import("@modern-js/plugin").ParallelWorkflow<void, void>;
|
|
15
16
|
noDevTools: import("@modern-js/plugin").AsyncWaterfall<string>;
|
|
16
17
|
beforeBuild: import("@modern-js/plugin").ParallelWorkflow<{
|
|
17
|
-
config: import("..").
|
|
18
|
+
config: import("..").BaseBuildConfig[];
|
|
18
19
|
cliOptions: import("..").BuildCommandOptions;
|
|
19
20
|
}, void>;
|
|
20
21
|
beforeBuildTask: import("@modern-js/plugin").AsyncWaterfall<import("..").BaseBuildConfig>;
|
package/dist/hooks/misc.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
import { ModuleUserConfig } from '../types';
|
|
1
2
|
export declare const miscHooks: {
|
|
2
3
|
addRuntimeExports: import("@modern-js/plugin").AsyncWaterfall<void>;
|
|
4
|
+
/**
|
|
5
|
+
* Change user configuration
|
|
6
|
+
*/
|
|
7
|
+
resolveModuleUserConfig: import("@modern-js/plugin").AsyncWaterfall<ModuleUserConfig>;
|
|
3
8
|
/**
|
|
4
9
|
* @deprecated
|
|
5
10
|
* use buildConfig.hooks and buildConfig.esbuildOptions instead.
|
package/dist/hooks/misc.js
CHANGED
|
@@ -25,6 +25,10 @@ var import_plugin = require("@modern-js/plugin");
|
|
|
25
25
|
const miscHooks = {
|
|
26
26
|
addRuntimeExports: (0, import_plugin.createAsyncWaterfall)(),
|
|
27
27
|
/**
|
|
28
|
+
* Change user configuration
|
|
29
|
+
*/
|
|
30
|
+
resolveModuleUserConfig: (0, import_plugin.createAsyncWaterfall)(),
|
|
31
|
+
/**
|
|
28
32
|
* @deprecated
|
|
29
33
|
* use buildConfig.hooks and buildConfig.esbuildOptions instead.
|
|
30
34
|
*/
|
package/lib/types.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="react" />
|
|
3
|
-
/// <reference types="react-dom" />
|
|
4
2
|
|
|
5
3
|
declare namespace NodeJS {
|
|
6
4
|
interface ProcessEnv {
|
|
@@ -9,11 +7,6 @@ declare namespace NodeJS {
|
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
9
|
|
|
12
|
-
declare module '*.bmp' {
|
|
13
|
-
const src: string;
|
|
14
|
-
export default src;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
10
|
declare module '*.gif' {
|
|
18
11
|
const src: string;
|
|
19
12
|
export default src;
|
|
@@ -34,10 +27,6 @@ declare module '*.png' {
|
|
|
34
27
|
export default src;
|
|
35
28
|
}
|
|
36
29
|
|
|
37
|
-
declare module '*.ico' {
|
|
38
|
-
const src: string;
|
|
39
|
-
export default src;
|
|
40
|
-
}
|
|
41
30
|
|
|
42
31
|
declare module '*.webp' {
|
|
43
32
|
const src: string;
|
|
@@ -89,29 +78,4 @@ declare module '*.module.sass' {
|
|
|
89
78
|
export default classes;
|
|
90
79
|
}
|
|
91
80
|
|
|
92
|
-
declare module '*.md' {
|
|
93
|
-
const src: string;
|
|
94
|
-
export default src;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
declare module '*.hbs' {
|
|
98
|
-
const src: string;
|
|
99
|
-
export default src;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
declare module '*.yaml' {
|
|
103
|
-
const src: string;
|
|
104
|
-
export default src;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
declare module '*.toml' {
|
|
108
|
-
const src: string;
|
|
109
|
-
export default src;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
declare module '*.xml' {
|
|
113
|
-
const src: string;
|
|
114
|
-
export default src;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
81
|
declare module '@modern-js/runtime/*' {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modern-js/module-tools",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.41.0",
|
|
4
4
|
"description": "Simple, powerful, high-performance modern npm package development solution.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"modern",
|
|
@@ -50,18 +50,18 @@
|
|
|
50
50
|
"@ast-grep/napi": "0.12.0",
|
|
51
51
|
"@babel/generator": "^7.22.15",
|
|
52
52
|
"@babel/parser": "^7.22.15",
|
|
53
|
-
"@babel/traverse": "7.23.2",
|
|
53
|
+
"@babel/traverse": "^7.23.2",
|
|
54
54
|
"@babel/types": "^7.22.15",
|
|
55
|
-
"@modern-js/swc-plugins": "0.6.
|
|
55
|
+
"@modern-js/swc-plugins": "0.6.5",
|
|
56
56
|
"@rollup/pluginutils": "4.1.1",
|
|
57
57
|
"@svgr/core": "8.0.0",
|
|
58
58
|
"@svgr/plugin-jsx": "8.0.1",
|
|
59
59
|
"@svgr/plugin-svgo": "8.0.1",
|
|
60
|
-
"@swc/helpers": "0.5.
|
|
60
|
+
"@swc/helpers": "0.5.3",
|
|
61
61
|
"convert-source-map": "1.8.0",
|
|
62
|
-
"enhanced-resolve": "5.
|
|
62
|
+
"enhanced-resolve": "5.12.0",
|
|
63
63
|
"esbuild": "0.19.2",
|
|
64
|
-
"magic-string": "0.
|
|
64
|
+
"magic-string": "0.30.5",
|
|
65
65
|
"postcss": "8.4.31",
|
|
66
66
|
"postcss-modules": "4.3.0",
|
|
67
67
|
"safe-identifier": "0.4.2",
|
|
@@ -71,15 +71,15 @@
|
|
|
71
71
|
"tapable": "2.2.1",
|
|
72
72
|
"terser": "5.19.2",
|
|
73
73
|
"tsconfig-paths-webpack-plugin": "4.1.0",
|
|
74
|
-
"@modern-js/
|
|
75
|
-
"@modern-js/
|
|
76
|
-
"@modern-js/
|
|
77
|
-
"@modern-js/plugin
|
|
78
|
-
"@modern-js/plugin-
|
|
79
|
-
"@modern-js/
|
|
80
|
-
"@modern-js/
|
|
81
|
-
"@modern-js/
|
|
82
|
-
"@modern-js/
|
|
74
|
+
"@modern-js/new-action": "2.41.0",
|
|
75
|
+
"@modern-js/core": "2.41.0",
|
|
76
|
+
"@modern-js/plugin-changeset": "2.41.0",
|
|
77
|
+
"@modern-js/plugin": "2.41.0",
|
|
78
|
+
"@modern-js/plugin-i18n": "2.41.0",
|
|
79
|
+
"@modern-js/plugin-lint": "2.41.0",
|
|
80
|
+
"@modern-js/types": "2.41.0",
|
|
81
|
+
"@modern-js/utils": "2.41.0",
|
|
82
|
+
"@modern-js/upgrade": "2.41.0"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@types/babel__generator": "7.6.4",
|
|
@@ -87,10 +87,10 @@
|
|
|
87
87
|
"@types/convert-source-map": "1.5.2",
|
|
88
88
|
"@types/node": "^14",
|
|
89
89
|
"typescript": "^5",
|
|
90
|
-
"@modern-js/builder-webpack-provider": "2.
|
|
91
|
-
"@modern-js/self": "npm:@modern-js/module-tools@2.
|
|
92
|
-
"@scripts/vitest-config": "2.
|
|
93
|
-
"@scripts/build": "2.
|
|
90
|
+
"@modern-js/builder-webpack-provider": "2.41.0",
|
|
91
|
+
"@modern-js/self": "npm:@modern-js/module-tools@2.41.0",
|
|
92
|
+
"@scripts/vitest-config": "2.41.0",
|
|
93
|
+
"@scripts/build": "2.41.0"
|
|
94
94
|
},
|
|
95
95
|
"peerDependencies": {
|
|
96
96
|
"typescript": "^4 || ^5"
|