@bleedingdev/modern-js-app-tools 3.2.0-ultramodern.12 → 3.2.0-ultramodern.121
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 +0 -0
- package/dist/cjs/baseline.js +12 -50
- package/dist/cjs/builder/builder-rspack/index.js +9 -5
- package/dist/cjs/builder/generator/adapterCopy.js +9 -5
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +9 -5
- package/dist/cjs/builder/generator/createCopyPattern.js +9 -5
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +199 -12
- package/dist/cjs/builder/generator/index.js +9 -5
- package/dist/cjs/builder/index.js +9 -5
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +50 -10
- package/dist/cjs/builder/shared/builderPlugins/adapterHtml.js +10 -6
- package/dist/cjs/builder/shared/builderPlugins/adapterPrecompress.js +9 -5
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +12 -6
- package/dist/cjs/builder/shared/builderPlugins/builderHooks.js +12 -8
- package/dist/cjs/builder/shared/builderPlugins/index.js +9 -5
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.js +9 -5
- package/dist/cjs/builder/shared/bundlerPlugins/HtmlBottomTemplate.js +12 -8
- package/dist/cjs/builder/shared/bundlerPlugins/RouterPlugin.js +9 -5
- package/dist/cjs/builder/shared/bundlerPlugins/index.js +9 -5
- package/dist/cjs/builder/shared/createCopyInfo.js +9 -5
- package/dist/cjs/builder/shared/index.js +9 -5
- package/dist/cjs/builder/shared/loaders/serverModuleLoader.js +12 -8
- package/dist/cjs/commands/build.js +9 -5
- package/dist/cjs/commands/deploy.js +9 -5
- package/dist/cjs/commands/dev.js +9 -5
- package/dist/cjs/commands/index.js +12 -11
- package/dist/cjs/commands/info.js +9 -5
- package/dist/cjs/commands/inspect.js +12 -8
- package/dist/cjs/commands/runtime.js +50 -13
- package/dist/cjs/commands/serve.js +9 -5
- package/dist/cjs/compat/hooks.js +9 -5
- package/dist/cjs/compat/index.js +9 -5
- package/dist/cjs/compat/utils.js +9 -5
- package/dist/cjs/config/default.js +9 -5
- package/dist/cjs/config/index.js +9 -5
- package/dist/cjs/config/initialize/index.js +9 -5
- package/dist/cjs/config/initialize/inits.js +9 -5
- package/dist/cjs/constants.js +13 -9
- package/dist/cjs/defineConfig.js +12 -8
- package/dist/cjs/esm/register-esm.js +12 -8
- package/dist/cjs/esm/ts-paths-loader.js +9 -5
- package/dist/cjs/index.js +22 -17
- package/dist/cjs/locale/en.js +12 -8
- package/dist/cjs/locale/index.js +9 -5
- package/dist/cjs/locale/zh.js +12 -8
- package/dist/cjs/plugins/analyze/constants.js +14 -10
- package/dist/cjs/plugins/analyze/getBundleEntry.js +9 -5
- package/dist/cjs/plugins/analyze/getFileSystemEntry.js +9 -5
- package/dist/cjs/plugins/analyze/getHtmlTemplate.js +9 -5
- package/dist/cjs/plugins/analyze/getServerRoutes.js +9 -5
- package/dist/cjs/plugins/analyze/index.js +9 -5
- package/dist/cjs/plugins/analyze/isDefaultExportFunction.js +9 -5
- package/dist/cjs/plugins/analyze/templates.js +12 -8
- package/dist/cjs/plugins/analyze/utils.js +9 -5
- package/dist/cjs/plugins/deploy/index.js +26 -11
- package/dist/cjs/plugins/deploy/platforms/cloudflare.js +400 -0
- package/dist/cjs/plugins/deploy/platforms/gh-pages.js +9 -5
- package/dist/cjs/plugins/deploy/platforms/netlify.js +9 -5
- package/dist/cjs/plugins/deploy/platforms/node.js +9 -5
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +563 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +7 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +185 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +59 -0
- package/dist/cjs/plugins/deploy/platforms/vercel.js +9 -5
- package/dist/cjs/plugins/deploy/utils/generator.js +9 -5
- package/dist/cjs/plugins/deploy/utils/index.js +19 -40
- package/dist/cjs/plugins/initialize/index.js +9 -5
- package/dist/cjs/plugins/serverBuild.js +9 -5
- package/dist/cjs/plugins/serverRuntime.js +12 -8
- package/dist/cjs/presetUltramodern.js +95 -7
- package/dist/cjs/rsbuild.js +55 -64
- package/dist/cjs/run/index.js +9 -5
- package/dist/cjs/types/config/cloudflareDeploy.js +18 -0
- package/dist/cjs/types/config/index.js +9 -5
- package/dist/cjs/types/config/precompress.js +18 -0
- package/dist/cjs/types/index.js +9 -5
- package/dist/cjs/ultramodern/designSystem.js +16 -12
- package/dist/cjs/utils/config.js +9 -5
- package/dist/cjs/utils/createServer.js +14 -10
- package/dist/cjs/utils/env.js +9 -5
- package/dist/cjs/utils/generateWatchFiles.js +9 -5
- package/dist/cjs/utils/getConfigFile.js +9 -5
- package/dist/cjs/utils/getSelectedEntries.js +9 -5
- package/dist/cjs/utils/initAppContext.js +9 -5
- package/dist/cjs/utils/loadPlugins.js +9 -5
- package/dist/cjs/utils/printInstructions.js +9 -5
- package/dist/cjs/utils/register.js +9 -5
- package/dist/cjs/utils/restart.js +9 -5
- package/dist/cjs/utils/routes.js +9 -5
- package/dist/esm/baseline.mjs +3 -45
- package/dist/esm/builder/generator/getBuilderEnvironments.mjs +180 -8
- package/dist/esm/builder/shared/builderPlugins/adapterBasic.mjs +41 -5
- package/dist/esm/builder/shared/builderPlugins/adapterHtml.mjs +1 -1
- package/dist/esm/builder/shared/builderPlugins/adapterSSR.mjs +3 -1
- package/dist/esm/commands/index.mjs +2 -5
- package/dist/esm/commands/runtime.mjs +33 -3
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/plugins/deploy/index.mjs +10 -4
- package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +352 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +563 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +7 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +185 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +59 -0
- package/dist/esm/plugins/deploy/utils/index.mjs +11 -36
- package/dist/esm/presetUltramodern.mjs +77 -3
- package/dist/esm/rsbuild.mjs +4 -8
- package/dist/esm/types/config/cloudflareDeploy.mjs +0 -0
- package/dist/esm/types/config/precompress.mjs +0 -0
- package/dist/esm-node/baseline.mjs +3 -45
- package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +185 -9
- package/dist/esm-node/builder/shared/builderPlugins/adapterBasic.mjs +41 -5
- package/dist/esm-node/builder/shared/builderPlugins/adapterHtml.mjs +1 -1
- package/dist/esm-node/builder/shared/builderPlugins/adapterSSR.mjs +3 -1
- package/dist/esm-node/commands/index.mjs +2 -5
- package/dist/esm-node/commands/runtime.mjs +33 -3
- package/dist/esm-node/index.mjs +2 -2
- package/dist/esm-node/plugins/deploy/index.mjs +10 -4
- package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +353 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +563 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.mjs +7 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs +185 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-path.mjs +59 -0
- package/dist/esm-node/plugins/deploy/utils/index.mjs +12 -36
- package/dist/esm-node/presetUltramodern.mjs +77 -3
- package/dist/esm-node/rsbuild.mjs +4 -8
- package/dist/esm-node/types/config/cloudflareDeploy.mjs +1 -0
- package/dist/esm-node/types/config/precompress.mjs +1 -0
- package/dist/types/baseline.d.ts +16 -46
- package/dist/types/builder/builder-rspack/index.d.ts +1 -1
- package/dist/types/builder/generator/index.d.ts +1 -1
- package/dist/types/builder/shared/createCopyInfo.d.ts +1 -1
- package/dist/types/commands/index.d.ts +1 -1
- package/dist/types/commands/inspect.d.ts +1 -1
- package/dist/types/commands/runtime.d.ts +1 -0
- package/dist/types/locale/en.d.ts +1 -1
- package/dist/types/locale/index.d.ts +89 -2
- package/dist/types/locale/zh.d.ts +1 -1
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +2 -2
- package/dist/types/plugins/analyze/utils.d.ts +1 -1
- package/dist/types/plugins/deploy/index.d.ts +4 -1
- package/dist/types/plugins/deploy/platforms/cloudflare.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.d.mts +4 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-fs-promises.d.mts +5 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.d.mts +48 -0
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-path.d.mts +21 -0
- package/dist/types/plugins/deploy/utils/generator.d.ts +2 -2
- package/dist/types/plugins/deploy/utils/index.d.ts +1 -1
- package/dist/types/presetUltramodern.d.ts +52 -2
- package/dist/types/rsbuild.d.ts +1 -1
- package/dist/types/run/index.d.ts +1 -1
- package/dist/types/types/config/cloudflareDeploy.d.ts +79 -0
- package/dist/types/types/config/deploy.d.ts +16 -14
- package/dist/types/types/config/output.d.ts +4 -20
- package/dist/types/types/config/precompress.d.ts +20 -0
- package/dist/types/utils/getConfigFile.d.ts +1 -1
- package/dist/types/utils/loadPlugins.d.ts +2 -2
- package/package.json +21 -22
- package/dist/esm/rslib-runtime.mjs +0 -18
- package/dist/esm-node/rslib-runtime.mjs +0 -19
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import loadableComponent from '@loadable/component';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
const internals = loadableComponent?.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED || {};
|
|
4
|
+
const LoadableContext = internals.Context || React.createContext(null);
|
|
5
|
+
const getRequiredChunkKey = internals.getRequiredChunkKey || ((namespace)=>`${namespace}__LOADABLE_REQUIRED_CHUNKS__`);
|
|
6
|
+
const scriptExtensions = new Set([
|
|
7
|
+
'.js',
|
|
8
|
+
'.mjs'
|
|
9
|
+
]);
|
|
10
|
+
const styleExtensions = new Set([
|
|
11
|
+
'.css'
|
|
12
|
+
]);
|
|
13
|
+
function uniqByUrl(assets) {
|
|
14
|
+
const seen = new Set();
|
|
15
|
+
return assets.filter((asset)=>{
|
|
16
|
+
if (seen.has(asset.url)) return false;
|
|
17
|
+
seen.add(asset.url);
|
|
18
|
+
return true;
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function extname(filePath) {
|
|
22
|
+
const basename = String(filePath).split('/').pop() || '';
|
|
23
|
+
const index = basename.lastIndexOf('.');
|
|
24
|
+
return index > 0 ? basename.slice(index) : '';
|
|
25
|
+
}
|
|
26
|
+
function joinUrl(publicPath, filename) {
|
|
27
|
+
const base = publicPath || '/';
|
|
28
|
+
return `${base.replace(/\/+$/u, '')}/${String(filename).replace(/^\/+/u, '')}`;
|
|
29
|
+
}
|
|
30
|
+
function extraPropsToString(extraProps = {}) {
|
|
31
|
+
return Object.entries(extraProps).filter(([, value])=>void 0 !== value && false !== value).map(([key, value])=>true === value ? ` ${key}` : ` ${key}="${value}"`).join('');
|
|
32
|
+
}
|
|
33
|
+
function assetScriptType(filename) {
|
|
34
|
+
const extension = extname(filename);
|
|
35
|
+
if (scriptExtensions.has(extension)) return "script";
|
|
36
|
+
if (styleExtensions.has(extension)) return 'style';
|
|
37
|
+
}
|
|
38
|
+
function getAssetName(asset) {
|
|
39
|
+
return 'object' == typeof asset && asset?.name ? asset.name : asset;
|
|
40
|
+
}
|
|
41
|
+
function getAssetIntegrity(asset) {
|
|
42
|
+
return 'object' == typeof asset && asset?.integrity ? asset.integrity : null;
|
|
43
|
+
}
|
|
44
|
+
function getChunkGroupAssets(chunkGroup) {
|
|
45
|
+
const assets = chunkGroup?.assets;
|
|
46
|
+
if (Array.isArray(assets)) return assets;
|
|
47
|
+
if (assets && 'object' == typeof assets) return [
|
|
48
|
+
...assets.js || [],
|
|
49
|
+
...assets.css || []
|
|
50
|
+
];
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
function getChunkGroupChildAssets(chunkGroup, type) {
|
|
54
|
+
const childAssets = chunkGroup?.childAssets?.[type];
|
|
55
|
+
return Array.isArray(childAssets) ? childAssets : [];
|
|
56
|
+
}
|
|
57
|
+
function chunkIncludesJs(chunkInfo) {
|
|
58
|
+
return (chunkInfo?.files || []).some((file)=>scriptExtensions.has(extname(file)));
|
|
59
|
+
}
|
|
60
|
+
export function ChunkExtractorManager({ extractor, children }) {
|
|
61
|
+
return React.createElement(LoadableContext.Provider, {
|
|
62
|
+
value: extractor
|
|
63
|
+
}, children);
|
|
64
|
+
}
|
|
65
|
+
export class ChunkExtractor {
|
|
66
|
+
constructor({ stats, entrypoints = [
|
|
67
|
+
'main'
|
|
68
|
+
], namespace = '', outputPath = '/', publicPath } = {}){
|
|
69
|
+
this.namespace = namespace;
|
|
70
|
+
this.stats = stats || {};
|
|
71
|
+
this.publicPath = publicPath || this.stats.publicPath || '/';
|
|
72
|
+
this.outputPath = outputPath || this.stats.outputPath || '/';
|
|
73
|
+
this.entrypoints = Array.isArray(entrypoints) ? entrypoints : [
|
|
74
|
+
entrypoints
|
|
75
|
+
];
|
|
76
|
+
this.chunks = [];
|
|
77
|
+
}
|
|
78
|
+
addChunk(chunk) {
|
|
79
|
+
if (!this.chunks.includes(chunk)) this.chunks.push(chunk);
|
|
80
|
+
}
|
|
81
|
+
collectChunks(app) {
|
|
82
|
+
return React.createElement(ChunkExtractorManager, {
|
|
83
|
+
extractor: this
|
|
84
|
+
}, app);
|
|
85
|
+
}
|
|
86
|
+
getChunkGroup(chunk) {
|
|
87
|
+
return this.stats.namedChunkGroups?.[chunk] || {
|
|
88
|
+
assets: [],
|
|
89
|
+
childAssets: {},
|
|
90
|
+
chunks: []
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
getChunkInfo(chunkId) {
|
|
94
|
+
return (this.stats.chunks || []).find((chunk)=>chunk.id === chunkId);
|
|
95
|
+
}
|
|
96
|
+
resolvePublicUrl(filename) {
|
|
97
|
+
return joinUrl(this.publicPath, filename);
|
|
98
|
+
}
|
|
99
|
+
createChunkAsset({ filename, chunk, type, linkType }) {
|
|
100
|
+
const resolvedFilename = getAssetName(filename);
|
|
101
|
+
const scriptType = assetScriptType(resolvedFilename);
|
|
102
|
+
if (!scriptType) return;
|
|
103
|
+
return {
|
|
104
|
+
filename: resolvedFilename,
|
|
105
|
+
integrity: getAssetIntegrity(filename),
|
|
106
|
+
scriptType,
|
|
107
|
+
chunk,
|
|
108
|
+
url: this.resolvePublicUrl(resolvedFilename),
|
|
109
|
+
path: String(resolvedFilename).replace(/^\/+/u, ''),
|
|
110
|
+
type,
|
|
111
|
+
linkType
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
getChunkAssets(chunks) {
|
|
115
|
+
const one = (chunk)=>getChunkGroupAssets(this.getChunkGroup(chunk)).map((filename)=>this.createChunkAsset({
|
|
116
|
+
filename,
|
|
117
|
+
chunk,
|
|
118
|
+
type: 'mainAsset',
|
|
119
|
+
linkType: 'preload'
|
|
120
|
+
})).filter(Boolean);
|
|
121
|
+
return Array.isArray(chunks) ? uniqByUrl(chunks.flatMap(one)) : one(chunks);
|
|
122
|
+
}
|
|
123
|
+
getChunkChildAssets(chunks, type) {
|
|
124
|
+
const one = (chunk)=>getChunkGroupChildAssets(this.getChunkGroup(chunk), type).map((filename)=>this.createChunkAsset({
|
|
125
|
+
filename,
|
|
126
|
+
chunk,
|
|
127
|
+
type: 'childAsset',
|
|
128
|
+
linkType: type
|
|
129
|
+
})).filter(Boolean);
|
|
130
|
+
return Array.isArray(chunks) ? uniqByUrl(chunks.flatMap(one)) : one(chunks);
|
|
131
|
+
}
|
|
132
|
+
getChunkDependencies(chunks) {
|
|
133
|
+
const one = (chunk)=>(this.getChunkGroup(chunk).chunks || []).filter((chunkId)=>chunkIncludesJs(this.getChunkInfo(chunkId)));
|
|
134
|
+
return Array.isArray(chunks) ? [
|
|
135
|
+
...new Set(chunks.flatMap(one))
|
|
136
|
+
] : one(chunks);
|
|
137
|
+
}
|
|
138
|
+
getRequiredChunksScriptContent() {
|
|
139
|
+
return JSON.stringify(this.getChunkDependencies(this.chunks));
|
|
140
|
+
}
|
|
141
|
+
getRequiredChunksNamesScriptContent() {
|
|
142
|
+
return JSON.stringify({
|
|
143
|
+
namedChunks: this.chunks
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
getRequiredChunksScriptTag(extraProps = {}) {
|
|
147
|
+
const id = getRequiredChunkKey(this.namespace);
|
|
148
|
+
const props = `type="application/json"${extraPropsToString(extraProps)}`;
|
|
149
|
+
return [
|
|
150
|
+
`<script id="${id}" ${props}>${this.getRequiredChunksScriptContent()}</script>`,
|
|
151
|
+
`<script id="${id}_ext" ${props}>${this.getRequiredChunksNamesScriptContent()}</script>`
|
|
152
|
+
].join('');
|
|
153
|
+
}
|
|
154
|
+
getMainAssets(scriptType) {
|
|
155
|
+
const assets = this.getChunkAssets([
|
|
156
|
+
...this.entrypoints,
|
|
157
|
+
...this.chunks
|
|
158
|
+
]);
|
|
159
|
+
return scriptType ? assets.filter((asset)=>asset.scriptType === scriptType) : assets;
|
|
160
|
+
}
|
|
161
|
+
getScriptTags(extraProps = {}) {
|
|
162
|
+
const scripts = this.getMainAssets("script").map((asset)=>`<script async data-chunk="${asset.chunk}" src="${asset.url}"${extraPropsToString(extraProps)}></script>`);
|
|
163
|
+
return [
|
|
164
|
+
this.getRequiredChunksScriptTag(extraProps),
|
|
165
|
+
...scripts
|
|
166
|
+
].join('');
|
|
167
|
+
}
|
|
168
|
+
getStyleTags(extraProps = {}) {
|
|
169
|
+
return this.getMainAssets('style').map((asset)=>`<link data-chunk="${asset.chunk}" rel="stylesheet" href="${asset.url}"${extraPropsToString(extraProps)}>`).join('');
|
|
170
|
+
}
|
|
171
|
+
getLinkTags(extraProps = {}) {
|
|
172
|
+
const assets = [
|
|
173
|
+
...this.getMainAssets(),
|
|
174
|
+
...this.getChunkChildAssets([
|
|
175
|
+
...this.entrypoints,
|
|
176
|
+
...this.chunks
|
|
177
|
+
], 'preload'),
|
|
178
|
+
...this.getChunkChildAssets([
|
|
179
|
+
...this.entrypoints,
|
|
180
|
+
...this.chunks
|
|
181
|
+
], 'prefetch')
|
|
182
|
+
];
|
|
183
|
+
return uniqByUrl(assets).map((asset)=>`<link data-chunk="${asset.chunk}" rel="${asset.linkType}" as="${asset.scriptType}" href="${asset.url}"${extraPropsToString(extraProps)}>`).join('');
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const trimSlashes = (value)=>String(value).replace(/^\/+|\/+$/gu, '');
|
|
2
|
+
const normalizeSeparators = (value)=>String(value).replace(/\\+/gu, '/');
|
|
3
|
+
export const sep = '/';
|
|
4
|
+
export const delimiter = ':';
|
|
5
|
+
export function isAbsolute(filePath) {
|
|
6
|
+
return normalizeSeparators(filePath).startsWith('/');
|
|
7
|
+
}
|
|
8
|
+
export function normalize(filePath) {
|
|
9
|
+
const normalized = normalizeSeparators(filePath);
|
|
10
|
+
const absolute = isAbsolute(normalized);
|
|
11
|
+
const parts = [];
|
|
12
|
+
for (const part of normalized.split('/'))if (part && '.' !== part) {
|
|
13
|
+
if ('..' === part) {
|
|
14
|
+
if (parts.length > 0 && '..' !== parts[parts.length - 1]) parts.pop();
|
|
15
|
+
else if (!absolute) parts.push(part);
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
parts.push(part);
|
|
19
|
+
}
|
|
20
|
+
const joined = parts.join('/');
|
|
21
|
+
if (absolute) return joined ? `/${joined}` : '/';
|
|
22
|
+
return joined || '.';
|
|
23
|
+
}
|
|
24
|
+
export function join(...segments) {
|
|
25
|
+
const joined = segments.map(normalizeSeparators).filter(Boolean).map((segment, index)=>0 === index ? segment : trimSlashes(segment)).filter(Boolean).join('/');
|
|
26
|
+
return joined ? normalize(joined) : '.';
|
|
27
|
+
}
|
|
28
|
+
export function resolve(...segments) {
|
|
29
|
+
const joined = join(...segments);
|
|
30
|
+
return joined.startsWith('/') ? joined : `/${joined}`;
|
|
31
|
+
}
|
|
32
|
+
export function dirname(filePath) {
|
|
33
|
+
const normalized = normalizeSeparators(filePath).replace(/\/+$/u, '');
|
|
34
|
+
const index = normalized.lastIndexOf('/');
|
|
35
|
+
if (index <= 0) return '/';
|
|
36
|
+
return normalized.slice(0, index);
|
|
37
|
+
}
|
|
38
|
+
export function basename(filePath, suffix = '') {
|
|
39
|
+
const normalized = normalizeSeparators(filePath).replace(/\/+$/u, '');
|
|
40
|
+
const base = normalized.slice(normalized.lastIndexOf('/') + 1);
|
|
41
|
+
return suffix && base.endsWith(suffix) ? base.slice(0, -suffix.length) : base;
|
|
42
|
+
}
|
|
43
|
+
export function extname(filePath) {
|
|
44
|
+
const base = basename(filePath);
|
|
45
|
+
const index = base.lastIndexOf('.');
|
|
46
|
+
if (index <= 0) return '';
|
|
47
|
+
return base.slice(index);
|
|
48
|
+
}
|
|
49
|
+
export default {
|
|
50
|
+
basename,
|
|
51
|
+
delimiter,
|
|
52
|
+
dirname,
|
|
53
|
+
extname,
|
|
54
|
+
isAbsolute,
|
|
55
|
+
join,
|
|
56
|
+
normalize,
|
|
57
|
+
resolve,
|
|
58
|
+
sep
|
|
59
|
+
};
|
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -40,6 +44,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
40
44
|
resolveESMDependency: ()=>resolveESMDependency
|
|
41
45
|
});
|
|
42
46
|
const external_node_module_namespaceObject = require("node:module");
|
|
47
|
+
const external_node_url_namespaceObject = require("node:url");
|
|
43
48
|
const utils_namespaceObject = require("@modern-js/utils");
|
|
44
49
|
const external_path_namespaceObject = require("path");
|
|
45
50
|
var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
|
|
@@ -67,43 +72,17 @@ const getProjectUsage = (appDirectory, distDirectory, metaName)=>{
|
|
|
67
72
|
};
|
|
68
73
|
const getTemplatePath = (file)=>external_path_default().join(__dirname, '../platforms/templates', file);
|
|
69
74
|
const readTemplate = async (file)=>(await utils_namespaceObject.fs.readFile(getTemplatePath(file))).toString();
|
|
70
|
-
const localRequire = (0, external_node_module_namespaceObject.createRequire)(external_path_default().join(__dirname, 'package.json'));
|
|
71
|
-
const findNearestPackageJson = (resolvedEntry)=>{
|
|
72
|
-
let currentDir = external_path_default().dirname(resolvedEntry);
|
|
73
|
-
while(currentDir !== external_path_default().dirname(currentDir)){
|
|
74
|
-
const manifestPath = external_path_default().join(currentDir, 'package.json');
|
|
75
|
-
if (utils_namespaceObject.fs.existsSync(manifestPath)) return manifestPath;
|
|
76
|
-
currentDir = external_path_default().dirname(currentDir);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
const splitPackageSpecifier = (entry)=>{
|
|
80
|
-
const segments = entry.split('/');
|
|
81
|
-
if (entry.startsWith('@')) {
|
|
82
|
-
const [scope, name, ...rest] = segments;
|
|
83
|
-
return {
|
|
84
|
-
packageName: `${scope}/${name}`,
|
|
85
|
-
exportKey: rest.length > 0 ? `./${rest.join('/')}` : '.'
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
const [name, ...rest] = segments;
|
|
89
|
-
return {
|
|
90
|
-
packageName: name,
|
|
91
|
-
exportKey: rest.length > 0 ? `./${rest.join('/')}` : '.'
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
75
|
const resolveESMDependency = async (entry)=>{
|
|
76
|
+
const conditions = new Set([
|
|
77
|
+
'node',
|
|
78
|
+
'import',
|
|
79
|
+
'module',
|
|
80
|
+
'default'
|
|
81
|
+
]);
|
|
95
82
|
try {
|
|
96
|
-
const
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
if (!packageJsonPath) return normalizePath(resolvedEntry);
|
|
100
|
-
const packageDir = external_path_default().dirname(packageJsonPath);
|
|
101
|
-
const packageJson = utils_namespaceObject.fs.readJSONSync(packageJsonPath);
|
|
102
|
-
const exportConfig = packageJson.exports?.[exportKey];
|
|
103
|
-
if ('string' == typeof exportConfig) return normalizePath(external_path_default().join(packageDir, exportConfig));
|
|
104
|
-
const esmExportPath = exportConfig?.node?.import || exportConfig?.import || exportConfig?.default;
|
|
105
|
-
if ('string' == typeof esmExportPath) return normalizePath(external_path_default().join(packageDir, esmExportPath));
|
|
106
|
-
return normalizePath(resolvedEntry);
|
|
83
|
+
const resolverPath = (0, external_node_url_namespaceObject.pathToFileURL)((0, external_node_module_namespaceObject.createRequire)(__filename).resolve('import-meta-resolve')).href;
|
|
84
|
+
const { moduleResolve } = await (0, utils_namespaceObject.dynamicImport)(resolverPath);
|
|
85
|
+
return normalizePath(moduleResolve(entry, (0, external_node_url_namespaceObject.pathToFileURL)(`${__dirname}/`), conditions, false).pathname.replace(/^\/(\w):/, '$1:'));
|
|
107
86
|
} catch (err) {}
|
|
108
87
|
};
|
|
109
88
|
exports.getProjectUsage = __webpack_exports__.getProjectUsage;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -10,11 +10,15 @@ var __webpack_require__ = {};
|
|
|
10
10
|
};
|
|
11
11
|
})();
|
|
12
12
|
(()=>{
|
|
13
|
-
__webpack_require__.d = (exports1,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
18
22
|
};
|
|
19
23
|
})();
|
|
20
24
|
(()=>{
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
+
var define = (defs, kind)=>{
|
|
6
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
[kind]: defs[key]
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
define(getters, "get");
|
|
12
|
+
define(values, "value");
|
|
9
13
|
};
|
|
10
14
|
})();
|
|
11
15
|
(()=>{
|
|
@@ -23,9 +27,6 @@ var __webpack_require__ = {};
|
|
|
23
27
|
})();
|
|
24
28
|
var __webpack_exports__ = {};
|
|
25
29
|
__webpack_require__.r(__webpack_exports__);
|
|
26
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
-
default: ()=>__rspack_default_export
|
|
28
|
-
});
|
|
29
30
|
const __rspack_default_export = ()=>({
|
|
30
31
|
name: '@modern-js/plugin-server-runtime',
|
|
31
32
|
setup (api) {
|
|
@@ -40,6 +41,9 @@ const __rspack_default_export = ()=>({
|
|
|
40
41
|
}));
|
|
41
42
|
}
|
|
42
43
|
});
|
|
44
|
+
__webpack_require__.d(__webpack_exports__, {}, {
|
|
45
|
+
default: __rspack_default_export
|
|
46
|
+
});
|
|
43
47
|
exports["default"] = __webpack_exports__["default"];
|
|
44
48
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
45
49
|
"default"
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __webpack_require__ = {};
|
|
3
3
|
(()=>{
|
|
4
|
-
__webpack_require__.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
__webpack_require__.n = (module)=>{
|
|
5
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
6
|
+
__webpack_require__.d(getter, {
|
|
7
|
+
a: getter
|
|
8
8
|
});
|
|
9
|
+
return getter;
|
|
10
|
+
};
|
|
11
|
+
})();
|
|
12
|
+
(()=>{
|
|
13
|
+
__webpack_require__.d = (exports1, getters, values)=>{
|
|
14
|
+
var define = (defs, kind)=>{
|
|
15
|
+
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
[kind]: defs[key]
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
define(getters, "get");
|
|
21
|
+
define(values, "value");
|
|
9
22
|
};
|
|
10
23
|
})();
|
|
11
24
|
(()=>{
|
|
@@ -27,9 +40,84 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
27
40
|
createPresetUltramodernConfig: ()=>createPresetUltramodernConfig,
|
|
28
41
|
presetUltramodern: ()=>presetUltramodern
|
|
29
42
|
});
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
43
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
44
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
45
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
46
|
+
const cli_namespaceObject = require("@modern-js/plugin/cli");
|
|
47
|
+
const DEFAULT_OTLP_ENDPOINT = 'http://127.0.0.1:4318/v1/logs';
|
|
48
|
+
const DEFAULT_VICTORIA_METRICS_ENDPOINT = 'http://127.0.0.1:8428/api/v1/import/prometheus';
|
|
49
|
+
const resolveReactRouterPackageDir = (appDirectory)=>{
|
|
50
|
+
const localRequire = (0, external_node_module_namespaceObject.createRequire)(external_node_path_default().join(appDirectory, 'package.json'));
|
|
51
|
+
try {
|
|
52
|
+
const reactRouterDomPackageJson = localRequire.resolve('react-router-dom/package.json', {
|
|
53
|
+
paths: [
|
|
54
|
+
appDirectory
|
|
55
|
+
]
|
|
56
|
+
});
|
|
57
|
+
const reactRouterPackageJson = localRequire.resolve('react-router/package.json', {
|
|
58
|
+
paths: [
|
|
59
|
+
external_node_path_default().dirname(reactRouterDomPackageJson)
|
|
60
|
+
]
|
|
61
|
+
});
|
|
62
|
+
return external_node_path_default().dirname(reactRouterPackageJson);
|
|
63
|
+
} catch {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const setReactRouterBridgeSafeAliases = (chain, { isProd })=>{
|
|
68
|
+
const chainContext = chain.get('context');
|
|
69
|
+
const appDirectory = 'string' == typeof chainContext && chainContext.length > 0 ? chainContext : process.cwd();
|
|
70
|
+
const reactRouterPackageDir = resolveReactRouterPackageDir(appDirectory);
|
|
71
|
+
if (!reactRouterPackageDir) return;
|
|
72
|
+
const productionEntry = external_node_path_default().join(reactRouterPackageDir, 'dist/production/index.mjs');
|
|
73
|
+
const developmentEntry = external_node_path_default().join(reactRouterPackageDir, 'dist/development/index.mjs');
|
|
74
|
+
chain.resolve.alias.set('react-router$', isProd ? productionEntry : developmentEntry);
|
|
75
|
+
chain.resolve.alias.set('react-router/dist/production/index.js', productionEntry);
|
|
76
|
+
chain.resolve.alias.set('react-router/dist/development/index.js', developmentEntry);
|
|
77
|
+
};
|
|
78
|
+
const createPresetUltramodernConfig = (options = {})=>{
|
|
79
|
+
const { appId = 'app', enableBffRequestId = true, enableTelemetry = true, enableTelemetryExporters, otlpEndpoint = process.env.MODERN_TELEMETRY_OTLP_ENDPOINT, victoriaMetricsEndpoint = process.env.MODERN_TELEMETRY_VICTORIA_ENDPOINT, telemetryFailLoudStartup = true, enableModuleFederationSSR = true } = options;
|
|
80
|
+
const server = {};
|
|
81
|
+
if (enableTelemetry) {
|
|
82
|
+
server.telemetry = {
|
|
83
|
+
enabled: true,
|
|
84
|
+
failLoudStartup: telemetryFailLoudStartup
|
|
85
|
+
};
|
|
86
|
+
if (false !== enableTelemetryExporters) {
|
|
87
|
+
const exporters = {};
|
|
88
|
+
if (true === enableTelemetryExporters || otlpEndpoint) exporters.otlp = {
|
|
89
|
+
enabled: true,
|
|
90
|
+
endpoint: otlpEndpoint || DEFAULT_OTLP_ENDPOINT
|
|
91
|
+
};
|
|
92
|
+
if (true === enableTelemetryExporters || victoriaMetricsEndpoint) exporters.victoriaMetrics = {
|
|
93
|
+
enabled: true,
|
|
94
|
+
endpoint: victoriaMetricsEndpoint || DEFAULT_VICTORIA_METRICS_ENDPOINT
|
|
95
|
+
};
|
|
96
|
+
if (Object.keys(exporters).length > 0) server.telemetry.exporters = exporters;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (enableModuleFederationSSR) server.ssr = {
|
|
100
|
+
mode: 'stream',
|
|
101
|
+
moduleFederationAppSSR: true
|
|
102
|
+
};
|
|
103
|
+
const presetConfig = {
|
|
104
|
+
output: {
|
|
105
|
+
precompress: true
|
|
106
|
+
},
|
|
107
|
+
server,
|
|
108
|
+
tools: {
|
|
109
|
+
bundlerChain: setReactRouterBridgeSafeAliases
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
if (enableBffRequestId) presetConfig.bff = {
|
|
113
|
+
requestId: appId
|
|
114
|
+
};
|
|
115
|
+
return presetConfig;
|
|
116
|
+
};
|
|
117
|
+
const presetUltramodern = (config, options = {})=>(0, cli_namespaceObject.mergeConfig)([
|
|
118
|
+
createPresetUltramodernConfig(options),
|
|
119
|
+
config
|
|
120
|
+
]);
|
|
33
121
|
exports.createPresetUltramodernConfig = __webpack_exports__.createPresetUltramodernConfig;
|
|
34
122
|
exports.presetUltramodern = __webpack_exports__.presetUltramodern;
|
|
35
123
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|