@bleedingdev/modern-js-app-tools 3.2.0-ultramodern.1 → 3.2.0-ultramodern.100
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 +43 -1
- package/dist/cjs/builder/generator/getBuilderEnvironments.js +191 -8
- package/dist/cjs/builder/shared/builderPlugins/adapterBasic.js +41 -5
- package/dist/cjs/builder/shared/builderPlugins/adapterSSR.js +3 -1
- package/dist/cjs/plugins/deploy/index.js +17 -6
- package/dist/cjs/plugins/deploy/platforms/cloudflare.js +222 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.mjs +438 -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/rsbuild.js +3 -0
- package/dist/esm/baseline.mjs +33 -1
- 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/adapterSSR.mjs +3 -1
- package/dist/esm/plugins/deploy/index.mjs +10 -4
- package/dist/esm/plugins/deploy/platforms/cloudflare.mjs +178 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +438 -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/rsbuild.mjs +5 -2
- package/dist/esm-node/baseline.mjs +33 -1
- 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/adapterSSR.mjs +3 -1
- package/dist/esm-node/plugins/deploy/index.mjs +10 -4
- package/dist/esm-node/plugins/deploy/platforms/cloudflare.mjs +179 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +438 -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/rsbuild.mjs +5 -2
- package/dist/types/baseline.d.ts +46 -0
- package/dist/types/builder/builder-rspack/index.d.ts +2 -0
- package/dist/types/builder/generator/adapterCopy.d.ts +3 -0
- package/dist/types/builder/generator/createBuilderProviderConfig.d.ts +3 -0
- package/dist/types/builder/generator/createCopyPattern.d.ts +16 -0
- package/dist/types/builder/generator/getBuilderEnvironments.d.ts +6 -0
- package/dist/types/builder/generator/index.d.ts +8 -0
- package/dist/types/builder/index.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterBasic.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterHtml.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterPrecompress.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/adapterSSR.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/builderHooks.d.ts +3 -0
- package/dist/types/builder/shared/builderPlugins/index.d.ts +5 -0
- package/dist/types/builder/shared/bundlerPlugins/HtmlAsyncChunkPlugin.d.ts +7 -0
- package/dist/types/builder/shared/bundlerPlugins/HtmlBottomTemplate.d.ts +9 -0
- package/dist/types/builder/shared/bundlerPlugins/RouterPlugin.d.ts +32 -0
- package/dist/types/builder/shared/bundlerPlugins/index.d.ts +3 -0
- package/dist/types/builder/shared/createCopyInfo.d.ts +8 -0
- package/dist/types/builder/shared/index.d.ts +3 -0
- package/dist/types/builder/shared/loaders/serverModuleLoader.d.ts +3 -0
- package/dist/types/builder/shared/types.d.ts +6 -0
- package/dist/types/commands/build.d.ts +4 -0
- package/dist/types/commands/deploy.d.ts +3 -0
- package/dist/types/commands/dev.d.ts +9 -0
- package/dist/types/commands/index.d.ts +10 -0
- package/dist/types/commands/info.d.ts +18 -0
- package/dist/types/commands/inspect.d.ts +4 -0
- package/dist/types/commands/runtime.d.ts +11 -0
- package/dist/types/commands/serve.d.ts +8 -0
- package/dist/types/compat/hooks.d.ts +7 -0
- package/dist/types/compat/index.d.ts +2 -0
- package/dist/types/compat/utils.d.ts +13 -0
- package/dist/types/config/default.d.ts +3 -0
- package/dist/types/config/index.d.ts +2 -0
- package/dist/types/config/initialize/index.d.ts +3 -0
- package/dist/types/config/initialize/inits.d.ts +4 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/defineConfig.d.ts +11 -0
- package/dist/types/esm/register-esm.d.mts +5 -0
- package/dist/types/esm/ts-paths-loader.d.mts +6 -0
- package/dist/types/exports/server.d.ts +1 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/locale/en.d.ts +44 -0
- package/dist/types/locale/index.d.ts +3 -0
- package/dist/types/locale/zh.d.ts +44 -0
- package/dist/types/plugins/analyze/constants.d.ts +3 -0
- package/dist/types/plugins/analyze/getBundleEntry.d.ts +4 -0
- package/dist/types/plugins/analyze/getFileSystemEntry.d.ts +7 -0
- package/dist/types/plugins/analyze/getHtmlTemplate.d.ts +27 -0
- package/dist/types/plugins/analyze/getServerRoutes.d.ts +8 -0
- package/dist/types/plugins/analyze/index.d.ts +3 -0
- package/dist/types/plugins/analyze/isDefaultExportFunction.d.ts +1 -0
- package/dist/types/plugins/analyze/templates.d.ts +5 -0
- package/dist/types/plugins/analyze/utils.d.ts +10 -0
- package/dist/types/plugins/deploy/index.d.ts +6 -0
- package/dist/types/plugins/deploy/platforms/cloudflare.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/gh-pages.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/netlify.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/node.d.ts +2 -0
- package/dist/types/plugins/deploy/platforms/platform.d.ts +17 -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/platforms/templates/netlify-entry.d.cts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/netlify-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/node-entry.d.cts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/node-entry.d.mts +1 -0
- package/dist/types/plugins/deploy/platforms/templates/vercel-entry.d.cts +2 -0
- package/dist/types/plugins/deploy/platforms/templates/vercel-entry.d.mts +2 -0
- package/dist/types/plugins/deploy/platforms/vercel.d.ts +2 -0
- package/dist/types/plugins/deploy/types.d.ts +3 -0
- package/dist/types/plugins/deploy/utils/generator.d.ts +24 -0
- package/dist/types/plugins/deploy/utils/index.d.ts +16 -0
- package/dist/types/plugins/initialize/index.d.ts +3 -0
- package/dist/types/plugins/serverBuild.d.ts +3 -0
- package/dist/types/plugins/serverRuntime.d.ts +3 -0
- package/dist/types/presetUltramodern.d.ts +6 -0
- package/dist/types/rsbuild.d.ts +12 -0
- package/dist/types/run/index.d.ts +20 -0
- package/dist/types/types/config/deploy.d.ts +46 -0
- package/dist/types/types/config/dev.d.ts +55 -0
- package/dist/types/types/config/experiments.d.ts +3 -0
- package/dist/types/types/config/html.d.ts +3 -0
- package/dist/types/types/config/index.d.ts +48 -0
- package/dist/types/types/config/output.d.ts +61 -0
- package/dist/types/types/config/performance.d.ts +3 -0
- package/dist/types/types/config/resolve.d.ts +2 -0
- package/dist/types/types/config/security.d.ts +2 -0
- package/dist/types/types/config/source.d.ts +61 -0
- package/dist/types/types/config/testing.d.ts +8 -0
- package/dist/types/types/config/tools.d.ts +21 -0
- package/dist/types/types/index.d.ts +10 -0
- package/dist/types/types/plugin.d.ts +114 -0
- package/dist/types/types/utils.d.ts +1 -0
- package/dist/types/ultramodern/designSystem.d.ts +54 -0
- package/dist/types/utils/config.d.ts +2 -0
- package/dist/types/utils/createServer.d.ts +5 -0
- package/dist/types/utils/env.d.ts +2 -0
- package/dist/types/utils/generateWatchFiles.d.ts +2 -0
- package/dist/types/utils/getConfigFile.d.ts +1 -0
- package/dist/types/utils/getSelectedEntries.d.ts +5 -0
- package/dist/types/utils/initAppContext.d.ts +31 -0
- package/dist/types/utils/loadPlugins.d.ts +13 -0
- package/dist/types/utils/printInstructions.d.ts +3 -0
- package/dist/types/utils/register.d.ts +19 -0
- package/dist/types/utils/restart.d.ts +2 -0
- package/dist/types/utils/routes.d.ts +4 -0
- package/dist/types/utils/types.d.ts +49 -0
- package/package.json +18 -17
package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-loadable-server.mjs
ADDED
|
@@ -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
|
+
};
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { parseRspackConfig } from "@modern-js/builder";
|
|
3
|
+
import { INTERNAL_RUNTIME_PLUGINS } from "@modern-js/utils";
|
|
3
4
|
import { builderPluginAdapterBasic, builderPluginAdapterHooks } from "./builder/shared/builderPlugins/index.mjs";
|
|
4
5
|
import { DEFAULT_CONFIG_FILE } from "./constants.mjs";
|
|
5
6
|
import { getConfigFile } from "./utils/getConfigFile.mjs";
|
|
7
|
+
import { loadInternalPlugins } from "./utils/loadPlugins.mjs";
|
|
6
8
|
import { __webpack_require__ } from "./rslib-runtime.mjs";
|
|
7
9
|
import * as __rspack_external__modern_js_plugin_cli_caa09fa2 from "@modern-js/plugin/cli";
|
|
8
10
|
__webpack_require__.add({
|
|
9
|
-
"@modern-js/plugin/cli?
|
|
11
|
+
"@modern-js/plugin/cli?8936" (module) {
|
|
10
12
|
module.exports = __rspack_external__modern_js_plugin_cli_caa09fa2;
|
|
11
13
|
}
|
|
12
14
|
});
|
|
13
15
|
const MODERN_META_NAME = 'modern-js';
|
|
14
|
-
const { createConfigOptions: createConfigOptions } = __webpack_require__("@modern-js/plugin/cli?
|
|
16
|
+
const { createConfigOptions: createConfigOptions } = __webpack_require__("@modern-js/plugin/cli?8936");
|
|
15
17
|
async function resolveModernRsbuildConfig(options) {
|
|
16
18
|
const { cwd = process.cwd(), metaName = MODERN_META_NAME } = options;
|
|
17
19
|
const configFile = options.configPath || getConfigFile(void 0, cwd);
|
|
@@ -20,6 +22,7 @@ async function resolveModernRsbuildConfig(options) {
|
|
|
20
22
|
command: options.command,
|
|
21
23
|
cwd,
|
|
22
24
|
configFile,
|
|
25
|
+
internalPlugins: await loadInternalPlugins(cwd, INTERNAL_RUNTIME_PLUGINS),
|
|
23
26
|
metaName,
|
|
24
27
|
modifyModernConfig: options.modifyModernConfig
|
|
25
28
|
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { AppUserConfig } from './types';
|
|
2
|
+
export interface AppBaselineOptions {
|
|
3
|
+
/**
|
|
4
|
+
* Stable producer identity used by BFF cross-project clients.
|
|
5
|
+
* @default "app"
|
|
6
|
+
*/
|
|
7
|
+
appId?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Enable BFF requestId contract by default.
|
|
10
|
+
* @default true
|
|
11
|
+
*/
|
|
12
|
+
enableBffRequestId?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Enable telemetry contract by default.
|
|
15
|
+
* Exporters are still configured separately by applications.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
18
|
+
enableTelemetry?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Enable telemetry exporters by default.
|
|
21
|
+
* @default true
|
|
22
|
+
*/
|
|
23
|
+
enableTelemetryExporters?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* OTLP exporter endpoint.
|
|
26
|
+
* @default process.env.MODERN_TELEMETRY_OTLP_ENDPOINT || 'http://127.0.0.1:4318/v1/logs'
|
|
27
|
+
*/
|
|
28
|
+
otlpEndpoint?: string;
|
|
29
|
+
/**
|
|
30
|
+
* VictoriaMetrics exporter endpoint.
|
|
31
|
+
* @default process.env.MODERN_TELEMETRY_VICTORIA_ENDPOINT || 'http://127.0.0.1:8428/api/v1/import/prometheus'
|
|
32
|
+
*/
|
|
33
|
+
victoriaMetricsEndpoint?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Enable fail-loud startup probing for telemetry exporters.
|
|
36
|
+
* @default true
|
|
37
|
+
*/
|
|
38
|
+
telemetryFailLoudStartup?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Enable app-level Module Federation SSR handshake by default.
|
|
41
|
+
* @default true
|
|
42
|
+
*/
|
|
43
|
+
enableModuleFederationSSR?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare const createAppBaselineConfig: (options?: AppBaselineOptions) => AppUserConfig;
|
|
46
|
+
export declare const withAppBaseline: (config: AppUserConfig, options?: AppBaselineOptions) => AppUserConfig;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Rspack, RspackChain } from '@rsbuild/core';
|
|
2
|
+
import type { AppNormalizedConfig } from '../../types';
|
|
3
|
+
import type { AppToolsContext } from '../../types/plugin';
|
|
4
|
+
export declare function createPublicPattern(appContext: AppToolsContext, config: AppNormalizedConfig, chain: RspackChain): {
|
|
5
|
+
info: (file: {
|
|
6
|
+
sourceFilename: string;
|
|
7
|
+
}) => {
|
|
8
|
+
minimized: boolean;
|
|
9
|
+
};
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
context: string;
|
|
13
|
+
noErrorOnMissing: boolean;
|
|
14
|
+
transform: (content: Buffer, absoluteFrom: string) => string | Buffer<ArrayBufferLike>;
|
|
15
|
+
};
|
|
16
|
+
export declare function createUploadPattern(appContext: AppToolsContext, config: AppNormalizedConfig): Rspack.CopyRspackPluginOptions['patterns']['0'];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { AppNormalizedConfig } from '../../types';
|
|
2
|
+
import type { AppToolsContext } from '../../types/plugin';
|
|
3
|
+
export declare function getBuilderEnvironments(normalizedConfig: AppNormalizedConfig, appContext: AppToolsContext, tempBuilderConfig: Omit<AppNormalizedConfig, 'plugins'>): {
|
|
4
|
+
environments: Record<string, import("@rsbuild/core").EnvironmentConfig>;
|
|
5
|
+
builderConfig: Omit<AppNormalizedConfig, "plugins">;
|
|
6
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type BundlerType } from '@modern-js/builder';
|
|
2
|
+
import type { BuilderOptions } from '../shared';
|
|
3
|
+
/**
|
|
4
|
+
* @param options BuilderOptions
|
|
5
|
+
* @param bundlerType BundlerType
|
|
6
|
+
* @returns BuilderInstance
|
|
7
|
+
*/
|
|
8
|
+
export declare function generateBuilder(options: BuilderOptions, bundlerType: BundlerType): Promise<any>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function createBuilderGenerator(): Promise<typeof import("./builder-rspack/index.js").createRspackBuilderForModern>;
|
|
2
|
+
export { parseRspackConfig } from '@modern-js/builder';
|
|
3
|
+
export { builderPluginAdapterBasic, builderPluginAdapterHooks, } from './shared/builderPlugins';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Rspack } from '@modern-js/builder';
|
|
2
|
+
export declare class BottomTemplatePlugin {
|
|
3
|
+
htmlPlugin: typeof Rspack.HtmlRspackPlugin;
|
|
4
|
+
bottomTemplateReg: RegExp;
|
|
5
|
+
bodyRegExp: RegExp;
|
|
6
|
+
name: string;
|
|
7
|
+
constructor(htmlPlugin: typeof Rspack.HtmlRspackPlugin);
|
|
8
|
+
apply(compiler: Rspack.Compiler): void;
|
|
9
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Rspack, ScriptLoading } from '@rsbuild/core';
|
|
2
|
+
export interface RouteAssets {
|
|
3
|
+
[routeId: string]: {
|
|
4
|
+
chunkIds?: (string | number)[];
|
|
5
|
+
assets?: string[];
|
|
6
|
+
referenceCssAssets?: string[];
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
type Compiler = Rspack.Compiler;
|
|
10
|
+
type Options = {
|
|
11
|
+
HtmlBundlerPlugin: typeof Rspack.HtmlRspackPlugin;
|
|
12
|
+
staticJsDir?: string;
|
|
13
|
+
enableInlineRouteManifests: boolean;
|
|
14
|
+
disableFilenameHash?: boolean;
|
|
15
|
+
scriptLoading?: ScriptLoading;
|
|
16
|
+
nonce?: string;
|
|
17
|
+
};
|
|
18
|
+
export declare class RouterPlugin {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
private HtmlBundlerPlugin;
|
|
21
|
+
private enableInlineRouteManifests;
|
|
22
|
+
private staticJsDir;
|
|
23
|
+
private disableFilenameHash?;
|
|
24
|
+
private scriptLoading?;
|
|
25
|
+
private nonce?;
|
|
26
|
+
constructor({ staticJsDir, HtmlBundlerPlugin, enableInlineRouteManifests, disableFilenameHash, scriptLoading, nonce, }: Options);
|
|
27
|
+
private isTargetNodeOrWebWorker;
|
|
28
|
+
private getEntryChunks;
|
|
29
|
+
private getEntryChunkFiles;
|
|
30
|
+
apply(compiler: Compiler): void;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { AppNormalizedConfig } from '../../types';
|
|
2
|
+
import type { AppToolsContext } from '../../types/plugin';
|
|
3
|
+
export declare function createCopyInfo(appContext: AppToolsContext, config: AppNormalizedConfig): {
|
|
4
|
+
configDir: string;
|
|
5
|
+
uploadDir: string;
|
|
6
|
+
publicDir: string;
|
|
7
|
+
customPublicDirs: any;
|
|
8
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
2
|
+
import { type ApplyPlugins } from '@modern-js/server';
|
|
3
|
+
import type { AppTools } from '../types';
|
|
4
|
+
import type { DevOptions } from '../utils/types';
|
|
5
|
+
interface ExtraServerOptions {
|
|
6
|
+
applyPlugins?: ApplyPlugins;
|
|
7
|
+
}
|
|
8
|
+
export declare const dev: (api: CLIPluginAPI<AppTools>, options: DevOptions, devServerOptions?: ExtraServerOptions) => Promise<void>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
2
|
+
import type { Command } from '@modern-js/utils';
|
|
3
|
+
import type { AppTools } from '../types';
|
|
4
|
+
export declare const devCommand: (program: Command, api: CLIPluginAPI<AppTools>) => Promise<void>;
|
|
5
|
+
export declare const buildCommand: (program: Command, api: CLIPluginAPI<AppTools>) => Promise<void>;
|
|
6
|
+
export declare const serverCommand: (program: Command, api: CLIPluginAPI<AppTools>) => void;
|
|
7
|
+
export declare const deployCommand: (program: Command, api: CLIPluginAPI<AppTools>) => void;
|
|
8
|
+
export declare const inspectCommand: (program: Command, api: CLIPluginAPI<AppTools>) => void;
|
|
9
|
+
export declare const infoCommand: (program: Command, api: CLIPluginAPI<AppTools>) => void;
|
|
10
|
+
export declare const runtimeOperationsCommand: (program: Command, api: CLIPluginAPI<AppTools>) => Promise<void>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
2
|
+
import type { AppTools } from '../types';
|
|
3
|
+
import type { InfoOptions } from '../utils/types';
|
|
4
|
+
export interface EntryInfo {
|
|
5
|
+
entryName: string;
|
|
6
|
+
isMainEntry: boolean;
|
|
7
|
+
entry: string;
|
|
8
|
+
isAutoMount: boolean;
|
|
9
|
+
isCustomSourceEntry: boolean;
|
|
10
|
+
customEntry: boolean;
|
|
11
|
+
ssr: boolean | 'stream' | 'string';
|
|
12
|
+
ssg: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface ProjectInfo {
|
|
15
|
+
entries: EntryInfo[];
|
|
16
|
+
apiOnly: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare const info: (api: CLIPluginAPI<AppTools>, options?: InfoOptions) => Promise<void>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
2
|
+
import type { Command } from '@modern-js/utils';
|
|
3
|
+
import type { AppTools } from '../types';
|
|
4
|
+
import type { RuntimeFallbackSignalOptions } from '../utils/types';
|
|
5
|
+
export declare const resolveRuntimeEndpoint: (input: string | undefined, defaultPath: string) => string;
|
|
6
|
+
export declare const resolveToken: ({ token, tokenEnv, }: {
|
|
7
|
+
token?: string;
|
|
8
|
+
tokenEnv?: string;
|
|
9
|
+
}) => string | undefined;
|
|
10
|
+
export declare const createRuntimeFallbackSignalPayload: (options: RuntimeFallbackSignalOptions) => Record<string, unknown>;
|
|
11
|
+
export declare const runtimeCommand: (program: Command, _api: CLIPluginAPI<AppTools>) => Promise<void>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
2
|
+
import { createProdServer } from '@modern-js/prod-server';
|
|
3
|
+
import type { AppTools } from '../types';
|
|
4
|
+
type ExtraServerOptions = {
|
|
5
|
+
launcher?: typeof createProdServer;
|
|
6
|
+
};
|
|
7
|
+
export declare const serve: (api: CLIPluginAPI<AppTools>, serverOptions?: ExtraServerOptions) => Promise<void>;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { InternalContext } from '@modern-js/plugin';
|
|
2
|
+
import type { AppTools } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* old plugin useHookRunners function result
|
|
5
|
+
*/
|
|
6
|
+
export declare function getHookRunners(context: InternalContext<AppTools>): Record<string, any>;
|
|
7
|
+
export declare function handleSetupResult(setupResult: Record<string, (...args: any) => any>, api: Record<string, any>): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Maps old plugin hook function names to new plugin API names
|
|
3
|
+
*/
|
|
4
|
+
export declare function transformHookRunner(hookRunnerName: string): string | undefined;
|
|
5
|
+
/**
|
|
6
|
+
* Note:
|
|
7
|
+
* isMultiple Indicates whether the function parameter represents multiple values.
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformHookParams(hookRunnerName: string, params: any): {
|
|
10
|
+
isMultiple: boolean;
|
|
11
|
+
params: any;
|
|
12
|
+
};
|
|
13
|
+
export declare function transformHookResult(hookRunnerName: string, result: any): any;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AppNormalizedConfig } from '../../types';
|
|
2
|
+
import type { AppToolsContext } from '../../types/plugin';
|
|
3
|
+
export declare function initHtmlConfig(config: AppNormalizedConfig, appContext: AppToolsContext): AppNormalizedConfig['html'];
|
|
4
|
+
export declare function initSourceConfig(config: AppNormalizedConfig, appContext: AppToolsContext): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { AppUserConfig } from './types';
|
|
2
|
+
export type ConfigParams = {
|
|
3
|
+
env: string;
|
|
4
|
+
command: string;
|
|
5
|
+
};
|
|
6
|
+
export type UserConfigExport<Config> = Config | ((env: ConfigParams) => Config | Promise<Config>);
|
|
7
|
+
/**
|
|
8
|
+
* This function helps you to autocomplete configuration types.
|
|
9
|
+
* It accepts a direct config object, or a function that returns a config.
|
|
10
|
+
*/
|
|
11
|
+
export declare const defineConfig: (config: UserConfigExport<AppUserConfig>) => UserConfigExport<import("./types").AppToolsUserConfig>;
|