@bleedingdev/modern-js-app-tools 3.2.0-ultramodern.12 → 3.2.0-ultramodern.120
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 +51 -5
- 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 +9 -5
- package/dist/cjs/commands/info.js +9 -5
- package/dist/cjs/commands/inspect.js +12 -8
- package/dist/cjs/commands/runtime.js +15 -11
- 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 +21 -16
- 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 +384 -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 +502 -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 +9 -5
- 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 +9 -5
- package/dist/cjs/rsbuild.js +12 -5
- package/dist/cjs/run/index.js +9 -5
- package/dist/cjs/types/config/index.js +9 -5
- 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 +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/adapterHtml.mjs +1 -1
- 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 +336 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.mjs +502 -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/adapterHtml.mjs +1 -1
- 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 +337 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.mjs +502 -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/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/inspect.d.ts +1 -1
- 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/rsbuild.d.ts +1 -1
- package/dist/types/run/index.d.ts +1 -1
- package/dist/types/types/config/deploy.d.ts +56 -0
- package/dist/types/utils/getConfigFile.d.ts +1 -1
- package/dist/types/utils/loadPlugins.d.ts +2 -2
- package/package.json +22 -21
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
|
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { BuilderOptions } from '../shared';
|
|
2
|
-
export declare function createRspackBuilderForModern(options: BuilderOptions): Promise<
|
|
2
|
+
export declare function createRspackBuilderForModern(options: BuilderOptions): Promise<import("@rsbuild/core").RsbuildInstance>;
|
|
@@ -5,4 +5,4 @@ import type { BuilderOptions } from '../shared';
|
|
|
5
5
|
* @param bundlerType BundlerType
|
|
6
6
|
* @returns BuilderInstance
|
|
7
7
|
*/
|
|
8
|
-
export declare function generateBuilder(options: BuilderOptions, bundlerType: BundlerType): Promise<
|
|
8
|
+
export declare function generateBuilder(options: BuilderOptions, bundlerType: BundlerType): Promise<import("@rsbuild/core").RsbuildInstance>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
2
2
|
import type { AppTools } from '../types';
|
|
3
3
|
import type { InspectOptions } from '../utils/types';
|
|
4
|
-
export declare const inspect: (api: CLIPluginAPI<AppTools>, options: InspectOptions) => Promise<
|
|
4
|
+
export declare const inspect: (api: CLIPluginAPI<AppTools>, options: InspectOptions) => Promise<import("@rsbuild/core").InspectConfigResult>;
|
|
@@ -1,3 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
declare const
|
|
1
|
+
import { I18n } from '@modern-js/i18n-utils';
|
|
2
|
+
declare const i18n: I18n;
|
|
3
|
+
declare const localeKeys: {
|
|
4
|
+
command: {
|
|
5
|
+
shared: {
|
|
6
|
+
analyze: string;
|
|
7
|
+
config: string;
|
|
8
|
+
skipBuild: string;
|
|
9
|
+
noNeedInstall: string;
|
|
10
|
+
};
|
|
11
|
+
dev: {
|
|
12
|
+
describe: string;
|
|
13
|
+
entry: string;
|
|
14
|
+
apiOnly: string;
|
|
15
|
+
webOnly: string;
|
|
16
|
+
selectEntry: string;
|
|
17
|
+
requireEntry: string;
|
|
18
|
+
};
|
|
19
|
+
build: {
|
|
20
|
+
describe: string;
|
|
21
|
+
watch: string;
|
|
22
|
+
};
|
|
23
|
+
serve: {
|
|
24
|
+
describe: string;
|
|
25
|
+
};
|
|
26
|
+
deploy: {
|
|
27
|
+
describe: string;
|
|
28
|
+
};
|
|
29
|
+
new: {
|
|
30
|
+
describe: string;
|
|
31
|
+
debug: string;
|
|
32
|
+
config: string;
|
|
33
|
+
distTag: string;
|
|
34
|
+
registry: string;
|
|
35
|
+
lang: string;
|
|
36
|
+
};
|
|
37
|
+
inspect: {
|
|
38
|
+
env: string;
|
|
39
|
+
output: string;
|
|
40
|
+
verbose: string;
|
|
41
|
+
};
|
|
42
|
+
info: {
|
|
43
|
+
describe: string;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
} | {
|
|
47
|
+
command: {
|
|
48
|
+
shared: {
|
|
49
|
+
analyze: string;
|
|
50
|
+
config: string;
|
|
51
|
+
skipBuild: string;
|
|
52
|
+
noNeedInstall: string;
|
|
53
|
+
};
|
|
54
|
+
dev: {
|
|
55
|
+
describe: string;
|
|
56
|
+
entry: string;
|
|
57
|
+
apiOnly: string;
|
|
58
|
+
webOnly: string;
|
|
59
|
+
selectEntry: string;
|
|
60
|
+
requireEntry: string;
|
|
61
|
+
};
|
|
62
|
+
build: {
|
|
63
|
+
describe: string;
|
|
64
|
+
watch: string;
|
|
65
|
+
};
|
|
66
|
+
serve: {
|
|
67
|
+
describe: string;
|
|
68
|
+
};
|
|
69
|
+
deploy: {
|
|
70
|
+
describe: string;
|
|
71
|
+
};
|
|
72
|
+
new: {
|
|
73
|
+
describe: string;
|
|
74
|
+
debug: string;
|
|
75
|
+
config: string;
|
|
76
|
+
distTag: string;
|
|
77
|
+
registry: string;
|
|
78
|
+
lang: string;
|
|
79
|
+
};
|
|
80
|
+
inspect: {
|
|
81
|
+
env: string;
|
|
82
|
+
output: string;
|
|
83
|
+
verbose: string;
|
|
84
|
+
};
|
|
85
|
+
info: {
|
|
86
|
+
describe: string;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
3
90
|
export { i18n, localeKeys };
|
|
@@ -2,6 +2,6 @@ import type { Entrypoint } from '@modern-js/types';
|
|
|
2
2
|
import type { AppNormalizedConfig } from '../../types';
|
|
3
3
|
import type { AppToolsContext, AppToolsHooks } from '../../types/plugin';
|
|
4
4
|
export type { Entrypoint };
|
|
5
|
-
export declare const hasEntry: (dir: string) =>
|
|
6
|
-
export declare const hasServerEntry: (dir: string) =>
|
|
5
|
+
export declare const hasEntry: (dir: string) => string | false;
|
|
6
|
+
export declare const hasServerEntry: (dir: string) => string | false;
|
|
7
7
|
export declare const getFileSystemEntry: (hooks: AppToolsHooks, appContext: AppToolsContext, config: AppNormalizedConfig) => Promise<Entrypoint[]>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const walkDirectory: (dir: string) => string[];
|
|
2
|
-
export declare const replaceWithAlias: (base: string, filePath: string, alias: string) =>
|
|
2
|
+
export declare const replaceWithAlias: (base: string, filePath: string, alias: string) => string;
|
|
3
3
|
export declare const parseModule: ({ source, filename, }: {
|
|
4
4
|
source: string;
|
|
5
5
|
filename: string;
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
import type { AppTools, CliPlugin } from '../../types';
|
|
1
|
+
import type { AppTools, AppToolsNormalizedConfig, CliPlugin } from '../../types';
|
|
2
|
+
import type { DeployTarget } from '../../types/config/deploy';
|
|
3
|
+
export declare const getSupportedDeployTargets: () => DeployTarget[];
|
|
4
|
+
export declare const resolveDeployTarget: (modernConfig: AppToolsNormalizedConfig, envDeployTarget?: string | undefined, detectedProvider?: import("std-env").ProviderName) => string;
|
|
2
5
|
declare const _default: () => CliPlugin<AppTools>;
|
|
3
6
|
export default _default;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function ChunkExtractorManager({ extractor, children }: {
|
|
3
|
+
children: any;
|
|
4
|
+
extractor: any;
|
|
5
|
+
}): React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
6
|
+
export declare class ChunkExtractor {
|
|
7
|
+
namespace: string;
|
|
8
|
+
stats: any;
|
|
9
|
+
publicPath: any;
|
|
10
|
+
outputPath: any;
|
|
11
|
+
entrypoints: string[];
|
|
12
|
+
chunks: any[];
|
|
13
|
+
constructor({ stats, entrypoints, namespace, outputPath, publicPath, }?: {
|
|
14
|
+
entrypoints?: string[] | undefined;
|
|
15
|
+
namespace?: string | undefined;
|
|
16
|
+
outputPath?: string | undefined;
|
|
17
|
+
});
|
|
18
|
+
addChunk(chunk: any): void;
|
|
19
|
+
collectChunks(app: any): React.DetailedReactHTMLElement<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
20
|
+
getChunkGroup(chunk: any): any;
|
|
21
|
+
getChunkInfo(chunkId: any): any;
|
|
22
|
+
resolvePublicUrl(filename: any): string;
|
|
23
|
+
createChunkAsset({ filename, chunk, type, linkType }: {
|
|
24
|
+
chunk: any;
|
|
25
|
+
filename: any;
|
|
26
|
+
linkType: any;
|
|
27
|
+
type: any;
|
|
28
|
+
}): {
|
|
29
|
+
filename: any;
|
|
30
|
+
integrity: any;
|
|
31
|
+
scriptType: string;
|
|
32
|
+
chunk: any;
|
|
33
|
+
url: string;
|
|
34
|
+
path: string;
|
|
35
|
+
type: any;
|
|
36
|
+
linkType: any;
|
|
37
|
+
} | undefined;
|
|
38
|
+
getChunkAssets(chunks: any): any;
|
|
39
|
+
getChunkChildAssets(chunks: any, type: any): any;
|
|
40
|
+
getChunkDependencies(chunks: any): any;
|
|
41
|
+
getRequiredChunksScriptContent(): string;
|
|
42
|
+
getRequiredChunksNamesScriptContent(): string;
|
|
43
|
+
getRequiredChunksScriptTag(extraProps?: {}): string;
|
|
44
|
+
getMainAssets(scriptType: any): any;
|
|
45
|
+
getScriptTags(extraProps?: {}): string;
|
|
46
|
+
getStyleTags(extraProps?: {}): any;
|
|
47
|
+
getLinkTags(extraProps?: {}): any;
|
|
48
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const sep = "/";
|
|
2
|
+
export declare const delimiter = ":";
|
|
3
|
+
export declare function isAbsolute(filePath: any): boolean;
|
|
4
|
+
export declare function normalize(filePath: any): string;
|
|
5
|
+
export declare function join(...segments: any[]): string;
|
|
6
|
+
export declare function resolve(...segments: any[]): string;
|
|
7
|
+
export declare function dirname(filePath: any): string;
|
|
8
|
+
export declare function basename(filePath: any, suffix?: string): string;
|
|
9
|
+
export declare function extname(filePath: any): string;
|
|
10
|
+
declare const _default: {
|
|
11
|
+
basename: typeof basename;
|
|
12
|
+
delimiter: string;
|
|
13
|
+
dirname: typeof dirname;
|
|
14
|
+
extname: typeof extname;
|
|
15
|
+
isAbsolute: typeof isAbsolute;
|
|
16
|
+
join: typeof join;
|
|
17
|
+
normalize: typeof normalize;
|
|
18
|
+
resolve: typeof resolve;
|
|
19
|
+
sep: string;
|
|
20
|
+
};
|
|
21
|
+
export default _default;
|
|
@@ -5,8 +5,8 @@ export declare const serverAppContextTemplate: (appContext: AppToolsContext) =>
|
|
|
5
5
|
sharedDirectory: string;
|
|
6
6
|
apiDirectory: string;
|
|
7
7
|
lambdaDirectory: string;
|
|
8
|
-
metaName:
|
|
9
|
-
bffRuntimeFramework:
|
|
8
|
+
metaName: string;
|
|
9
|
+
bffRuntimeFramework: "effect" | "hono";
|
|
10
10
|
};
|
|
11
11
|
export type PluginItem = [string, Record<string, any> | undefined];
|
|
12
12
|
export declare const genPluginImportsCode: (plugins: PluginItem[], isESM?: boolean) => string;
|
|
@@ -12,5 +12,5 @@ export declare const getProjectUsage: (appDirectory: string, distDirectory: stri
|
|
|
12
12
|
useWebServer: boolean;
|
|
13
13
|
};
|
|
14
14
|
export declare const getTemplatePath: (file: string) => string;
|
|
15
|
-
export declare const readTemplate: (file: string) => Promise<
|
|
15
|
+
export declare const readTemplate: (file: string) => Promise<string>;
|
|
16
16
|
export declare const resolveESMDependency: (entry: string) => Promise<string | undefined>;
|
package/dist/types/rsbuild.d.ts
CHANGED
|
@@ -7,6 +7,6 @@ type ResolveModernRsbuildConfigOptions = {
|
|
|
7
7
|
modifyModernConfig?: (config: AppUserConfig) => AppUserConfig | Promise<AppUserConfig>;
|
|
8
8
|
};
|
|
9
9
|
export declare function resolveModernRsbuildConfig(options: ResolveModernRsbuildConfigOptions): Promise<{
|
|
10
|
-
rsbuildConfig:
|
|
10
|
+
rsbuildConfig: import("@rsbuild/core").RsbuildConfig;
|
|
11
11
|
}>;
|
|
12
12
|
export type { ResolveModernRsbuildConfigOptions };
|
|
@@ -14,7 +14,7 @@ export declare function createRunOptions({ cwd, initialLog, metaName, version, i
|
|
|
14
14
|
initialLog: string;
|
|
15
15
|
configFile: string;
|
|
16
16
|
metaName: string;
|
|
17
|
-
internalPlugins:
|
|
17
|
+
internalPlugins: import("@modern-js/plugin").Plugin[];
|
|
18
18
|
handleSetupResult: typeof handleSetupResult;
|
|
19
19
|
}>;
|
|
20
20
|
export declare function run(options: RunOptions): Promise<void>;
|
|
@@ -26,13 +26,69 @@ export interface MicroFrontend {
|
|
|
26
26
|
*/
|
|
27
27
|
attestation?: string;
|
|
28
28
|
}
|
|
29
|
+
export type DeployTarget = 'node' | 'vercel' | 'netlify' | 'ghPages' | 'cloudflare';
|
|
30
|
+
export type CloudflareWorkerSecurityCspMode = 'enforce' | 'report-only' | 'off';
|
|
31
|
+
export interface CloudflareWorkerSecurityCspConfig {
|
|
32
|
+
mode?: CloudflareWorkerSecurityCspMode;
|
|
33
|
+
directives?: Record<string, string[] | string | false>;
|
|
34
|
+
additionalScriptSrc?: string[];
|
|
35
|
+
additionalStyleSrc?: string[];
|
|
36
|
+
additionalConnectSrc?: string[];
|
|
37
|
+
additionalImgSrc?: string[];
|
|
38
|
+
frameAncestors?: string[] | false;
|
|
39
|
+
reportUri?: string;
|
|
40
|
+
reason?: string;
|
|
41
|
+
}
|
|
42
|
+
export interface CloudflareWorkerSecurityNoindexConfig {
|
|
43
|
+
workersDev?: boolean;
|
|
44
|
+
localhost?: boolean;
|
|
45
|
+
previewHostnames?: string[];
|
|
46
|
+
reason?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface CloudflareWorkerSecurityConfig {
|
|
49
|
+
/**
|
|
50
|
+
* Disable all Cloudflare worker security defaults for this app.
|
|
51
|
+
* Prefer narrower escape hatches when possible.
|
|
52
|
+
*/
|
|
53
|
+
enabled?: boolean;
|
|
54
|
+
headers?: {
|
|
55
|
+
referrerPolicy?: string | false;
|
|
56
|
+
contentTypeOptions?: 'nosniff' | false;
|
|
57
|
+
permissionsPolicy?: string | false;
|
|
58
|
+
};
|
|
59
|
+
contentSecurityPolicy?: CloudflareWorkerSecurityCspConfig;
|
|
60
|
+
noindex?: boolean | CloudflareWorkerSecurityNoindexConfig;
|
|
61
|
+
cookies?: {
|
|
62
|
+
/**
|
|
63
|
+
* Cloudflare worker does not mutate application Set-Cookie headers by
|
|
64
|
+
* default; app-owned cookies should be secured by the owner that sets them.
|
|
65
|
+
*/
|
|
66
|
+
mutateSetCookie?: false;
|
|
67
|
+
reason?: string;
|
|
68
|
+
};
|
|
69
|
+
reason?: string;
|
|
70
|
+
}
|
|
29
71
|
export interface DeployUserConfig {
|
|
72
|
+
/**
|
|
73
|
+
* Selects the deploy output preset.
|
|
74
|
+
* `MODERNJS_DEPLOY` still overrides provider auto-detection when set.
|
|
75
|
+
* @default node
|
|
76
|
+
*/
|
|
77
|
+
target?: DeployTarget;
|
|
30
78
|
/**
|
|
31
79
|
* Used to configure micro-frontend sub-application information.
|
|
32
80
|
* @default false
|
|
33
81
|
*/
|
|
34
82
|
microFrontend?: boolean | MicroFrontend;
|
|
35
83
|
worker?: {
|
|
84
|
+
name?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Cloudflare Workers compatibility date for generated wrangler config.
|
|
87
|
+
* Use YYYY-MM-DD. Defaults to the date validated against the bundled
|
|
88
|
+
* Wrangler version used by UltraModern generated workspaces.
|
|
89
|
+
*/
|
|
90
|
+
compatibilityDate?: string;
|
|
36
91
|
ssr?: boolean;
|
|
92
|
+
security?: CloudflareWorkerSecurityConfig;
|
|
37
93
|
};
|
|
38
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const getConfigFile: (configFile?: string, cwd?: string) =>
|
|
1
|
+
export declare const getConfigFile: (configFile?: string, cwd?: string) => string | false;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
1
|
+
import type { CLIPluginAPI, Plugin } from '@modern-js/plugin';
|
|
2
2
|
import type { ServerPlugin as ServerPluginInstance } from '@modern-js/server-core';
|
|
3
3
|
import type { InternalPlugins, ServerPlugin } from '@modern-js/types';
|
|
4
4
|
import type { AppTools } from '../types';
|
|
@@ -10,4 +10,4 @@ export declare function loadServerPlugins(api: CLIPluginAPI<AppTools>, appDirect
|
|
|
10
10
|
* @param internalPlugins - Internal plugins.
|
|
11
11
|
* @returns Plugin Objects has been required.
|
|
12
12
|
*/
|
|
13
|
-
export declare const loadInternalPlugins: (appDirectory: string, internalPlugins?: InternalPlugins) => Promise<
|
|
13
|
+
export declare const loadInternalPlugins: (appDirectory: string, internalPlugins?: InternalPlugins) => Promise<Plugin[]>;
|