@modern-js/app-tools 1.21.5 → 2.0.0-beta.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/CHANGELOG.md +319 -51
- package/dist/js/modern/analyze/constants.js +1 -0
- package/dist/js/modern/analyze/generateCode.js +126 -32
- package/dist/js/modern/analyze/getBundleEntry.js +7 -14
- package/dist/js/modern/analyze/getClientRoutes/getRoutes.js +173 -0
- package/dist/js/modern/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +13 -58
- package/dist/js/modern/analyze/getClientRoutes/index.js +2 -0
- package/dist/js/modern/analyze/getClientRoutes/utils.js +18 -0
- package/dist/js/modern/analyze/getFileSystemEntry.js +27 -21
- package/dist/js/modern/analyze/getHtmlTemplate.js +2 -9
- package/dist/js/modern/analyze/getServerRoutes.js +15 -32
- package/dist/js/modern/analyze/index.js +81 -23
- 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 +102 -0
- package/dist/js/modern/analyze/templates.js +151 -12
- package/dist/js/modern/analyze/utils.js +2 -8
- package/dist/js/modern/builder/builderPlugins/compatModern.js +208 -0
- package/dist/js/modern/builder/createHtmlConfig.js +58 -0
- package/dist/js/modern/builder/createOutputConfig.js +70 -0
- package/dist/js/modern/builder/createSourceConfig.js +74 -0
- package/dist/js/modern/builder/createToolsConfig.js +87 -0
- package/dist/js/modern/builder/index.js +108 -0
- package/dist/js/modern/builder/share.js +44 -0
- package/dist/js/modern/builder/webpackPlugins/htmlAsyncChunkPlugin.js +29 -0
- package/dist/js/modern/builder/webpackPlugins/htmlBottomTemplate.js +33 -0
- package/dist/js/modern/builder/webpackPlugins/routerPlugin.js +97 -0
- package/dist/js/modern/commands/build.js +16 -110
- package/dist/js/modern/commands/dev.js +12 -28
- package/dist/js/modern/commands/inspect.js +8 -66
- package/dist/js/modern/commands/start.js +2 -3
- package/dist/js/modern/index.js +17 -16
- package/dist/js/modern/locale/en.js +0 -1
- package/dist/js/modern/locale/zh.js +0 -1
- package/dist/js/modern/utils/commands.js +5 -0
- package/dist/js/modern/utils/config.js +1 -12
- package/dist/js/modern/utils/createServer.js +12 -1
- package/dist/js/modern/utils/getSpecifiedEntries.js +0 -6
- package/dist/js/modern/utils/printInstructions.js +3 -2
- package/dist/js/modern/utils/routes.js +0 -2
- package/dist/js/node/analyze/constants.js +3 -1
- package/dist/js/node/analyze/generateCode.js +123 -47
- package/dist/js/node/analyze/getBundleEntry.js +7 -20
- package/dist/js/node/analyze/getClientRoutes/getRoutes.js +181 -0
- package/dist/js/node/analyze/{getClientRoutes.js → getClientRoutes/getRoutesLegacy.js} +19 -78
- package/dist/js/node/analyze/getClientRoutes/index.js +19 -0
- package/dist/js/node/analyze/getClientRoutes/utils.js +28 -0
- package/dist/js/node/analyze/getFileSystemEntry.js +26 -28
- package/dist/js/node/analyze/getHtmlTemplate.js +2 -23
- package/dist/js/node/analyze/getServerRoutes.js +14 -40
- package/dist/js/node/analyze/index.js +81 -33
- 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 +111 -0
- package/dist/js/node/analyze/templates.js +153 -21
- package/dist/js/node/analyze/utils.js +4 -20
- package/dist/js/node/builder/builderPlugins/compatModern.js +216 -0
- package/dist/js/node/builder/createHtmlConfig.js +68 -0
- package/dist/js/node/builder/createOutputConfig.js +76 -0
- package/dist/js/node/builder/createSourceConfig.js +82 -0
- package/dist/js/node/builder/createToolsConfig.js +94 -0
- package/dist/js/node/builder/index.js +117 -0
- package/dist/js/node/builder/share.js +51 -0
- package/dist/js/node/builder/webpackPlugins/htmlAsyncChunkPlugin.js +36 -0
- package/dist/js/node/builder/webpackPlugins/htmlBottomTemplate.js +40 -0
- package/dist/js/node/builder/webpackPlugins/routerPlugin.js +105 -0
- package/dist/js/node/commands/build.js +14 -121
- package/dist/js/node/commands/deploy.js +0 -2
- package/dist/js/node/commands/dev.js +10 -44
- package/dist/js/node/commands/index.js +0 -6
- package/dist/js/node/commands/inspect.js +10 -90
- package/dist/js/node/commands/start.js +2 -11
- package/dist/js/node/exports/server.js +0 -1
- package/dist/js/node/hooks.js +0 -2
- package/dist/js/node/index.js +22 -32
- package/dist/js/node/locale/en.js +0 -1
- package/dist/js/node/locale/index.js +0 -4
- package/dist/js/node/locale/zh.js +0 -1
- package/dist/js/node/utils/commands.js +12 -0
- package/dist/js/node/utils/config.js +1 -25
- package/dist/js/node/utils/createServer.js +15 -11
- 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 +3 -6
- package/dist/js/node/utils/routes.js +0 -5
- package/dist/js/treeshaking/analyze/constants.js +16 -0
- package/dist/js/treeshaking/analyze/generateCode.js +369 -0
- package/dist/js/treeshaking/analyze/getBundleEntry.js +69 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutes.js +184 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/getRoutesLegacy.js +185 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/index.js +2 -0
- package/dist/js/treeshaking/analyze/getClientRoutes/utils.js +24 -0
- package/dist/js/treeshaking/analyze/getFileSystemEntry.js +96 -0
- package/dist/js/treeshaking/analyze/getHtmlTemplate.js +129 -0
- package/dist/js/treeshaking/analyze/getServerRoutes.js +157 -0
- package/dist/js/treeshaking/analyze/index.js +334 -0
- package/dist/js/treeshaking/analyze/isDefaultExportFunction.js +28 -0
- package/dist/js/treeshaking/analyze/makeLegalIdentifier.js +16 -0
- package/dist/js/treeshaking/analyze/nestedRoutes.js +165 -0
- package/dist/js/treeshaking/analyze/templates.js +170 -0
- package/dist/js/treeshaking/analyze/utils.js +88 -0
- package/dist/js/treeshaking/builder/builderPlugins/compatModern.js +212 -0
- package/dist/js/treeshaking/builder/createHtmlConfig.js +59 -0
- package/dist/js/treeshaking/builder/createOutputConfig.js +70 -0
- package/dist/js/treeshaking/builder/createSourceConfig.js +88 -0
- package/dist/js/treeshaking/builder/createToolsConfig.js +85 -0
- package/dist/js/treeshaking/builder/index.js +161 -0
- package/dist/js/treeshaking/builder/share.js +46 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlAsyncChunkPlugin.js +46 -0
- package/dist/js/treeshaking/builder/webpackPlugins/htmlBottomTemplate.js +41 -0
- package/dist/js/treeshaking/builder/webpackPlugins/routerPlugin.js +121 -0
- package/dist/js/treeshaking/commands/build.js +83 -0
- package/dist/js/treeshaking/commands/deploy.js +26 -0
- package/dist/js/treeshaking/commands/dev.js +124 -0
- package/dist/js/treeshaking/commands/index.js +3 -0
- package/dist/js/treeshaking/commands/inspect.js +29 -0
- package/dist/js/treeshaking/commands/start.js +69 -0
- package/dist/js/treeshaking/exports/server.js +1 -0
- package/dist/js/treeshaking/hooks.js +21 -0
- package/dist/js/treeshaking/index.js +267 -0
- package/dist/js/treeshaking/locale/en.js +34 -0
- package/dist/js/treeshaking/locale/index.js +9 -0
- package/dist/js/treeshaking/locale/zh.js +34 -0
- package/dist/js/treeshaking/utils/commands.js +5 -0
- package/dist/js/treeshaking/utils/config.js +124 -0
- package/dist/js/treeshaking/utils/createServer.js +73 -0
- package/dist/js/treeshaking/utils/getSpecifiedEntries.js +58 -0
- package/dist/js/treeshaking/utils/language.js +5 -0
- package/dist/js/treeshaking/utils/printInstructions.js +30 -0
- package/dist/js/treeshaking/utils/routes.js +29 -0
- package/dist/js/treeshaking/utils/types.js +0 -0
- package/dist/types/analyze/constants.d.ts +1 -0
- package/dist/types/analyze/generateCode.d.ts +1 -1
- package/dist/types/analyze/{getClientRoutes.d.ts → getClientRoutes/getRoutes.d.ts} +2 -7
- package/dist/types/analyze/getClientRoutes/getRoutesLegacy.d.ts +15 -0
- package/dist/types/analyze/getClientRoutes/index.d.ts +2 -0
- package/dist/types/analyze/getClientRoutes/utils.d.ts +5 -0
- package/dist/types/analyze/index.d.ts +4 -5
- package/dist/types/analyze/nestedRoutes.d.ts +5 -0
- package/dist/types/analyze/templates.d.ts +19 -3
- package/dist/types/analyze/utils.d.ts +2 -1
- package/dist/types/builder/builderPlugins/compatModern.d.ts +13 -0
- package/dist/types/builder/createHtmlConfig.d.ts +6 -0
- package/dist/types/builder/createOutputConfig.d.ts +3 -0
- package/dist/types/builder/createSourceConfig.d.ts +5 -0
- package/dist/types/builder/createToolsConfig.d.ts +13 -0
- package/dist/types/builder/index.d.ts +15 -0
- package/dist/types/builder/share.d.ts +26 -0
- package/dist/types/builder/webpackPlugins/htmlAsyncChunkPlugin.d.ts +8 -0
- package/dist/types/builder/webpackPlugins/htmlBottomTemplate.d.ts +10 -0
- package/dist/types/builder/webpackPlugins/routerPlugin.d.ts +10 -0
- package/dist/types/commands/build.d.ts +2 -1
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/commands/dev.d.ts +2 -1
- package/dist/types/commands/inspect.d.ts +2 -6
- package/dist/types/commands/start.d.ts +2 -1
- package/dist/types/hooks.d.ts +15 -10
- package/dist/types/index.d.ts +4 -4
- package/dist/types/locale/en.d.ts +0 -1
- package/dist/types/locale/index.d.ts +0 -2
- package/dist/types/locale/zh.d.ts +0 -1
- package/dist/types/utils/commands.d.ts +1 -0
- package/dist/types/utils/config.d.ts +0 -1
- package/dist/types/utils/createServer.d.ts +8 -1
- package/dist/types/utils/printInstructions.d.ts +3 -2
- package/dist/types/utils/types.d.ts +2 -3
- package/package.json +25 -42
- package/dist/js/modern/utils/createCompiler.js +0 -61
- package/dist/js/node/utils/createCompiler.js +0 -81
- package/dist/types/utils/createCompiler.d.ts +0 -13
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.renderFunction = exports.index = exports.html = exports.fileSystemRoutes = void 0;
|
|
7
|
-
|
|
6
|
+
exports.routesForServer = exports.renderFunction = exports.index = exports.html = exports.fileSystemRoutes = void 0;
|
|
7
|
+
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; }
|
|
8
|
+
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; }
|
|
9
|
+
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; }
|
|
8
10
|
const index = ({
|
|
9
11
|
mountId,
|
|
10
12
|
imports,
|
|
@@ -29,9 +31,7 @@ AppWrapper = render();
|
|
|
29
31
|
|
|
30
32
|
${exportStatement};
|
|
31
33
|
`;
|
|
32
|
-
|
|
33
34
|
exports.index = index;
|
|
34
|
-
|
|
35
35
|
const renderFunction = ({
|
|
36
36
|
plugins,
|
|
37
37
|
customBootstrap,
|
|
@@ -53,9 +53,7 @@ const renderFunction = ({
|
|
|
53
53
|
|
|
54
54
|
return AppWrapper
|
|
55
55
|
`;
|
|
56
|
-
|
|
57
56
|
exports.renderFunction = renderFunction;
|
|
58
|
-
|
|
59
57
|
const html = partials => `
|
|
60
58
|
<!DOCTYPE html>
|
|
61
59
|
<html>
|
|
@@ -86,21 +84,155 @@ const html = partials => `
|
|
|
86
84
|
|
|
87
85
|
</html>
|
|
88
86
|
`;
|
|
89
|
-
|
|
90
87
|
exports.html = html;
|
|
91
|
-
|
|
88
|
+
const routesForServer = ({
|
|
89
|
+
routes,
|
|
90
|
+
alias
|
|
91
|
+
}) => {
|
|
92
|
+
const {
|
|
93
|
+
name,
|
|
94
|
+
basename
|
|
95
|
+
} = alias;
|
|
96
|
+
const loaders = [];
|
|
97
|
+
const traverseRouteTree = route => {
|
|
98
|
+
let children;
|
|
99
|
+
if ('children' in route && route.children) {
|
|
100
|
+
var _route$children;
|
|
101
|
+
children = route === null || route === void 0 ? void 0 : (_route$children = route.children) === null || _route$children === void 0 ? void 0 : _route$children.map(traverseRouteTree);
|
|
102
|
+
}
|
|
103
|
+
let loader;
|
|
104
|
+
if (route.type === 'nested') {
|
|
105
|
+
if (route.loader) {
|
|
106
|
+
loaders.push(route.loader);
|
|
107
|
+
loader = `loader_${loaders.length - 1}`;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const finalRoute = _objectSpread(_objectSpread({}, route), {}, {
|
|
111
|
+
loader,
|
|
112
|
+
children
|
|
113
|
+
});
|
|
114
|
+
return finalRoute;
|
|
115
|
+
};
|
|
116
|
+
let routesCode = `
|
|
117
|
+
export const routes = [
|
|
118
|
+
`;
|
|
119
|
+
for (const route of routes) {
|
|
120
|
+
if ('type' in route) {
|
|
121
|
+
const newRoute = traverseRouteTree(route);
|
|
122
|
+
routesCode += `${JSON.stringify(newRoute, null, 2).replace(/"(loader_[^"])"/g, '$1')},`;
|
|
123
|
+
} else {
|
|
124
|
+
routesCode += `${JSON.stringify(route, null, 2)}`;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
routesCode += `\n];`;
|
|
128
|
+
const importLoadersCode = loaders.map((loader, index) => {
|
|
129
|
+
const realLoaderPath = loader.replace(name, basename);
|
|
130
|
+
return `import loader_${index} from '${realLoaderPath}';\n`;
|
|
131
|
+
}).join('');
|
|
132
|
+
return `
|
|
133
|
+
${importLoadersCode}
|
|
134
|
+
${routesCode}
|
|
135
|
+
`;
|
|
136
|
+
};
|
|
137
|
+
exports.routesForServer = routesForServer;
|
|
92
138
|
const fileSystemRoutes = ({
|
|
93
|
-
routes
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
`;
|
|
105
|
-
|
|
139
|
+
routes,
|
|
140
|
+
ssrMode,
|
|
141
|
+
nestedRoutesEntry,
|
|
142
|
+
entryName
|
|
143
|
+
}) => {
|
|
144
|
+
// The legacy mode and pages dir routes should use loadable
|
|
145
|
+
// nested routes + renderTostring should use loadable.lazy
|
|
146
|
+
// nested routes + renderToStream should use react.lazy
|
|
147
|
+
const importLazyCode = `
|
|
148
|
+
import { lazy } from "react";
|
|
149
|
+
import loadable, { lazy as loadableLazy } from "@modern-js/runtime/loadable"
|
|
150
|
+
`;
|
|
151
|
+
let dataLoaderPath = '';
|
|
152
|
+
if (ssrMode) {
|
|
153
|
+
dataLoaderPath = require.resolve(`@modern-js/plugin-data-loader/loader`);
|
|
154
|
+
if (nestedRoutesEntry) {
|
|
155
|
+
dataLoaderPath = `${dataLoaderPath}?routesDir=${nestedRoutesEntry}&entryName=${entryName}!`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
const loadings = [];
|
|
159
|
+
const errors = [];
|
|
160
|
+
const loaders = [];
|
|
161
|
+
const traverseRouteTree = route => {
|
|
162
|
+
let children;
|
|
163
|
+
if ('children' in route && route.children) {
|
|
164
|
+
var _route$children2;
|
|
165
|
+
children = route === null || route === void 0 ? void 0 : (_route$children2 = route.children) === null || _route$children2 === void 0 ? void 0 : _route$children2.map(traverseRouteTree);
|
|
166
|
+
}
|
|
167
|
+
let loading;
|
|
168
|
+
let error;
|
|
169
|
+
let loader;
|
|
170
|
+
let component = '';
|
|
171
|
+
if (route.type === 'nested') {
|
|
172
|
+
if (route.loading) {
|
|
173
|
+
loadings.push(route.loading);
|
|
174
|
+
loading = `loading_${loadings.length - 1}`;
|
|
175
|
+
}
|
|
176
|
+
if (route.error) {
|
|
177
|
+
errors.push(route.error);
|
|
178
|
+
error = `error_${errors.length - 1}`;
|
|
179
|
+
}
|
|
180
|
+
if (route.loader) {
|
|
181
|
+
loaders.push(route.loader);
|
|
182
|
+
loader = `loader_${loaders.length - 1}`;
|
|
183
|
+
}
|
|
184
|
+
if (route._component) {
|
|
185
|
+
if (ssrMode === 'stream') {
|
|
186
|
+
component = `lazy(() => import(/* webpackChunkName: "${route.id}" */ /* webpackMode: "lazy-once" */ '${route._component}'))`;
|
|
187
|
+
} else {
|
|
188
|
+
component = `loadable(() => import(/* webpackChunkName: "${route.id}" */ /* webpackMode: "lazy-once" */ '${route._component}'))`;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
} else if (route._component) {
|
|
192
|
+
component = `loadable(() => import('${route._component}'))`;
|
|
193
|
+
}
|
|
194
|
+
const finalRoute = _objectSpread(_objectSpread({}, route), {}, {
|
|
195
|
+
loading,
|
|
196
|
+
loader,
|
|
197
|
+
error,
|
|
198
|
+
children
|
|
199
|
+
});
|
|
200
|
+
if (route._component) {
|
|
201
|
+
finalRoute.component = component;
|
|
202
|
+
}
|
|
203
|
+
return finalRoute;
|
|
204
|
+
};
|
|
205
|
+
let routeComponentsCode = `
|
|
206
|
+
export const routes = [
|
|
207
|
+
`;
|
|
208
|
+
for (const route of routes) {
|
|
209
|
+
if ('type' in route) {
|
|
210
|
+
const newRoute = traverseRouteTree(route);
|
|
211
|
+
routeComponentsCode += `${JSON.stringify(newRoute, null, 2).replace(/"(loadable.*\))"/g, '$1').replace(/"(loadableLazy.*\))"/g, '$1').replace(/"(lazy.*\))"/g, '$1').replace(/"(loading_[^"])"/g, '$1').replace(/"(loader_[^"])"/g, '$1').replace(/"(error_[^"])"/g, '$1').replace(/\\"/g, '"')},`;
|
|
212
|
+
} else {
|
|
213
|
+
const component = `loadable(() => import('${route._component}'))`;
|
|
214
|
+
const finalRoute = _objectSpread(_objectSpread({}, route), {}, {
|
|
215
|
+
component
|
|
216
|
+
});
|
|
217
|
+
routeComponentsCode += `${JSON.stringify(finalRoute, null, 2).replace(/"(loadable[^"]*)"/g, '$1').replace(/"(lazy[^"]*)"/g, '$1')},`;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
routeComponentsCode += `\n];`;
|
|
221
|
+
const importLoadingCode = loadings.map((loading, index) => {
|
|
222
|
+
return `import loading_${index} from '${loading}';\n`;
|
|
223
|
+
}).join('');
|
|
224
|
+
const importErrorComponentsCode = errors.map((error, index) => {
|
|
225
|
+
return `import error_${index} from '${error}';\n`;
|
|
226
|
+
}).join('');
|
|
227
|
+
const importLoaderComponentsCode = loaders.map((loader, index) => {
|
|
228
|
+
return `import loader_${index} from '${dataLoaderPath}${loader}';\n`;
|
|
229
|
+
}).join('');
|
|
230
|
+
return `
|
|
231
|
+
${importLazyCode}
|
|
232
|
+
${importLoadingCode}
|
|
233
|
+
${importErrorComponentsCode}
|
|
234
|
+
${importLoaderComponentsCode}
|
|
235
|
+
${routeComponentsCode}
|
|
236
|
+
`;
|
|
237
|
+
};
|
|
106
238
|
exports.fileSystemRoutes = fileSystemRoutes;
|
|
@@ -3,30 +3,21 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.walkDirectory = exports.isRouteComponentFile = exports.getDefaultImports = void 0;
|
|
7
|
-
|
|
6
|
+
exports.walkDirectory = exports.replaceWithAlias = exports.isRouteComponentFile = exports.getDefaultImports = void 0;
|
|
8
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
|
-
|
|
10
8
|
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
|
|
12
9
|
var _utils = require("@modern-js/utils");
|
|
13
|
-
|
|
14
10
|
var _constants = require("./constants");
|
|
15
|
-
|
|
16
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
|
|
18
12
|
const walkDirectory = dir => _fs.default.readdirSync(dir).reduce((previous, filename) => {
|
|
19
13
|
const filePath = _path.default.join(dir, filename);
|
|
20
|
-
|
|
21
14
|
if (_fs.default.statSync(filePath).isDirectory()) {
|
|
22
15
|
return [...previous, ...walkDirectory(filePath)];
|
|
23
16
|
} else {
|
|
24
17
|
return [...previous, filePath];
|
|
25
18
|
}
|
|
26
19
|
}, []);
|
|
27
|
-
|
|
28
20
|
exports.walkDirectory = walkDirectory;
|
|
29
|
-
|
|
30
21
|
const getDefaultImports = ({
|
|
31
22
|
entrypoint,
|
|
32
23
|
srcDirectory,
|
|
@@ -63,7 +54,6 @@ const getDefaultImports = ({
|
|
|
63
54
|
}],
|
|
64
55
|
value: (0, _utils.normalizeToPosixPath)(customBootstrap.replace(srcDirectory, internalSrcAlias))
|
|
65
56
|
}].filter(Boolean);
|
|
66
|
-
|
|
67
57
|
if (fileSystemRoutes) {
|
|
68
58
|
const route = {
|
|
69
59
|
specifiers: [{
|
|
@@ -71,7 +61,6 @@ const getDefaultImports = ({
|
|
|
71
61
|
}],
|
|
72
62
|
value: (0, _utils.normalizeToPosixPath)(`${internalDirAlias}/${entryName}/${_constants.FILE_SYSTEM_ROUTES_FILE_NAME}`)
|
|
73
63
|
};
|
|
74
|
-
|
|
75
64
|
if (fileSystemRoutes.globalApp) {
|
|
76
65
|
imports.push({
|
|
77
66
|
specifiers: [{
|
|
@@ -82,7 +71,6 @@ const getDefaultImports = ({
|
|
|
82
71
|
} else {
|
|
83
72
|
route.initialize = 'const App = false;';
|
|
84
73
|
}
|
|
85
|
-
|
|
86
74
|
imports.push(route);
|
|
87
75
|
} else {
|
|
88
76
|
imports.push({
|
|
@@ -92,22 +80,18 @@ const getDefaultImports = ({
|
|
|
92
80
|
value: (0, _utils.normalizeToPosixPath)(entry.replace(srcDirectory, internalSrcAlias))
|
|
93
81
|
});
|
|
94
82
|
}
|
|
95
|
-
|
|
96
83
|
return imports;
|
|
97
84
|
};
|
|
98
|
-
|
|
99
85
|
exports.getDefaultImports = getDefaultImports;
|
|
100
|
-
|
|
101
86
|
const isRouteComponentFile = filePath => {
|
|
102
87
|
if (/\.(d|test|spec|e2e)\.(js|jsx|ts|tsx)$/.test(filePath)) {
|
|
103
88
|
return false;
|
|
104
89
|
}
|
|
105
|
-
|
|
106
90
|
if (['.js', '.jsx', '.ts', '.tsx'].includes(_path.default.extname(filePath))) {
|
|
107
91
|
return true;
|
|
108
92
|
}
|
|
109
|
-
|
|
110
93
|
return false;
|
|
111
94
|
};
|
|
112
|
-
|
|
113
|
-
|
|
95
|
+
exports.isRouteComponentFile = isRouteComponentFile;
|
|
96
|
+
const replaceWithAlias = (base, filePath, alias) => (0, _utils.normalizeToPosixPath)(_path.default.join(alias, _path.default.relative(base, filePath)));
|
|
97
|
+
exports.replaceWithAlias = replaceWithAlias;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.PluginCompatModern = void 0;
|
|
7
|
+
var _path = require("path");
|
|
8
|
+
var _builderShared = require("@modern-js/builder-shared");
|
|
9
|
+
var _lodash = require("@modern-js/utils/lodash");
|
|
10
|
+
var _htmlWebpackPlugin = _interopRequireDefault(require("@modern-js/builder-webpack-provider/html-webpack-plugin"));
|
|
11
|
+
var _utils = require("@modern-js/utils");
|
|
12
|
+
var _htmlBottomTemplate = require("../webpackPlugins/htmlBottomTemplate");
|
|
13
|
+
var _htmlAsyncChunkPlugin = require("../webpackPlugins/htmlAsyncChunkPlugin");
|
|
14
|
+
var _share = require("../share");
|
|
15
|
+
var _routerPlugin = _interopRequireDefault(require("../webpackPlugins/routerPlugin"));
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
+
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; }
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
20
|
+
/**
|
|
21
|
+
* Provides default configuration consistent with `@modern-js/webpack`
|
|
22
|
+
*/
|
|
23
|
+
const PluginCompatModern = (appContext, modernConfig, options) => ({
|
|
24
|
+
name: 'builder-plugin-compat-modern',
|
|
25
|
+
setup(api) {
|
|
26
|
+
api.modifyBuilderConfig(config => {
|
|
27
|
+
if (isStreamingSSR(modernConfig)) {
|
|
28
|
+
return (0, _builderShared.mergeBuilderConfig)(config, {
|
|
29
|
+
html: {
|
|
30
|
+
inject: 'body'
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return config;
|
|
35
|
+
});
|
|
36
|
+
api.modifyWebpackChain((chain, {
|
|
37
|
+
target,
|
|
38
|
+
CHAIN_ID,
|
|
39
|
+
isProd
|
|
40
|
+
}) => {
|
|
41
|
+
const builderNormalizedConfig = api.getNormalizedConfig();
|
|
42
|
+
// set webpack config name
|
|
43
|
+
if (target === 'node') {
|
|
44
|
+
chain.name('server');
|
|
45
|
+
} else if (target === 'modern-web') {
|
|
46
|
+
chain.name('modern');
|
|
47
|
+
} else {
|
|
48
|
+
chain.name('client');
|
|
49
|
+
}
|
|
50
|
+
chain.resolve.modules.add('node_modules').add((0, _path.join)(api.context.rootPath, 'node_modules'));
|
|
51
|
+
|
|
52
|
+
// apply node compat
|
|
53
|
+
if (target === 'node') {
|
|
54
|
+
applyNodeCompat(chain, modernConfig, isProd);
|
|
55
|
+
}
|
|
56
|
+
if (isHtmlEnabled(builderNormalizedConfig, target)) {
|
|
57
|
+
applyBottomHtmlWebpackPlugin({
|
|
58
|
+
api,
|
|
59
|
+
chain,
|
|
60
|
+
CHAIN_ID,
|
|
61
|
+
appContext,
|
|
62
|
+
modernConfig
|
|
63
|
+
});
|
|
64
|
+
applyAsyncChunkHtmlPlugin({
|
|
65
|
+
chain,
|
|
66
|
+
CHAIN_ID,
|
|
67
|
+
modernConfig
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// apply copy plugin
|
|
72
|
+
// const copyPatterns = createCopyPatterns(chain, appContext, modernConfig);
|
|
73
|
+
const defaultCopyPattern = (0, _share.createCopyPattern)(appContext, modernConfig, 'public', chain);
|
|
74
|
+
chain.plugin(CHAIN_ID.PLUGIN.COPY).tap(args => {
|
|
75
|
+
var _args$;
|
|
76
|
+
return [{
|
|
77
|
+
patterns: [...(((_args$ = args[0]) === null || _args$ === void 0 ? void 0 : _args$.patterns) || []), defaultCopyPattern]
|
|
78
|
+
}];
|
|
79
|
+
});
|
|
80
|
+
const {
|
|
81
|
+
entrypoints
|
|
82
|
+
} = appContext;
|
|
83
|
+
const existNestedRoutes = entrypoints.some(entrypoint => entrypoint.nestedRoutesEntry);
|
|
84
|
+
chain.plugin('route-plugin').use(_routerPlugin.default, [{
|
|
85
|
+
existNestedRoutes
|
|
86
|
+
}]);
|
|
87
|
+
function isHtmlEnabled(config, target) {
|
|
88
|
+
var _config$tools;
|
|
89
|
+
return ((_config$tools = config.tools) === null || _config$tools === void 0 ? void 0 : _config$tools.htmlPlugin) !== false && target !== 'node' && target !== 'web-worker';
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
if (options) {
|
|
93
|
+
applyCallbacks(api, options);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* register builder hooks callback
|
|
100
|
+
*/
|
|
101
|
+
exports.PluginCompatModern = PluginCompatModern;
|
|
102
|
+
function applyCallbacks(api, options) {
|
|
103
|
+
options.onAfterBuild && api.onAfterBuild(options.onAfterBuild);
|
|
104
|
+
options.onAfterCreateCompiler && api.onAfterCreateCompiler(options.onAfterCreateCompiler);
|
|
105
|
+
options.onAfterStartDevServer && api.onAfterStartDevServer(options.onAfterStartDevServer);
|
|
106
|
+
options.onBeforeBuild && api.onBeforeBuild(options.onBeforeBuild);
|
|
107
|
+
options.onBeforeCreateCompiler && api.onBeforeCreateCompiler(options.onBeforeCreateCompiler);
|
|
108
|
+
options.onBeforeStartDevServer && api.onBeforeStartDevServer(options.onBeforeStartDevServer);
|
|
109
|
+
options.onDevCompileDone && api.onDevCompileDone(options.onDevCompileDone);
|
|
110
|
+
options.onExit && api.onExit(options.onExit);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* compat some config, if target is `node`
|
|
115
|
+
*/
|
|
116
|
+
function applyNodeCompat(chain, modernConfig, isProd) {
|
|
117
|
+
// apply node resolve extensions
|
|
118
|
+
for (const ext of ['.node.js', '.node.jsx', '.node.ts', '.node.tsx']) {
|
|
119
|
+
chain.resolve.extensions.prepend(ext);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// apply filterEntriesBySSRConfig
|
|
123
|
+
filterEntriesBySSRConfig(isProd, chain, modernConfig.server, modernConfig.output);
|
|
124
|
+
function filterEntriesBySSRConfig(isProd, chain, serverConfig, outputConfig) {
|
|
125
|
+
var _outputConfig$ssg;
|
|
126
|
+
const entries = chain.entryPoints.entries();
|
|
127
|
+
// if prod and ssg config is true or function
|
|
128
|
+
if (isProd && ((outputConfig === null || outputConfig === void 0 ? void 0 : outputConfig.ssg) === true || typeof (outputConfig === null || outputConfig === void 0 ? void 0 : (_outputConfig$ssg = outputConfig.ssg) === null || _outputConfig$ssg === void 0 ? void 0 : _outputConfig$ssg[0]) === 'function')) {
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// if single entry has ssg config
|
|
133
|
+
// `ssg: {}` is not allowed if multi entry
|
|
134
|
+
const entryNames = Object.keys(entries);
|
|
135
|
+
if (isProd && entryNames.length === 1 && outputConfig !== null && outputConfig !== void 0 && outputConfig.ssg) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// collect all ssg entries
|
|
140
|
+
const ssgEntries = [];
|
|
141
|
+
if (isProd && outputConfig !== null && outputConfig !== void 0 && outputConfig.ssg) {
|
|
142
|
+
const {
|
|
143
|
+
ssg
|
|
144
|
+
} = outputConfig;
|
|
145
|
+
entryNames.forEach(name => {
|
|
146
|
+
if (ssg[name]) {
|
|
147
|
+
ssgEntries.push(name);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const {
|
|
152
|
+
ssr,
|
|
153
|
+
ssrByEntries
|
|
154
|
+
} = serverConfig || {};
|
|
155
|
+
entryNames.forEach(name => {
|
|
156
|
+
if (!ssgEntries.includes(name) && (ssr && (ssrByEntries === null || ssrByEntries === void 0 ? void 0 : ssrByEntries[name]) === false || !ssr && !(ssrByEntries !== null && ssrByEntries !== void 0 && ssrByEntries[name]))) {
|
|
157
|
+
chain.entryPoints.delete(name);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* inject bottom template
|
|
165
|
+
*/
|
|
166
|
+
function applyBottomHtmlWebpackPlugin({
|
|
167
|
+
api,
|
|
168
|
+
chain,
|
|
169
|
+
modernConfig,
|
|
170
|
+
appContext,
|
|
171
|
+
CHAIN_ID
|
|
172
|
+
}) {
|
|
173
|
+
// inject bottomTemplate into html-webpack-plugin
|
|
174
|
+
for (const entryName of Object.keys(api.context.entry)) {
|
|
175
|
+
// FIXME: the only need necessary
|
|
176
|
+
const baseTemplateParams = _objectSpread({
|
|
177
|
+
entryName,
|
|
178
|
+
title: (0, _utils.getEntryOptions)(entryName, modernConfig.output.title, modernConfig.output.titleByEntries, appContext.packageName),
|
|
179
|
+
mountId: modernConfig.output.mountId
|
|
180
|
+
}, (0, _utils.getEntryOptions)(entryName, modernConfig.output.templateParameters, modernConfig.output.templateParametersByEntries, appContext.packageName));
|
|
181
|
+
chain.plugin(`${CHAIN_ID.PLUGIN.HTML}-${entryName}`).tap(args => [_objectSpread(_objectSpread({}, args[0] || {}), {}, {
|
|
182
|
+
__internal__: true,
|
|
183
|
+
bottomTemplate: appContext.htmlTemplates[`__${entryName}-bottom__`] && (0, _lodash.template)(appContext.htmlTemplates[`__${entryName}-bottom__`])(baseTemplateParams)
|
|
184
|
+
})]);
|
|
185
|
+
}
|
|
186
|
+
chain.plugin(CHAIN_ID.PLUGIN.BOTTOM_TEMPLATE).use(_htmlBottomTemplate.BottomTemplatePlugin, [_htmlWebpackPlugin.default]);
|
|
187
|
+
}
|
|
188
|
+
const isStreamingSSR = userConfig => {
|
|
189
|
+
const isStreaming = ssr => ssr && typeof ssr === 'object' && ssr.mode === 'stream';
|
|
190
|
+
const {
|
|
191
|
+
server
|
|
192
|
+
} = userConfig;
|
|
193
|
+
if (isStreaming(server.ssr)) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// Since we cannot apply different plugins for different entries,
|
|
198
|
+
// we regard the whole app as streaming ssr only if one entry meets the requirement.
|
|
199
|
+
if (server !== null && server !== void 0 && server.ssrByEntries && typeof server.ssrByEntries === 'object') {
|
|
200
|
+
for (const name of Object.keys(server.ssrByEntries)) {
|
|
201
|
+
if (isStreaming(server.ssrByEntries[name])) {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
};
|
|
208
|
+
function applyAsyncChunkHtmlPlugin({
|
|
209
|
+
chain,
|
|
210
|
+
modernConfig,
|
|
211
|
+
CHAIN_ID
|
|
212
|
+
}) {
|
|
213
|
+
if (isStreamingSSR(modernConfig)) {
|
|
214
|
+
chain.plugin(CHAIN_ID.PLUGIN.HTML_ASYNC_CHUNK).use(_htmlAsyncChunkPlugin.HtmlAsyncChunkPlugin, [_htmlWebpackPlugin.default]);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
var _utils = require("@modern-js/utils");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function createHtmlConfig(normalizedConfig, appContext) {
|
|
14
|
+
const {
|
|
15
|
+
disableHtmlFolder,
|
|
16
|
+
favicon,
|
|
17
|
+
faviconByEntries,
|
|
18
|
+
inject,
|
|
19
|
+
injectByEntries,
|
|
20
|
+
meta,
|
|
21
|
+
metaByEntries,
|
|
22
|
+
mountId,
|
|
23
|
+
title,
|
|
24
|
+
titleByEntries,
|
|
25
|
+
scriptExt,
|
|
26
|
+
templateParameters,
|
|
27
|
+
templateParametersByEntries
|
|
28
|
+
} = normalizedConfig.output;
|
|
29
|
+
const {
|
|
30
|
+
configDir
|
|
31
|
+
} = normalizedConfig.source;
|
|
32
|
+
|
|
33
|
+
// transform Modernjs `output.scriptExt` to Builder `html.crossorigin` configuration
|
|
34
|
+
const builderCrossorigin = createBuilderCrossorigin(scriptExt);
|
|
35
|
+
const builderAppIcon = createBuilderAppIcon(configDir, appContext);
|
|
36
|
+
const builderFavicon = createBuilderFavicon(favicon, configDir, appContext);
|
|
37
|
+
return {
|
|
38
|
+
appIcon: builderAppIcon,
|
|
39
|
+
disableHtmlFolder,
|
|
40
|
+
favicon: builderFavicon,
|
|
41
|
+
faviconByEntries,
|
|
42
|
+
inject,
|
|
43
|
+
injectByEntries,
|
|
44
|
+
meta,
|
|
45
|
+
metaByEntries,
|
|
46
|
+
mountId,
|
|
47
|
+
title,
|
|
48
|
+
titleByEntries,
|
|
49
|
+
crossorigin: builderCrossorigin,
|
|
50
|
+
templateByEntries: appContext.htmlTemplates,
|
|
51
|
+
templateParameters,
|
|
52
|
+
templateParametersByEntries: templateParametersByEntries
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
const ICON_EXTENSIONS = ['png', 'jpg', 'jpeg', 'svg', 'ico'];
|
|
56
|
+
function createBuilderAppIcon(configDir, appContext) {
|
|
57
|
+
const appIcon = (0, _utils.findExists)(ICON_EXTENSIONS.map(ext => _path.default.resolve(appContext.appDirectory, configDir, `icon.${ext}`)));
|
|
58
|
+
return typeof appIcon === 'string' ? appIcon : undefined;
|
|
59
|
+
}
|
|
60
|
+
function createBuilderCrossorigin(scriptExt) {
|
|
61
|
+
var _scriptExtCustomConfi;
|
|
62
|
+
const scriptExtCustomConfig = scriptExt === null || scriptExt === void 0 ? void 0 : scriptExt.custom;
|
|
63
|
+
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;
|
|
64
|
+
}
|
|
65
|
+
function createBuilderFavicon(favicon, configDir, appContext) {
|
|
66
|
+
const defaultFavicon = (0, _utils.findExists)(ICON_EXTENSIONS.map(ext => _path.default.resolve(appContext.appDirectory, configDir, `favicon.${ext}`)));
|
|
67
|
+
return favicon || defaultFavicon || undefined;
|
|
68
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createOutputConfig = createOutputConfig;
|
|
7
|
+
var _share = require("./share");
|
|
8
|
+
function createOutputConfig(normalizedConfig, appContext) {
|
|
9
|
+
// TODO: add `externals` options in Modern.
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
assetPrefix,
|
|
13
|
+
copy,
|
|
14
|
+
cssModuleLocalIdentName,
|
|
15
|
+
cssPath,
|
|
16
|
+
jsPath,
|
|
17
|
+
htmlPath,
|
|
18
|
+
mediaPath,
|
|
19
|
+
path,
|
|
20
|
+
disableInlineRuntimeChunk,
|
|
21
|
+
disableMinimize,
|
|
22
|
+
disableSourceMap,
|
|
23
|
+
disableTsChecker,
|
|
24
|
+
enableCssModuleTSDeclaration,
|
|
25
|
+
enableInlineScripts,
|
|
26
|
+
enableInlineStyles,
|
|
27
|
+
polyfill,
|
|
28
|
+
dataUriLimit,
|
|
29
|
+
disableAssetsCache,
|
|
30
|
+
enableLatestDecorators,
|
|
31
|
+
disableCssModuleExtension
|
|
32
|
+
} = normalizedConfig.output;
|
|
33
|
+
const defaultCopyPattern = (0, _share.createCopyPattern)(appContext, normalizedConfig, 'upload');
|
|
34
|
+
const builderCopy = copy ? [...copy, defaultCopyPattern] : [defaultCopyPattern];
|
|
35
|
+
return {
|
|
36
|
+
assetPrefix,
|
|
37
|
+
copy: builderCopy,
|
|
38
|
+
distPath: {
|
|
39
|
+
root: path,
|
|
40
|
+
css: cssPath,
|
|
41
|
+
js: jsPath,
|
|
42
|
+
html: htmlPath,
|
|
43
|
+
// `@modern-js/webpack` output all media files to `dist/media` by default
|
|
44
|
+
svg: mediaPath || 'media',
|
|
45
|
+
image: mediaPath || 'media',
|
|
46
|
+
font: mediaPath || 'media',
|
|
47
|
+
media: mediaPath || 'media'
|
|
48
|
+
},
|
|
49
|
+
dataUriLimit: {
|
|
50
|
+
svg: dataUriLimit,
|
|
51
|
+
image: dataUriLimit,
|
|
52
|
+
font: dataUriLimit,
|
|
53
|
+
media: dataUriLimit
|
|
54
|
+
},
|
|
55
|
+
disableCssModuleExtension,
|
|
56
|
+
disableInlineRuntimeChunk,
|
|
57
|
+
disableMinimize,
|
|
58
|
+
disableSourceMap,
|
|
59
|
+
disableTsChecker,
|
|
60
|
+
enableCssModuleTSDeclaration,
|
|
61
|
+
enableInlineScripts,
|
|
62
|
+
enableInlineStyles,
|
|
63
|
+
polyfill,
|
|
64
|
+
// 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
|
|
65
|
+
cleanDistPath: false,
|
|
66
|
+
disableFilenameHash: disableAssetsCache,
|
|
67
|
+
enableLatestDecorators,
|
|
68
|
+
filename: {
|
|
69
|
+
css: cssModuleLocalIdentName
|
|
70
|
+
},
|
|
71
|
+
// `@modern-js/webpack` used to generate asset manifest by default
|
|
72
|
+
enableAssetManifest: true,
|
|
73
|
+
// compatible the modern-js with fallback behavior
|
|
74
|
+
enableAssetFallback: true
|
|
75
|
+
};
|
|
76
|
+
}
|