@modern-js/app-tools 2.47.1 → 2.48.1
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/bin/modern.js +7 -1
- package/dist/cjs/builder/generator/index.js +3 -2
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +2 -1
- package/dist/cjs/builder/shared/builderPlugins/adapterWorker.js +49 -0
- package/dist/cjs/builder/shared/builderPlugins/index.js +3 -1
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -3
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +2 -5
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +1 -8
- package/dist/cjs/index.js +5 -5
- package/dist/esm/builder/generator/index.js +4 -3
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.js +2 -1
- package/dist/esm/builder/shared/builderPlugins/adapterWorker.js +41 -0
- package/dist/esm/builder/shared/builderPlugins/index.js +1 -0
- package/dist/esm/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +35 -43
- package/dist/esm/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +24 -32
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +240 -261
- package/dist/esm/index.js +20 -19
- package/dist/esm-node/builder/generator/index.js +3 -2
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.js +2 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterWorker.js +25 -0
- package/dist/esm-node/builder/shared/builderPlugins/index.js +1 -0
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +0 -3
- package/dist/esm-node/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +2 -5
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +1 -8
- package/dist/esm-node/index.js +6 -6
- package/dist/types/builder/shared/builderPlugins/adapterWorker.d.ts +2 -0
- package/dist/types/builder/shared/builderPlugins/index.d.ts +1 -0
- package/dist/types/config/legacy/index.d.ts +1 -1
- package/dist/types/defineConfig.d.ts +1 -1
- package/dist/types/types/config/index.d.ts +4 -3
- package/dist/types/types/config/tools.d.ts +5 -3
- package/dist/types/types/index.d.ts +2 -2
- package/package.json +21 -23
@@ -0,0 +1,25 @@
|
|
1
|
+
import { posix } from "path";
|
2
|
+
const getDistPath = (outputConfig, type) => {
|
3
|
+
const { distPath } = outputConfig;
|
4
|
+
const ret = distPath[type];
|
5
|
+
if (typeof ret !== "string") {
|
6
|
+
throw new Error(`unknown key ${type} in "output.distPath"`);
|
7
|
+
}
|
8
|
+
return ret;
|
9
|
+
};
|
10
|
+
const builderPluginAdapterWorker = () => ({
|
11
|
+
name: "builder-plugin-adapter-worker",
|
12
|
+
setup(api) {
|
13
|
+
api.modifyBundlerChain(async (chain, { isServiceWorker }) => {
|
14
|
+
const config = api.getNormalizedConfig();
|
15
|
+
if (isServiceWorker) {
|
16
|
+
const workerPath = getDistPath(config.output, "worker");
|
17
|
+
const filename = posix.join(workerPath, `[name].js`);
|
18
|
+
chain.output.filename(filename).chunkFilename(filename).libraryTarget("commonjs2");
|
19
|
+
}
|
20
|
+
});
|
21
|
+
}
|
22
|
+
});
|
23
|
+
export {
|
24
|
+
builderPluginAdapterWorker
|
25
|
+
};
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
2
1
|
class HtmlAsyncChunkPlugin {
|
3
2
|
apply(compiler) {
|
4
3
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
@@ -22,8 +21,6 @@ class HtmlAsyncChunkPlugin {
|
|
22
21
|
});
|
23
22
|
}
|
24
23
|
constructor(htmlWebpackPlugin) {
|
25
|
-
_define_property(this, "name", void 0);
|
26
|
-
_define_property(this, "htmlWebpackPlugin", void 0);
|
27
24
|
this.name = "HtmlAsyncChunkPlugin";
|
28
25
|
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
29
26
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
2
1
|
class BottomTemplatePlugin {
|
3
2
|
apply(compiler) {
|
4
3
|
compiler.hooks.compilation.tap(this.name, (compilation) => {
|
@@ -21,10 +20,8 @@ ${match}`);
|
|
21
20
|
});
|
22
21
|
}
|
23
22
|
constructor(htmlWebpackPlugin) {
|
24
|
-
|
25
|
-
|
26
|
-
_define_property(this, "bodyRegExp", /(<\/\s*body\s*>)/i);
|
27
|
-
_define_property(this, "name", void 0);
|
23
|
+
this.bottomTemplateReg = /<!--<\?-\s*bottomTemplate\s*\?>-->/;
|
24
|
+
this.bodyRegExp = /(<\/\s*body\s*>)/i;
|
28
25
|
this.htmlWebpackPlugin = htmlWebpackPlugin;
|
29
26
|
this.name = "bottom-template";
|
30
27
|
}
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import { _ as _define_property } from "@swc/helpers/_/_define_property";
|
2
1
|
import { createHash } from "crypto";
|
3
2
|
import { mergeWith } from "@modern-js/utils/lodash";
|
4
3
|
import { ROUTE_MANIFEST_FILE } from "@modern-js/utils";
|
@@ -206,13 +205,7 @@ class RouterPlugin {
|
|
206
205
|
});
|
207
206
|
}
|
208
207
|
constructor({ staticJsDir = "static/js", HtmlBundlerPlugin, enableInlineRouteManifests, disableFilenameHash = false, scriptLoading = "defer", nonce }) {
|
209
|
-
|
210
|
-
_define_property(this, "HtmlBundlerPlugin", void 0);
|
211
|
-
_define_property(this, "enableInlineRouteManifests", void 0);
|
212
|
-
_define_property(this, "staticJsDir", void 0);
|
213
|
-
_define_property(this, "disableFilenameHash", void 0);
|
214
|
-
_define_property(this, "scriptLoading", void 0);
|
215
|
-
_define_property(this, "nonce", void 0);
|
208
|
+
this.name = "RouterPlugin";
|
216
209
|
this.HtmlBundlerPlugin = HtmlBundlerPlugin;
|
217
210
|
this.enableInlineRouteManifests = enableInlineRouteManifests;
|
218
211
|
this.staticJsDir = staticJsDir;
|
package/dist/esm-node/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import path from "path";
|
2
2
|
import { lintPlugin } from "@modern-js/plugin-lint";
|
3
|
-
import { cleanRequireCache, emptyDir, getCommand, getArgv, fs, NESTED_ROUTE_SPEC_FILE } from "@modern-js/utils";
|
3
|
+
import { cleanRequireCache, emptyDir, getCommand, getArgv, fs, NESTED_ROUTE_SPEC_FILE, newAction, upgradeAction } from "@modern-js/utils";
|
4
4
|
import { castArray } from "@modern-js/utils/lodash";
|
5
5
|
import { getLocaleLanguage } from "@modern-js/plugin-i18n/language-detector";
|
6
6
|
import analyzePlugin from "./analyze";
|
@@ -123,18 +123,18 @@ const appTools = (options = {
|
|
123
123
|
process.exit(0);
|
124
124
|
});
|
125
125
|
program.command("new").usage("[options]").description(i18n.t(localeKeys.command.new.describe)).option("--config-file <configFile>", i18n.t(localeKeys.command.shared.config)).option("--lang <lang>", i18n.t(localeKeys.command.new.lang)).option("-c, --config <config>", i18n.t(localeKeys.command.new.config)).option("-d, --debug", i18n.t(localeKeys.command.new.debug), false).option("--dist-tag <tag>", i18n.t(localeKeys.command.new.distTag)).option("--registry", i18n.t(localeKeys.command.new.registry)).option("--no-need-install", i18n.t(localeKeys.command.shared.noNeedInstall)).action(async (options2) => {
|
126
|
-
|
127
|
-
await MWANewAction({
|
126
|
+
await newAction({
|
128
127
|
...options2,
|
129
128
|
locale: options2.lang || locale
|
130
|
-
});
|
129
|
+
}, "mwa");
|
131
130
|
});
|
132
131
|
program.command("inspect").description("inspect the internal configs").option(`--env <env>`, i18n.t(localeKeys.command.inspect.env), "development").option("--output <output>", i18n.t(localeKeys.command.inspect.output), "/").option("--verbose", i18n.t(localeKeys.command.inspect.verbose)).option("-c --config <config>", i18n.t(localeKeys.command.shared.config)).action(async (options2) => {
|
133
132
|
const { inspect } = await import("./commands/inspect");
|
134
133
|
inspect(api, options2);
|
135
134
|
});
|
136
|
-
|
137
|
-
|
135
|
+
program.command("upgrade").allowUnknownOption().option("-h --help", "Show help").action(async () => {
|
136
|
+
await upgradeAction();
|
137
|
+
});
|
138
138
|
},
|
139
139
|
async prepare() {
|
140
140
|
const command = getCommand();
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import type { AppLegacyNormalizedConfig, AppLegacyUserConfig, AppNormalizedConfig, AppUserConfig } from '../../types';
|
2
2
|
export declare function transformNormalizedConfig(config: AppLegacyNormalizedConfig): AppNormalizedConfig<'webpack'>;
|
3
|
-
export declare function checkIsLegacyConfig(config: AppLegacyUserConfig | AppUserConfig): config is AppLegacyUserConfig;
|
3
|
+
export declare function checkIsLegacyConfig(config: AppLegacyUserConfig | AppUserConfig<'shared'>): config is AppLegacyUserConfig;
|
@@ -4,7 +4,7 @@ import type { AppLegacyUserConfig, AppUserConfig } from './types';
|
|
4
4
|
* This function helps you to autocomplete configuration types.
|
5
5
|
* It accepts a direct config object, or a function that returns a config.
|
6
6
|
*/
|
7
|
-
export declare const defineConfig: <B extends "rspack" | "webpack" = "webpack">(config: UserConfigExport<AppUserConfig<
|
7
|
+
export declare const defineConfig: <B extends "rspack" | "webpack" = "webpack">(config: UserConfigExport<AppUserConfig<B>>) => UserConfigExport<AppUserConfig<B>>;
|
8
8
|
/**
|
9
9
|
* @deprecated Please use `defineConfig` instead.
|
10
10
|
* `defineLegacyConfig` will be removed in the future major version.
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import type { ServerUserConfig, BffUserConfig } from '@modern-js/server-core';
|
2
2
|
import type { UniBuilderPlugin } from '@modern-js/uni-builder';
|
3
|
+
import type { Bundler } from '../utils';
|
3
4
|
import type { OutputUserConfig } from './output';
|
4
5
|
import type { SourceUserConfig } from './source';
|
5
6
|
import type { TestingUserConfig } from './testing';
|
@@ -17,7 +18,7 @@ export interface RuntimeUserConfig {
|
|
17
18
|
export interface RuntimeByEntriesUserConfig {
|
18
19
|
[name: string]: RuntimeUserConfig;
|
19
20
|
}
|
20
|
-
export interface AppToolsUserConfig {
|
21
|
+
export interface AppToolsUserConfig<B extends Bundler> {
|
21
22
|
server?: ServerUserConfig;
|
22
23
|
source?: SourceUserConfig;
|
23
24
|
output?: OutputUserConfig;
|
@@ -33,7 +34,7 @@ export interface AppToolsUserConfig {
|
|
33
34
|
runtime?: RuntimeUserConfig;
|
34
35
|
runtimeByEntries?: RuntimeByEntriesUserConfig;
|
35
36
|
html?: HtmlUserConfig;
|
36
|
-
tools?: ToolsUserConfig
|
37
|
+
tools?: ToolsUserConfig<B>;
|
37
38
|
security?: SecurityUserConfig;
|
38
39
|
testing?: TestingUserConfig;
|
39
40
|
builderPlugins?: UniBuilderPlugin[];
|
@@ -44,4 +45,4 @@ interface SharedNormalizedConfig<RawConfig> {
|
|
44
45
|
cliOptions?: Record<string, any>;
|
45
46
|
_raw: RawConfig;
|
46
47
|
}
|
47
|
-
export type AppToolsNormalizedConfig<Config = AppToolsUserConfig
|
48
|
+
export type AppToolsNormalizedConfig<Config = AppToolsUserConfig<'shared'>> = Required<Config> & SharedNormalizedConfig<Config>;
|
@@ -2,9 +2,10 @@ import type { JestConfig } from '@modern-js/types';
|
|
2
2
|
import type { PluginSwcOptions } from '@rsbuild/plugin-swc';
|
3
3
|
import type { PluginEsbuildOptions } from '@rsbuild/plugin-esbuild';
|
4
4
|
import type { UniBuilderConfig } from '@modern-js/uni-builder';
|
5
|
-
import type { UnwrapBuilderConfig } from '../utils';
|
5
|
+
import type { UnwrapBuilderConfig, Bundler } from '../utils';
|
6
6
|
export type Tailwindcss = Record<string, any> | ((options: Record<string, any>) => Record<string, any> | void);
|
7
|
-
|
7
|
+
type BuilderToolsConfig = UnwrapBuilderConfig<UniBuilderConfig, 'tools'>;
|
8
|
+
export interface ToolsUserConfig<B extends Bundler = 'webpack'> extends Omit<BuilderToolsConfig, 'swc'> {
|
8
9
|
/**
|
9
10
|
* Used to custom Tailwind CSS configurations.
|
10
11
|
* @requires `tailwindcss` plugin.
|
@@ -25,7 +26,7 @@ export interface ToolsUserConfig extends UnwrapBuilderConfig<UniBuilderConfig, '
|
|
25
26
|
* The configuration of `swc` is provided by `swc` plugin.
|
26
27
|
* Please use `yarn new` or `pnpm new` to enable the corresponding capability.
|
27
28
|
*/
|
28
|
-
swc?: PluginSwcOptions<'outer'
|
29
|
+
swc?: B extends 'shared' ? undefined : B extends 'webpack' ? PluginSwcOptions<'outer'> : BuilderToolsConfig['swc'];
|
29
30
|
/**
|
30
31
|
* Used to custom Esbuild configurations.
|
31
32
|
* @requires `esbuild` plugin.
|
@@ -34,3 +35,4 @@ export interface ToolsUserConfig extends UnwrapBuilderConfig<UniBuilderConfig, '
|
|
34
35
|
*/
|
35
36
|
esbuild?: PluginEsbuildOptions;
|
36
37
|
}
|
38
|
+
export {};
|
@@ -12,8 +12,8 @@ export type { ServerUserConfig, ServerNormalizedConfig, BffUserConfig, BffNormal
|
|
12
12
|
export type { IAppContext, PluginAPI, CliPlugin, NormalizedConfig, UserConfig, } from '@modern-js/core';
|
13
13
|
export type AppTools<B extends Bundler = 'webpack'> = {
|
14
14
|
hooks: AppToolsHooks<B>;
|
15
|
-
userConfig: AppToolsUserConfig
|
16
|
-
normalizedConfig: AppToolsNormalizedConfig<AppToolsUserConfig
|
15
|
+
userConfig: AppToolsUserConfig<B>;
|
16
|
+
normalizedConfig: AppToolsNormalizedConfig<AppToolsUserConfig<'shared'>>;
|
17
17
|
};
|
18
18
|
export type LegacyAppTools = {
|
19
19
|
hooks: AppToolsHooks;
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.48.1",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -69,39 +69,37 @@
|
|
69
69
|
"@babel/parser": "^7.22.15",
|
70
70
|
"@babel/traverse": "^7.23.2",
|
71
71
|
"@babel/types": "^7.23.0",
|
72
|
-
"@rsbuild/plugin-esbuild": "0.4.
|
73
|
-
"@rsbuild/plugin-node-polyfill": "0.4.
|
74
|
-
"@rsbuild/shared": "0.4.
|
75
|
-
"@rsbuild/core": "0.4.
|
72
|
+
"@rsbuild/plugin-esbuild": "0.4.15",
|
73
|
+
"@rsbuild/plugin-node-polyfill": "0.4.15",
|
74
|
+
"@rsbuild/shared": "0.4.15",
|
75
|
+
"@rsbuild/core": "0.4.15",
|
76
76
|
"es-module-lexer": "^1.1.0",
|
77
77
|
"esbuild": "0.17.19",
|
78
78
|
"@swc/helpers": "0.5.3",
|
79
|
-
"@modern-js/uni-builder": "2.
|
80
|
-
"@modern-js/core": "2.
|
81
|
-
"@modern-js/
|
82
|
-
"@modern-js/
|
83
|
-
"@modern-js/plugin-data-loader": "2.
|
84
|
-
"@modern-js/
|
85
|
-
"@modern-js/plugin-i18n": "2.
|
86
|
-
"@modern-js/prod-server": "2.
|
87
|
-
"@modern-js/server": "2.
|
88
|
-
"@modern-js/server-utils": "2.
|
89
|
-
"@modern-js/
|
90
|
-
"@modern-js/
|
91
|
-
"@modern-js/
|
92
|
-
"@modern-js/utils": "2.47.1",
|
93
|
-
"@modern-js/server-core": "2.47.1"
|
79
|
+
"@modern-js/uni-builder": "2.48.1",
|
80
|
+
"@modern-js/core": "2.48.1",
|
81
|
+
"@modern-js/plugin": "2.48.1",
|
82
|
+
"@modern-js/node-bundle-require": "2.48.1",
|
83
|
+
"@modern-js/plugin-data-loader": "2.48.1",
|
84
|
+
"@modern-js/plugin-lint": "2.48.1",
|
85
|
+
"@modern-js/plugin-i18n": "2.48.1",
|
86
|
+
"@modern-js/prod-server": "2.48.1",
|
87
|
+
"@modern-js/server": "2.48.1",
|
88
|
+
"@modern-js/server-utils": "2.48.1",
|
89
|
+
"@modern-js/types": "2.48.1",
|
90
|
+
"@modern-js/utils": "2.48.1",
|
91
|
+
"@modern-js/server-core": "2.48.1"
|
94
92
|
},
|
95
93
|
"devDependencies": {
|
96
|
-
"@rsbuild/plugin-swc": "0.4.
|
94
|
+
"@rsbuild/plugin-swc": "0.4.15",
|
97
95
|
"@types/babel__traverse": "7.18.5",
|
98
96
|
"@types/jest": "^29",
|
99
97
|
"@types/node": "^14",
|
100
98
|
"jest": "^29",
|
101
99
|
"typescript": "^5",
|
102
100
|
"webpack": "^5.89.0",
|
103
|
-
"@scripts/build": "2.
|
104
|
-
"@scripts/jest-config": "2.
|
101
|
+
"@scripts/build": "2.48.1",
|
102
|
+
"@scripts/jest-config": "2.48.1"
|
105
103
|
},
|
106
104
|
"sideEffects": false,
|
107
105
|
"publishConfig": {
|