@modern-js/app-tools 2.40.0 → 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/cjs/analyze/getHtmlTemplate.js +5 -5
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +1 -1
- package/dist/cjs/defineConfig.js +8 -6
- package/dist/esm/analyze/getHtmlTemplate.js +5 -5
- package/dist/esm/builder/shared/bundlerPlugins/RouterPlugin.js +1 -1
- package/dist/esm/config/initialize/inits.js +19 -19
- package/dist/esm/defineConfig.js +1 -1
- package/dist/esm-node/analyze/getHtmlTemplate.js +5 -5
- package/dist/esm-node/builder/shared/bundlerPlugins/RouterPlugin.js +1 -1
- package/dist/esm-node/defineConfig.js +8 -6
- package/package.json +26 -26
@@ -63,7 +63,7 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
63
63
|
for (const entrypoint of entrypoints) {
|
64
64
|
const { entryName, isMainEntry } = entrypoint;
|
65
65
|
const name = entrypoints.length === 1 && isMainEntry ? "" : entryName;
|
66
|
-
const customIndexTemplate = findPartials(htmlDir, name,
|
66
|
+
const customIndexTemplate = findPartials(htmlDir, name, "index");
|
67
67
|
if (customIndexTemplate) {
|
68
68
|
htmlTemplates[entryName] = customIndexTemplate.file;
|
69
69
|
} else {
|
@@ -71,9 +71,9 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
71
71
|
const { partials } = await hookRunners.htmlPartials({
|
72
72
|
entrypoint,
|
73
73
|
partials: [
|
74
|
-
|
75
|
-
|
76
|
-
|
74
|
+
"top",
|
75
|
+
"head",
|
76
|
+
"body"
|
77
77
|
].reduce((previous, position) => {
|
78
78
|
const found = findPartials(htmlDir, name, position);
|
79
79
|
previous[position] = found ? [
|
@@ -90,7 +90,7 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
90
90
|
import_utils.fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
91
91
|
htmlTemplates[entryName] = templatePath;
|
92
92
|
partialsByEntrypoint[entryName] = partials;
|
93
|
-
const bottomTemplate = findPartials(htmlDir, name,
|
93
|
+
const bottomTemplate = findPartials(htmlDir, name, "bottom");
|
94
94
|
if (bottomTemplate) {
|
95
95
|
htmlTemplates[`__${entryName}-bottom__`] = bottomTemplate.content;
|
96
96
|
}
|
@@ -62,7 +62,7 @@ class RouterPlugin {
|
|
62
62
|
return;
|
63
63
|
}
|
64
64
|
const { webpack } = compiler;
|
65
|
-
const isRspack = webpack
|
65
|
+
const isRspack = "rspackVersion" in webpack;
|
66
66
|
const { Compilation, sources } = webpack;
|
67
67
|
const { RawSource } = sources;
|
68
68
|
const normalizePath = (path) => {
|
package/dist/cjs/defineConfig.js
CHANGED
@@ -23,12 +23,14 @@ __export(defineConfig_exports, {
|
|
23
23
|
});
|
24
24
|
module.exports = __toCommonJS(defineConfig_exports);
|
25
25
|
const defineConfig = (config) => config;
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
const defineLegacyConfig = (config) => {
|
27
|
+
var _config_autoLoadPlugins;
|
28
|
+
return {
|
29
|
+
...config,
|
30
|
+
legacy: true,
|
31
|
+
autoLoadPlugins: (_config_autoLoadPlugins = config.autoLoadPlugins) !== null && _config_autoLoadPlugins !== void 0 ? _config_autoLoadPlugins : true
|
32
|
+
};
|
33
|
+
};
|
32
34
|
// Annotate the CommonJS export names for ESM import in node:
|
33
35
|
0 && (module.exports = {
|
34
36
|
defineConfig,
|
@@ -59,7 +59,7 @@ var getHtmlTemplate = function() {
|
|
59
59
|
entrypoint = _step.value;
|
60
60
|
entryName = entrypoint.entryName, isMainEntry = entrypoint.isMainEntry;
|
61
61
|
name = entrypoints.length === 1 && isMainEntry ? "" : entryName;
|
62
|
-
customIndexTemplate = findPartials(htmlDir, name,
|
62
|
+
customIndexTemplate = findPartials(htmlDir, name, "index");
|
63
63
|
if (!customIndexTemplate)
|
64
64
|
return [
|
65
65
|
3,
|
@@ -77,9 +77,9 @@ var getHtmlTemplate = function() {
|
|
77
77
|
hookRunners.htmlPartials({
|
78
78
|
entrypoint,
|
79
79
|
partials: [
|
80
|
-
|
81
|
-
|
82
|
-
|
80
|
+
"top",
|
81
|
+
"head",
|
82
|
+
"body"
|
83
83
|
].reduce(function(previous, position) {
|
84
84
|
var found = findPartials(htmlDir, name, position);
|
85
85
|
previous[position] = found ? [
|
@@ -99,7 +99,7 @@ var getHtmlTemplate = function() {
|
|
99
99
|
fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
100
100
|
htmlTemplates[entryName] = templatePath;
|
101
101
|
partialsByEntrypoint[entryName] = partials;
|
102
|
-
bottomTemplate = findPartials(htmlDir, name,
|
102
|
+
bottomTemplate = findPartials(htmlDir, name, "bottom");
|
103
103
|
if (bottomTemplate) {
|
104
104
|
htmlTemplates["__".concat(entryName, "-bottom__")] = bottomTemplate.content;
|
105
105
|
}
|
@@ -80,7 +80,7 @@ var RouterPlugin = /* @__PURE__ */ function() {
|
|
80
80
|
return;
|
81
81
|
}
|
82
82
|
var webpack = compiler.webpack;
|
83
|
-
var isRspack = webpack
|
83
|
+
var isRspack = "rspackVersion" in webpack;
|
84
84
|
var Compilation = webpack.Compilation, sources = webpack.sources;
|
85
85
|
var RawSource = sources.RawSource;
|
86
86
|
var normalizePath = function(path) {
|
@@ -1,31 +1,31 @@
|
|
1
1
|
import path, { isAbsolute } from "path";
|
2
2
|
import { findExists } from "@modern-js/utils";
|
3
3
|
function initHtmlConfig(config, appContext) {
|
4
|
-
var
|
4
|
+
var ICON_EXTENSIONS = [
|
5
|
+
"png",
|
6
|
+
"jpg",
|
7
|
+
"jpeg",
|
8
|
+
"svg",
|
9
|
+
"ico"
|
10
|
+
];
|
11
|
+
config.html.appIcon = createBuilderAppIcon(config, appContext);
|
12
|
+
config.html.favicon = createBuilderFavicon(config, appContext);
|
13
|
+
return config.html;
|
14
|
+
function createBuilderAppIcon(config2, appContext2) {
|
5
15
|
var configDir = config2.source.configDir;
|
6
16
|
var appIcon = findExists(ICON_EXTENSIONS.map(function(ext) {
|
7
17
|
return path.resolve(appContext2.appDirectory, configDir || "./config", "icon.".concat(ext));
|
8
18
|
}));
|
9
19
|
return typeof appIcon === "string" ? appIcon : void 0;
|
10
|
-
}
|
11
|
-
|
20
|
+
}
|
21
|
+
function createBuilderFavicon(config2, appContext2) {
|
12
22
|
var configDir = config2.source.configDir;
|
13
23
|
var favicon = config2.html.favicon;
|
14
24
|
var defaultFavicon = findExists(ICON_EXTENSIONS.map(function(ext) {
|
15
25
|
return path.resolve(appContext2.appDirectory, configDir || "./config", "favicon.".concat(ext));
|
16
26
|
}));
|
17
27
|
return favicon || defaultFavicon || void 0;
|
18
|
-
}
|
19
|
-
var ICON_EXTENSIONS = [
|
20
|
-
"png",
|
21
|
-
"jpg",
|
22
|
-
"jpeg",
|
23
|
-
"svg",
|
24
|
-
"ico"
|
25
|
-
];
|
26
|
-
config.html.appIcon = createBuilderAppIcon(config, appContext);
|
27
|
-
config.html.favicon = createBuilderFavicon(config, appContext);
|
28
|
-
return config.html;
|
28
|
+
}
|
29
29
|
}
|
30
30
|
function initSourceConfig(config, appContext, bundler) {
|
31
31
|
config.source.include = createBuilderInclude(config, appContext);
|
@@ -50,11 +50,6 @@ function createBuilderInclude(config, appContext) {
|
|
50
50
|
return transformInclude;
|
51
51
|
}
|
52
52
|
function createBuilderModuleScope(config) {
|
53
|
-
var isPrimitiveScope = function isPrimitiveScope2(items) {
|
54
|
-
return items.every(function(item) {
|
55
|
-
return typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]";
|
56
|
-
});
|
57
|
-
};
|
58
53
|
var moduleScopes = config.source.moduleScopes;
|
59
54
|
if (moduleScopes) {
|
60
55
|
var DEFAULT_SCOPES = [
|
@@ -67,6 +62,11 @@ function createBuilderModuleScope(config) {
|
|
67
62
|
} else {
|
68
63
|
return void 0;
|
69
64
|
}
|
65
|
+
function isPrimitiveScope(items) {
|
66
|
+
return items.every(function(item) {
|
67
|
+
return typeof item === "string" || Object.prototype.toString.call(item) === "[object RegExp]";
|
68
|
+
});
|
69
|
+
}
|
70
70
|
function applyScopeOptions(defaults, options) {
|
71
71
|
if (Array.isArray(options)) {
|
72
72
|
if (isPrimitiveScope(options)) {
|
package/dist/esm/defineConfig.js
CHANGED
@@ -3,8 +3,8 @@ import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props";
|
|
3
3
|
var defineConfig = function(config) {
|
4
4
|
return config;
|
5
5
|
};
|
6
|
-
var _config_autoLoadPlugins;
|
7
6
|
var defineLegacyConfig = function(config) {
|
7
|
+
var _config_autoLoadPlugins;
|
8
8
|
return _object_spread_props(_object_spread({}, config), {
|
9
9
|
legacy: true,
|
10
10
|
autoLoadPlugins: (_config_autoLoadPlugins = config.autoLoadPlugins) !== null && _config_autoLoadPlugins !== void 0 ? _config_autoLoadPlugins : true
|
@@ -30,7 +30,7 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
30
30
|
for (const entrypoint of entrypoints) {
|
31
31
|
const { entryName, isMainEntry } = entrypoint;
|
32
32
|
const name = entrypoints.length === 1 && isMainEntry ? "" : entryName;
|
33
|
-
const customIndexTemplate = findPartials(htmlDir, name,
|
33
|
+
const customIndexTemplate = findPartials(htmlDir, name, "index");
|
34
34
|
if (customIndexTemplate) {
|
35
35
|
htmlTemplates[entryName] = customIndexTemplate.file;
|
36
36
|
} else {
|
@@ -38,9 +38,9 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
38
38
|
const { partials } = await hookRunners.htmlPartials({
|
39
39
|
entrypoint,
|
40
40
|
partials: [
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
"top",
|
42
|
+
"head",
|
43
|
+
"body"
|
44
44
|
].reduce((previous, position) => {
|
45
45
|
const found = findPartials(htmlDir, name, position);
|
46
46
|
previous[position] = found ? [
|
@@ -57,7 +57,7 @@ const getHtmlTemplate = async (entrypoints, api, { appContext, config }) => {
|
|
57
57
|
fs.outputFileSync(templatePath, templates.html(partials), "utf8");
|
58
58
|
htmlTemplates[entryName] = templatePath;
|
59
59
|
partialsByEntrypoint[entryName] = partials;
|
60
|
-
const bottomTemplate = findPartials(htmlDir, name,
|
60
|
+
const bottomTemplate = findPartials(htmlDir, name, "bottom");
|
61
61
|
if (bottomTemplate) {
|
62
62
|
htmlTemplates[`__${entryName}-bottom__`] = bottomTemplate.content;
|
63
63
|
}
|
@@ -39,7 +39,7 @@ class RouterPlugin {
|
|
39
39
|
return;
|
40
40
|
}
|
41
41
|
const { webpack } = compiler;
|
42
|
-
const isRspack = webpack
|
42
|
+
const isRspack = "rspackVersion" in webpack;
|
43
43
|
const { Compilation, sources } = webpack;
|
44
44
|
const { RawSource } = sources;
|
45
45
|
const normalizePath = (path) => {
|
@@ -1,10 +1,12 @@
|
|
1
1
|
const defineConfig = (config) => config;
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
const defineLegacyConfig = (config) => {
|
3
|
+
var _config_autoLoadPlugins;
|
4
|
+
return {
|
5
|
+
...config,
|
6
|
+
legacy: true,
|
7
|
+
autoLoadPlugins: (_config_autoLoadPlugins = config.autoLoadPlugins) !== null && _config_autoLoadPlugins !== void 0 ? _config_autoLoadPlugins : true
|
8
|
+
};
|
9
|
+
};
|
8
10
|
export {
|
9
11
|
defineConfig,
|
10
12
|
defineLegacyConfig
|
package/package.json
CHANGED
@@ -15,7 +15,7 @@
|
|
15
15
|
"modern",
|
16
16
|
"modern.js"
|
17
17
|
],
|
18
|
-
"version": "2.
|
18
|
+
"version": "2.41.0",
|
19
19
|
"jsnext:source": "./src/index.ts",
|
20
20
|
"types": "./dist/types/index.d.ts",
|
21
21
|
"main": "./dist/cjs/index.js",
|
@@ -71,40 +71,40 @@
|
|
71
71
|
"@babel/types": "^7.22.15",
|
72
72
|
"es-module-lexer": "^1.1.0",
|
73
73
|
"esbuild": "0.17.19",
|
74
|
-
"@swc/helpers": "0.5.
|
75
|
-
"@modern-js/builder": "2.
|
76
|
-
"@modern-js/builder-plugin-
|
77
|
-
"@modern-js/builder-plugin-
|
78
|
-
"@modern-js/builder-shared": "2.
|
79
|
-
"@modern-js/
|
80
|
-
"@modern-js/
|
81
|
-
"@modern-js/
|
82
|
-
"@modern-js/
|
83
|
-
"@modern-js/plugin": "2.
|
84
|
-
"@modern-js/plugin-i18n": "2.
|
85
|
-
"@modern-js/
|
86
|
-
"@modern-js/
|
87
|
-
"@modern-js/
|
88
|
-
"@modern-js/server": "2.
|
89
|
-
"@modern-js/types": "2.
|
90
|
-
"@modern-js/utils": "2.
|
91
|
-
"@modern-js/
|
92
|
-
"@modern-js/
|
74
|
+
"@swc/helpers": "0.5.3",
|
75
|
+
"@modern-js/builder": "2.41.0",
|
76
|
+
"@modern-js/builder-plugin-esbuild": "2.41.0",
|
77
|
+
"@modern-js/builder-plugin-node-polyfill": "2.41.0",
|
78
|
+
"@modern-js/builder-shared": "2.41.0",
|
79
|
+
"@modern-js/builder-webpack-provider": "2.41.0",
|
80
|
+
"@modern-js/new-action": "2.41.0",
|
81
|
+
"@modern-js/plugin": "2.41.0",
|
82
|
+
"@modern-js/core": "2.41.0",
|
83
|
+
"@modern-js/plugin-data-loader": "2.41.0",
|
84
|
+
"@modern-js/plugin-i18n": "2.41.0",
|
85
|
+
"@modern-js/node-bundle-require": "2.41.0",
|
86
|
+
"@modern-js/plugin-lint": "2.41.0",
|
87
|
+
"@modern-js/prod-server": "2.41.0",
|
88
|
+
"@modern-js/server": "2.41.0",
|
89
|
+
"@modern-js/types": "2.41.0",
|
90
|
+
"@modern-js/utils": "2.41.0",
|
91
|
+
"@modern-js/server-core": "2.41.0",
|
92
|
+
"@modern-js/upgrade": "2.41.0"
|
93
93
|
},
|
94
94
|
"devDependencies": {
|
95
|
-
"@types/babel__traverse": "
|
95
|
+
"@types/babel__traverse": "7.18.5",
|
96
96
|
"@types/jest": "^29",
|
97
97
|
"@types/node": "^14",
|
98
98
|
"jest": "^29",
|
99
99
|
"typescript": "^5",
|
100
100
|
"webpack": "^5.88.1",
|
101
|
-
"@modern-js/builder-
|
102
|
-
"@modern-js/builder-
|
103
|
-
"@scripts/
|
104
|
-
"@scripts/
|
101
|
+
"@modern-js/builder-rspack-provider": "2.41.0",
|
102
|
+
"@modern-js/builder-plugin-swc": "2.41.0",
|
103
|
+
"@scripts/jest-config": "2.41.0",
|
104
|
+
"@scripts/build": "2.41.0"
|
105
105
|
},
|
106
106
|
"peerDependencies": {
|
107
|
-
"@modern-js/builder-rspack-provider": "^2.
|
107
|
+
"@modern-js/builder-rspack-provider": "^2.41.0"
|
108
108
|
},
|
109
109
|
"peerDependenciesMeta": {
|
110
110
|
"@modern-js/builder-rspack-provider": {
|