chore: add basic-export build work

This commit is contained in:
hardfist 2024-07-21 17:07:05 +08:00
parent 8f5f0ef141
commit 001664e3bc
16 changed files with 356 additions and 187 deletions

View file

@ -1,8 +1,8 @@
{ {
"private": true, "private": true,
"scripts": { "scripts": {
"dev": "next", "dev": "RSPACK_CONFIG_VALIDATE=loose-silent next",
"build": "next build", "build": "RSPACK_CONFIG_VALIDATE=loose-silent next build",
"start": "serve out" "start": "serve out"
}, },
"dependencies": { "dependencies": {

View file

@ -99,6 +99,7 @@
"caniuse-lite": "^1.0.30001579", "caniuse-lite": "^1.0.30001579",
"graceful-fs": "^4.2.11", "graceful-fs": "^4.2.11",
"postcss": "8.4.31", "postcss": "8.4.31",
"source-map-support": "0.5.21",
"styled-jsx": "5.1.6" "styled-jsx": "5.1.6"
}, },
"peerDependencies": { "peerDependencies": {
@ -163,6 +164,7 @@
"@next/swc": "15.0.0-canary.56", "@next/swc": "15.0.0-canary.56",
"@opentelemetry/api": "1.6.0", "@opentelemetry/api": "1.6.0",
"@playwright/test": "1.41.2", "@playwright/test": "1.41.2",
"@rspack/core": "alpha",
"@swc/core": "1.6.6", "@swc/core": "1.6.6",
"@swc/types": "0.1.7", "@swc/types": "0.1.7",
"@taskr/clear": "1.1.0", "@taskr/clear": "1.1.0",

View file

@ -51,6 +51,7 @@ export function runCompiler(
] ]
> { > {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
console.log(config);
const compiler = webpack(config) const compiler = webpack(config)
// Ensure we use the previous inputFileSystem // Ensure we use the previous inputFileSystem
if (inputFileSystem) { if (inputFileSystem) {

View file

@ -922,8 +922,9 @@ export default async function getBaseWebpackConfig(
context, context,
request, request,
dependencyType, dependencyType,
contextInfo.issuerLayer as WebpackLayerName, contextInfo?.issuerLayer as WebpackLayerName,
(options) => { (options) => {
return true
const resolveFunction = getResolve(options) const resolveFunction = getResolve(options)
return (resolveContext: string, requestToResolve: string) => return (resolveContext: string, requestToResolve: string) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
@ -1037,7 +1038,6 @@ export default async function getBaseWebpackConfig(
}): boolean { }): boolean {
return ( return (
!module.type?.startsWith('css') && !module.type?.startsWith('css') &&
module.size() > 160000 &&
/node_modules[/\\]/.test(module.nameForCondition() || '') /node_modules[/\\]/.test(module.nameForCondition() || '')
) )
}, },
@ -1104,35 +1104,35 @@ export default async function getBaseWebpackConfig(
const { const {
TerserPlugin, TerserPlugin,
} = require('./webpack/plugins/terser-webpack-plugin/src/index.js') } = require('./webpack/plugins/terser-webpack-plugin/src/index.js')
new TerserPlugin({ // new TerserPlugin({
terserOptions: { // terserOptions: {
...terserOptions, // ...terserOptions,
compress: { // compress: {
...terserOptions.compress, // ...terserOptions.compress,
}, // },
mangle: { // mangle: {
...terserOptions.mangle, // ...terserOptions.mangle,
}, // },
}, // },
}).apply(compiler) // }).apply(compiler)
}, },
// Minify CSS // Minify CSS
(compiler: webpack.Compiler) => { (compiler: webpack.Compiler) => {
const { const {
CssMinimizerPlugin, CssMinimizerPlugin,
} = require('./webpack/plugins/css-minimizer-plugin') } = require('./webpack/plugins/css-minimizer-plugin')
new CssMinimizerPlugin({ // new CssMinimizerPlugin({
postcssOptions: { // postcssOptions: {
map: { // map: {
// `inline: false` generates the source map in a separate file. // // `inline: false` generates the source map in a separate file.
// Otherwise, the CSS file is needlessly large. // // Otherwise, the CSS file is needlessly large.
inline: false, // inline: false,
// `annotation: false` skips appending the `sourceMappingURL` // // `annotation: false` skips appending the `sourceMappingURL`
// to the end of the CSS file. Webpack already handles this. // // to the end of the CSS file. Webpack already handles this.
annotation: false, // annotation: false,
}, // },
}, // },
}).apply(compiler) // }).apply(compiler)
}, },
], ],
}, },
@ -1740,7 +1740,7 @@ export default async function getBaseWebpackConfig(
resource.request, resource.request,
'.shared-runtime' '.shared-runtime'
) )
const layer = resource.contextInfo.issuerLayer const layer = 'pages' as string
let runtime let runtime
switch (layer) { switch (layer) {
@ -1757,7 +1757,7 @@ export default async function getBaseWebpackConfig(
} }
), ),
dev && new MemoryWithGcCachePlugin({ maxGenerations: 5 }), dev && new MemoryWithGcCachePlugin({ maxGenerations: 5 }),
dev && isClient && new ReactRefreshWebpackPlugin(webpack), // dev && isClient && new ReactRefreshWebpackPlugin(webpack),
// Makes sure `Buffer` and `process` are polyfilled in client and flight bundles (same behavior as webpack 4) // Makes sure `Buffer` and `process` are polyfilled in client and flight bundles (same behavior as webpack 4)
(isClient || isEdgeServer) && (isClient || isEdgeServer) &&
new webpack.ProvidePlugin({ new webpack.ProvidePlugin({
@ -1788,7 +1788,7 @@ export default async function getBaseWebpackConfig(
runtimeAsset: `server/${MIDDLEWARE_REACT_LOADABLE_MANIFEST}.js`, runtimeAsset: `server/${MIDDLEWARE_REACT_LOADABLE_MANIFEST}.js`,
dev, dev,
}), }),
(isClient || isEdgeServer) && new DropClientPage(), // (isClient || isEdgeServer) && new DropClientPage(),
isNodeServer && isNodeServer &&
!dev && !dev &&
new (require('./webpack/plugins/next-trace-entrypoints-plugin') new (require('./webpack/plugins/next-trace-entrypoints-plugin')
@ -1823,9 +1823,9 @@ export default async function getBaseWebpackConfig(
const { NextJsRequireCacheHotReloader } = const { NextJsRequireCacheHotReloader } =
require('./webpack/plugins/nextjs-require-cache-hot-reloader') as typeof import('./webpack/plugins/nextjs-require-cache-hot-reloader') require('./webpack/plugins/nextjs-require-cache-hot-reloader') as typeof import('./webpack/plugins/nextjs-require-cache-hot-reloader')
const devPlugins: any[] = [ const devPlugins: any[] = [
new NextJsRequireCacheHotReloader({ // new NextJsRequireCacheHotReloader({
serverComponents: hasAppDir, // serverComponents: hasAppDir,
}), // }),
] ]
if (isClient || isEdgeServer) { if (isClient || isEdgeServer) {
@ -1876,11 +1876,11 @@ export default async function getBaseWebpackConfig(
require('./webpack/plugins/font-stylesheet-gathering-plugin') as { require('./webpack/plugins/font-stylesheet-gathering-plugin') as {
FontStylesheetGatheringPlugin: typeof import('./webpack/plugins/font-stylesheet-gathering-plugin').FontStylesheetGatheringPlugin FontStylesheetGatheringPlugin: typeof import('./webpack/plugins/font-stylesheet-gathering-plugin').FontStylesheetGatheringPlugin
} }
return new FontStylesheetGatheringPlugin({ // return new FontStylesheetGatheringPlugin({
adjustFontFallbacks: config.experimental.adjustFontFallbacks, // adjustFontFallbacks: config.experimental.adjustFontFallbacks,
adjustFontFallbacksWithSizeAdjust: // adjustFontFallbacksWithSizeAdjust:
config.experimental.adjustFontFallbacksWithSizeAdjust, // config.experimental.adjustFontFallbacksWithSizeAdjust,
}) // })
})(), })(),
new WellKnownErrorsPlugin(), new WellKnownErrorsPlugin(),
isClient && isClient &&
@ -2266,22 +2266,22 @@ export default async function getBaseWebpackConfig(
const webpack5Config = webpackConfig as webpack.Configuration const webpack5Config = webpackConfig as webpack.Configuration
// disable lazy compilation of entries as next.js has it's own method here // disable lazy compilation of entries as next.js has it's own method here
if (webpack5Config.experiments?.lazyCompilation === true) { // if (webpack5Config.experiments?.lazyCompilation === true) {
webpack5Config.experiments.lazyCompilation = { // webpack5Config.experiments.lazyCompilation = {
entries: false, // entries: false,
} // }
} else if ( // } else if (
typeof webpack5Config.experiments?.lazyCompilation === 'object' && // typeof webpack5Config.experiments?.lazyCompilation === 'object' &&
webpack5Config.experiments.lazyCompilation.entries !== false // webpack5Config.experiments.lazyCompilation.entries !== false
) { // ) {
webpack5Config.experiments.lazyCompilation.entries = false // webpack5Config.experiments.lazyCompilation.entries = false
} // }
if (typeof (webpackConfig as any).then === 'function') { // if (typeof (webpackConfig as any).then === 'function') {
console.warn( // console.warn(
'> Promise returned in next config. https://nextjs.org/docs/messages/promise-in-next-config' // '> Promise returned in next config. https://nextjs.org/docs/messages/promise-in-next-config'
) // )
} // }
} }
const rules = webpackConfig.module?.rules || [] const rules = webpackConfig.module?.rules || []

View file

@ -588,47 +588,47 @@ export const css = curry(async function css(
} }
// Enable full mini-css-extract-plugin hmr for prod mode pages or app dir // Enable full mini-css-extract-plugin hmr for prod mode pages or app dir
if (ctx.isClient && (ctx.isProduction || ctx.hasAppDir)) { // if (ctx.isClient && (ctx.isProduction || ctx.hasAppDir)) {
// Extract CSS as CSS file(s) in the client-side production bundle. // // Extract CSS as CSS file(s) in the client-side production bundle.
const MiniCssExtractPlugin = // const MiniCssExtractPlugin =
require('../../../plugins/mini-css-extract-plugin').default // require('../../../plugins/mini-css-extract-plugin').default
fns.push( // fns.push(
plugin( // plugin(
// @ts-ignore webpack 5 compat // // @ts-ignore webpack 5 compat
new MiniCssExtractPlugin({ // new MiniCssExtractPlugin({
filename: ctx.isProduction // filename: ctx.isProduction
? 'static/css/[contenthash].css' // ? 'static/css/[contenthash].css'
: 'static/css/[name].css', // : 'static/css/[name].css',
chunkFilename: ctx.isProduction // chunkFilename: ctx.isProduction
? 'static/css/[contenthash].css' // ? 'static/css/[contenthash].css'
: 'static/css/[name].css', // : 'static/css/[name].css',
// Next.js guarantees that CSS order "doesn't matter", due to imposed // // Next.js guarantees that CSS order "doesn't matter", due to imposed
// restrictions: // // restrictions:
// 1. Global CSS can only be defined in a single entrypoint (_app) // // 1. Global CSS can only be defined in a single entrypoint (_app)
// 2. CSS Modules generate scoped class names by default and cannot // // 2. CSS Modules generate scoped class names by default and cannot
// include Global CSS (:global() selector). // // include Global CSS (:global() selector).
// // //
// While not a perfect guarantee (e.g. liberal use of `:global()` // // While not a perfect guarantee (e.g. liberal use of `:global()`
// selector), this assumption is required to code-split CSS. // // selector), this assumption is required to code-split CSS.
// // //
// If this warning were to trigger, it'd be unactionable by the user, // // If this warning were to trigger, it'd be unactionable by the user,
// but likely not valid -- so we disable it. // // but likely not valid -- so we disable it.
ignoreOrder: true, // ignoreOrder: true,
insert: function (linkTag: HTMLLinkElement) { // insert: function (linkTag: HTMLLinkElement) {
if (typeof _N_E_STYLE_LOAD === 'function') { // if (typeof _N_E_STYLE_LOAD === 'function') {
const { href, onload, onerror } = linkTag // const { href, onload, onerror } = linkTag
_N_E_STYLE_LOAD(new URL(href).pathname).then( // _N_E_STYLE_LOAD(new URL(href).pathname).then(
() => onload?.call(linkTag, { type: 'load' } as Event), // () => onload?.call(linkTag, { type: 'load' } as Event),
() => onerror?.call(linkTag, {} as Event) // () => onerror?.call(linkTag, {} as Event)
) // )
} else { // } else {
document.head.appendChild(linkTag) // document.head.appendChild(linkTag)
} // }
}, // },
}) // })
) // )
) // )
} // }
const fn = pipe(...fns) const fn = pipe(...fns)
return fn(config) return fn(config)

View file

@ -33,7 +33,7 @@ export function isCSSMod(mod: {
mod.loaders?.some( mod.loaders?.some(
({ loader }) => ({ loader }) =>
loader.includes('next-style-loader/index.js') || loader.includes('next-style-loader/index.js') ||
loader.includes('mini-css-extract-plugin/loader.js') || // loader.includes('mini-css-extract-plugin/loader.js') ||
loader.includes('@vanilla-extract/webpack-plugin/loader/') loader.includes('@vanilla-extract/webpack-plugin/loader/')
) )
) )

View file

@ -29,6 +29,7 @@ export class CssChunkingPlugin {
} }
public apply(compiler: Compiler) { public apply(compiler: Compiler) {
return
const strict = this.strict const strict = this.strict
const summary = !!process.env.CSS_CHUNKING_SUMMARY const summary = !!process.env.CSS_CHUNKING_SUMMARY
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => { compiler.hooks.thisCompilation.tap(PLUGIN_NAME, (compilation) => {

View file

@ -568,7 +568,7 @@ function getExtractMetadata(params: {
metadataByEntry.clear() metadataByEntry.clear()
const telemetry: Telemetry | undefined = traceGlobals.get('telemetry') const telemetry: Telemetry | undefined = traceGlobals.get('telemetry')
for (const [entryName, entry] of compilation.entries) { for (const [entryName, entry] of compilation.entries ?? []) {
if (entry.options.runtime !== EDGE_RUNTIME_WEBPACK) { if (entry.options.runtime !== EDGE_RUNTIME_WEBPACK) {
// Only process edge runtime entries // Only process edge runtime entries
continue continue
@ -782,9 +782,9 @@ export default class MiddlewarePlugin {
compiler, compiler,
compilation, compilation,
}) })
hooks.parser.for('javascript/auto').tap(NAME, codeAnalyzer) // hooks.parser.for('javascript/auto').tap(NAME, codeAnalyzer)
hooks.parser.for('javascript/dynamic').tap(NAME, codeAnalyzer) // hooks.parser.for('javascript/dynamic').tap(NAME, codeAnalyzer)
hooks.parser.for('javascript/esm').tap(NAME, codeAnalyzer) // hooks.parser.for('javascript/esm').tap(NAME, codeAnalyzer)
/** /**
* Extract all metadata for the entry points in a Map object. * Extract all metadata for the entry points in a Map object.

View file

@ -677,6 +677,7 @@ export class TraceEntryPointsPlugin implements webpack.WebpackPluginInstance {
} }
apply(compiler: webpack.Compiler) { apply(compiler: webpack.Compiler) {
return;
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {
const readlink = async (path: string): Promise<string | null> => { const readlink = async (path: string): Promise<string | null> => {
try { try {

View file

@ -63,7 +63,7 @@ export class ProfilingPlugin {
} = {} } = {}
) { ) {
let span: Span | undefined let span: Span | undefined
startHook.tap( startHook?.tap(
{ name: pluginName, stage: -Infinity }, { name: pluginName, stage: -Infinity },
(...params: any[]) => { (...params: any[]) => {
const name = typeof spanName === 'function' ? spanName() : spanName const name = typeof spanName === 'function' ? spanName() : spanName
@ -75,7 +75,7 @@ export class ProfilingPlugin {
if (onStart) onStart(span, ...params) if (onStart) onStart(span, ...params)
} }
) )
stopHook.tap({ name: pluginName, stage: Infinity }, (...params: any[]) => { stopHook?.tap({ name: pluginName, stage: Infinity }, (...params: any[]) => {
// `stopHook` may be triggered when `startHook` has not in cases // `stopHook` may be triggered when `startHook` has not in cases
// where `stopHook` is used as the terminating event for more // where `stopHook` is used as the terminating event for more
// than one pair of hooks. // than one pair of hooks.
@ -149,54 +149,54 @@ export class ProfilingPlugin {
compiler.hooks.compilation.tap( compiler.hooks.compilation.tap(
{ name: pluginName, stage: -Infinity }, { name: pluginName, stage: -Infinity },
(compilation: any) => { (compilation: any) => {
compilation.hooks.buildModule.tap(pluginName, (module: any) => { // compilation.hooks.buildModule.tap(pluginName, (module: any) => {
const moduleType = (() => { // const moduleType = (() => {
const r = module.userRequest // const r = module.userRequest
if (!r || r.endsWith('!')) { // if (!r || r.endsWith('!')) {
return '' // return ''
} else { // } else {
const resource = r.split('!').pop() // const resource = r.split('!').pop()
const match = /^[^?]+\.([^?]+)$/.exec(resource) // const match = /^[^?]+\.([^?]+)$/.exec(resource)
return match ? match[1] : '' // return match ? match[1] : ''
} // }
})() // })()
const issuerModule = compilation?.moduleGraph?.getIssuer(module) // const issuerModule = compilation?.moduleGraph?.getIssuer(module)
let span: Span // let span: Span
const moduleSpans = moduleSpansByCompilation.get(compilation) // const moduleSpans = moduleSpansByCompilation.get(compilation)
const spanName = `build-module${moduleType ? `-${moduleType}` : ''}` // const spanName = `build-module${moduleType ? `-${moduleType}` : ''}`
const issuerSpan: Span | undefined = // const issuerSpan: Span | undefined =
issuerModule && moduleSpans?.get(issuerModule) // issuerModule && moduleSpans?.get(issuerModule)
if (issuerSpan) { // if (issuerSpan) {
span = issuerSpan.traceChild(spanName) // span = issuerSpan.traceChild(spanName)
} else { // } else {
let parentSpan: Span | undefined // let parentSpan: Span | undefined
for (const incomingConnection of compilation.moduleGraph.getIncomingConnections( // for (const incomingConnection of compilation.moduleGraph?.getIncomingConnections(
module // module
)) { // )) {
const entrySpan = spans.get(incomingConnection.dependency) // const entrySpan = spans.get(incomingConnection.dependency)
if (entrySpan) { // if (entrySpan) {
parentSpan = entrySpan // parentSpan = entrySpan
break // break
} // }
} // }
if (!parentSpan) { // if (!parentSpan) {
const compilationSpan = spans.get(compilation) // const compilationSpan = spans.get(compilation)
if (!compilationSpan) { // if (!compilationSpan) {
return // return
} // }
parentSpan = compilationSpan // parentSpan = compilationSpan
} // }
span = parentSpan.traceChild(spanName) // span = parentSpan.traceChild(spanName)
} // }
span.setAttribute('name', module.userRequest) // span.setAttribute('name', module.userRequest)
span.setAttribute('layer', module.layer) // span.setAttribute('layer', module.layer)
moduleSpans!.set(module, span) // moduleSpans!.set(module, span)
}) // })
const moduleHooks = NormalModule.getCompilationHooks(compilation) const moduleHooks = NormalModule.getCompilationHooks(compilation)
moduleHooks.readResource.for(undefined).intercept({ moduleHooks.readResource.for(undefined).intercept({
@ -214,17 +214,27 @@ export class ProfilingPlugin {
moduleHooks.loader.tap( moduleHooks.loader.tap(
pluginName, pluginName,
(loaderContext: any, module: any) => { (loaderContext: any, module: any) => {
const moduleSpan = moduleSpansByCompilation // const moduleSpan = moduleSpansByCompilation
.get(compilation) // .get(compilation)
?.get(module) // ?.get(module)
const moduleSpan = {
traceChild() {
return {
traceFn(fn: any) {
return fn()
},
setAttribute() {},
}
},
}
loaderContext.currentTraceSpan = moduleSpan loaderContext.currentTraceSpan = moduleSpan
} }
) )
compilation.hooks.succeedModule.tap(pluginName, (module: any) => { compilation.hooks.succeedModule?.tap(pluginName, (module: any) => {
moduleSpansByCompilation?.get(compilation)?.get(module)?.stop() moduleSpansByCompilation?.get(compilation)?.get(module)?.stop()
}) })
compilation.hooks.failedModule.tap(pluginName, (module: any) => { compilation.hooks.failedModule?.tap(pluginName, (module: any) => {
moduleSpansByCompilation?.get(compilation)?.get(module)?.stop() moduleSpansByCompilation?.get(compilation)?.get(module)?.stop()
}) })
@ -243,7 +253,7 @@ export class ProfilingPlugin {
} }
) )
compilation.hooks.addEntry.tap(pluginName, (entry: any) => { compilation.hooks.addEntry?.tap(pluginName, (entry: any) => {
const parentSpan = const parentSpan =
makeSpanByCompilation.get(compilation) || spans.get(compilation) makeSpanByCompilation.get(compilation) || spans.get(compilation)
if (!parentSpan) { if (!parentSpan) {
@ -254,11 +264,11 @@ export class ProfilingPlugin {
spans.set(entry, addEntrySpan) spans.set(entry, addEntrySpan)
}) })
compilation.hooks.succeedEntry.tap(pluginName, (entry: any) => { compilation.hooks.succeedEntry?.tap(pluginName, (entry: any) => {
spans.get(entry)?.stop() spans.get(entry)?.stop()
spans.delete(entry) spans.delete(entry)
}) })
compilation.hooks.failedEntry.tap(pluginName, (entry: any) => { compilation.hooks.failedEntry?.tap(pluginName, (entry: any) => {
spans.get(entry)?.stop() spans.get(entry)?.stop()
spans.delete(entry) spans.delete(entry)
}) })
@ -355,31 +365,31 @@ export class ProfilingPlugin {
) )
const logs = new Map() const logs = new Map()
const originalTime = compilation.logger.time const originalTime = compilation.logger?.time
const originalTimeEnd = compilation.logger.timeEnd const originalTimeEnd = compilation.logger?.timeEnd
compilation.logger.time = (label: string) => { // compilation.logger.time = (label: string) => {
if (!inTraceLabelsSeal(label)) { // if (!inTraceLabelsSeal(label)) {
return originalTime.call(compilation.logger, label) // return originalTime.call(compilation.logger, label)
} // }
const span = sealSpanByCompilation.get(compilation) // const span = sealSpanByCompilation.get(compilation)
if (span) { // if (span) {
logs.set(label, span.traceChild(label.replace(/ /g, '-'))) // logs.set(label, span.traceChild(label.replace(/ /g, '-')))
} // }
return originalTime.call(compilation.logger, label) // return originalTime.call(compilation.logger, label)
} // }
compilation.logger.timeEnd = (label: string) => { // compilation.logger.timeEnd = (label: string) => {
if (!inTraceLabelsSeal(label)) { // if (!inTraceLabelsSeal(label)) {
return originalTimeEnd.call(compilation.logger, label) // return originalTimeEnd.call(compilation.logger, label)
} // }
const span = logs.get(label) // const span = logs.get(label)
if (span) { // if (span) {
span.stop() // span.stop()
logs.delete(label) // logs.delete(label)
} // }
return originalTimeEnd.call(compilation.logger, label) // return originalTimeEnd.call(compilation.logger, label)
} // }
} }
) )
} }

View file

@ -134,9 +134,9 @@ function buildManifest(
} }
} }
} }
for (const module of compilation.modules) { // for (const module of compilation.modules) {
module.blocks.forEach(handleBlock) // module.blocks.forEach(handleBlock)
} // }
manifest = Object.keys(manifest) manifest = Object.keys(manifest)
.sort() .sort()

View file

@ -1,4 +1,5 @@
#!/usr/bin/env node #!/usr/bin/env node
require('source-map-support').install();
import '../server/lib/cpu-profile' import '../server/lib/cpu-profile'
import { existsSync } from 'fs' import { existsSync } from 'fs'

View file

@ -1,4 +1,5 @@
#!/usr/bin/env node #!/usr/bin/env node
require('source-map-support').install();
import '../server/lib/cpu-profile' import '../server/lib/cpu-profile'
import type { StartServerOptions } from '../server/lib/start-server' import type { StartServerOptions } from '../server/lib/start-server'

View file

@ -21,6 +21,7 @@ exports.init = function () {
webpack: require('webpack'), webpack: require('webpack'),
}) })
} else { } else {
Object.assign(exports, require('./bundle5')()) console.log('load rspack');
Object.assign(exports, require('@rspack/core'))
} }
} }

View file

@ -133,6 +133,7 @@ export async function requirePage(
export function requireFontManifest(distDir: string) { export function requireFontManifest(distDir: string) {
const serverBuildPath = path.join(distDir, SERVER_DIRECTORY) const serverBuildPath = path.join(distDir, SERVER_DIRECTORY)
return {}
const fontManifest = loadManifest( const fontManifest = loadManifest(
path.join(serverBuildPath, AUTOMATIC_FONT_OPTIMIZATION_MANIFEST) path.join(serverBuildPath, AUTOMATIC_FONT_OPTIMIZATION_MANIFEST)
) as FontManifest ) as FontManifest

View file

@ -868,6 +868,9 @@ importers:
sass: sass:
specifier: ^1.3.0 specifier: ^1.3.0
version: 1.77.6 version: 1.77.6
source-map-support:
specifier: 0.5.21
version: 0.5.21
styled-jsx: styled-jsx:
specifier: 5.1.6 specifier: 5.1.6
version: 5.1.6(@babel/core@7.22.5)(babel-plugin-macros@3.1.0)(react@19.0.0-rc-6230622a1a-20240610) version: 5.1.6(@babel/core@7.22.5)(babel-plugin-macros@3.1.0)(react@19.0.0-rc-6230622a1a-20240610)
@ -984,6 +987,9 @@ importers:
'@playwright/test': '@playwright/test':
specifier: 1.41.2 specifier: 1.41.2
version: 1.41.2 version: 1.41.2
'@rspack/core':
specifier: alpha
version: 1.0.0-alpha.1(@swc/helpers@0.5.11)
'@swc/core': '@swc/core':
specifier: 1.6.6 specifier: 1.6.6
version: 1.6.6(@swc/helpers@0.5.11) version: 1.6.6(@swc/helpers@0.5.11)
@ -3943,6 +3949,18 @@ packages:
peerDependencies: peerDependencies:
react: 19.0.0-rc-6230622a1a-20240610 react: 19.0.0-rc-6230622a1a-20240610
'@module-federation/runtime-tools@0.2.3':
resolution: {integrity: sha512-capN8CVTCEqNAjnl102girrkevczoQfnQYyiYC4WuyKsg7+LUqfirIe1Eiyv6VSE2UgvOTZDnqvervA6rBOlmg==}
'@module-federation/runtime@0.2.3':
resolution: {integrity: sha512-N+ZxBUb1mkmfO9XT1BwgYQgShtUTlijHbukqQ4afFka5lRAT+ayC7RKfHJLz0HbuexKPCmPBDfdmCnErR5WyTQ==}
'@module-federation/sdk@0.2.3':
resolution: {integrity: sha512-W9zrPchLocyCBc/B8CW21akcfJXLl++9xBe1L1EtgxZGfj/xwHt0GcBWE/y+QGvYTL2a1iZjwscbftbUhxgxXg==}
'@module-federation/webpack-bundler-runtime@0.2.3':
resolution: {integrity: sha512-L/jt2uJ+8dwYiyn9GxryzDR6tr/Wk8rpgvelM2EBeLIhu7YxCHSmSjQYhw3BTux9zZIr47d1K9fGjBFsVRd/SQ==}
'@mswjs/cookies@1.1.0': '@mswjs/cookies@1.1.0':
resolution: {integrity: sha512-0ZcCVQxifZmhwNBoQIrystCb+2sWBY2Zw8lpfJBPCHGCA/HWqehITeCRVIv4VMy8MPlaHo2w2pTHFV2pFfqKPw==} resolution: {integrity: sha512-0ZcCVQxifZmhwNBoQIrystCb+2sWBY2Zw8lpfJBPCHGCA/HWqehITeCRVIv4VMy8MPlaHo2w2pTHFV2pFfqKPw==}
engines: {node: '>=18'} engines: {node: '>=18'}
@ -4378,6 +4396,67 @@ packages:
resolution: {integrity: sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==} resolution: {integrity: sha512-iKnFXr7NkdZAIHiIWE+BX5ULi/ucVFYWD6TbAV+rZctiRTY2PL6tsIKhoIOaoskiWAkgu+VsbXgUVDNLHf+InQ==}
engines: {node: '>= 8.0.0'} engines: {node: '>= 8.0.0'}
'@rspack/binding-darwin-arm64@1.0.0-alpha.1':
resolution: {integrity: sha512-6ZbxlS5+29bvYqsEoPMvCnn6NxZPq8CucuDDSwuP/w0UH81DD2yf9Mtn7IYDBhjiS7wv9pF4NYr7oDpGfOksHA==}
cpu: [arm64]
os: [darwin]
'@rspack/binding-darwin-x64@1.0.0-alpha.1':
resolution: {integrity: sha512-4Y9xfwaTHJBTrq5uav/tOWvCMLcBG72SEi+XgVjsZOC2ZS2WNqg4z0QCRzmt+agdmlWuXTOMB2LpYxRLxBj9sg==}
cpu: [x64]
os: [darwin]
'@rspack/binding-linux-arm64-gnu@1.0.0-alpha.1':
resolution: {integrity: sha512-cew/WxOILZkTN1I+oWrt1BSnm3iK4/8DqX/6XxiUwCAmgfStZXB5NQS+SDIDBzFJ4I+NibLRMiJy5T9uCtOWzQ==}
cpu: [arm64]
os: [linux]
'@rspack/binding-linux-arm64-musl@1.0.0-alpha.1':
resolution: {integrity: sha512-+yLjjl8nkWRseQwwovaaLMshTKTep/5PSFN3nHtXPo/TsL1itDgUtM9XntTdeTdaIEgVyNGcb1dRARDoAq/vKw==}
cpu: [arm64]
os: [linux]
'@rspack/binding-linux-x64-gnu@1.0.0-alpha.1':
resolution: {integrity: sha512-QQfGCTrn76d6fVoWnn6tm2eYTSJe78wc3X4H92Js+ZhjcHVn5XSTeyqyb0Oq4+TRKmwAi39/wUgPsbSxQj9g5A==}
cpu: [x64]
os: [linux]
'@rspack/binding-linux-x64-musl@1.0.0-alpha.1':
resolution: {integrity: sha512-ZpVTXPjG5SLwKUYiwLR6XIlo/G4ZQHA6TBKFbPG3p9kZ0DYurGjt8bcjeiu9xP050XmTA0Hj5vS6zEdYtgE6bA==}
cpu: [x64]
os: [linux]
'@rspack/binding-win32-arm64-msvc@1.0.0-alpha.1':
resolution: {integrity: sha512-8wTNt1MgJgUMRJ2ySAToUZoeBJabOV/lqH2o1ypHdmirZ0aMno+C05XOmbrLhgZL2qKBROVt4VVa7+IlmvJ7yQ==}
cpu: [arm64]
os: [win32]
'@rspack/binding-win32-ia32-msvc@1.0.0-alpha.1':
resolution: {integrity: sha512-hfujEyp1+0yfAzShQJZUezdiHQ7KvTwC0T817/dQi4CdwoXWOuPnnYrb5JG5TAcagNttQNX2NFhVbeYQgj5c8Q==}
cpu: [ia32]
os: [win32]
'@rspack/binding-win32-x64-msvc@1.0.0-alpha.1':
resolution: {integrity: sha512-KMIosN4wdXVFb3RIBX7fEXBv5jfinK0PkYSv8aQcIAdyhm2mSI95aCpAFE8xhgGCeSwaZ2PCO0zBgO0ZldAc7Q==}
cpu: [x64]
os: [win32]
'@rspack/binding@1.0.0-alpha.1':
resolution: {integrity: sha512-3q3cN5kZZdaAnIrjVhkW2f2RbLpxgSp8ATs4P6fzUoKvuunU1v+KXbhPir/tKaKBXLgYH2h3i13tPDcuL3kA+A==}
'@rspack/core@1.0.0-alpha.1':
resolution: {integrity: sha512-UN6oAWnDJpouldf6UDuZZIc1GSgEgSAeeIQlpCwob9v+uuZ/NjJHvG7HCjxeHtkh1g9Oly8clOZA7gKOWtE4CA==}
engines: {node: '>=16.0.0'}
peerDependencies:
'@swc/helpers': '>=0.5.1'
peerDependenciesMeta:
'@swc/helpers':
optional: true
'@rspack/lite-tapable@1.0.0-alpha.1':
resolution: {integrity: sha512-vgY3jauZk+Pd6u6I5d4Rs9Q7hUtl5mClKG2Hn/FucFL4WK+1m6kssu/576WEY6HP5ptBPWlqcBbamzodai1q1g==}
engines: {node: '>=16.0.0'}
'@rushstack/eslint-patch@1.3.3': '@rushstack/eslint-patch@1.3.3':
resolution: {integrity: sha512-0xd7qez0AQ+MbHatZTlI1gu5vkG8r7MYRUJAHPAHJBmGLs16zpkrpAVLvjQKQOqaXPDUBwOiJzNc00znHSCVBw==} resolution: {integrity: sha512-0xd7qez0AQ+MbHatZTlI1gu5vkG8r7MYRUJAHPAHJBmGLs16zpkrpAVLvjQKQOqaXPDUBwOiJzNc00znHSCVBw==}
@ -13255,6 +13334,9 @@ packages:
source-map-support@0.5.20: source-map-support@0.5.20:
resolution: {integrity: sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw==} resolution: {integrity: sha512-n1lZZ8Ve4ksRqizaBQgxXDgKwttHDhyfQjA6YZZn8+AroHbsIz+JjwxQDxbp+7y5OYCI8t1Yk7etjD9CRd2hIw==}
source-map-support@0.5.21:
resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==}
source-map-url@0.4.0: source-map-url@0.4.0:
resolution: {integrity: sha512-liJwHPI9x9d9w5WSIjM58MqGmmb7XzNqwdUA3kSBQ4lmDngexlKwawGzK3J1mKXi6+sysoMDlpVyZh9sv5vRfw==} resolution: {integrity: sha512-liJwHPI9x9d9w5WSIjM58MqGmmb7XzNqwdUA3kSBQ4lmDngexlKwawGzK3J1mKXi6+sysoMDlpVyZh9sv5vRfw==}
deprecated: See https://github.com/lydell/source-map-url#deprecated deprecated: See https://github.com/lydell/source-map-url#deprecated
@ -18189,6 +18271,22 @@ snapshots:
'@types/react': types-react@19.0.0-rc.0 '@types/react': types-react@19.0.0-rc.0
react: 19.0.0-rc-6230622a1a-20240610 react: 19.0.0-rc-6230622a1a-20240610
'@module-federation/runtime-tools@0.2.3':
dependencies:
'@module-federation/runtime': 0.2.3
'@module-federation/webpack-bundler-runtime': 0.2.3
'@module-federation/runtime@0.2.3':
dependencies:
'@module-federation/sdk': 0.2.3
'@module-federation/sdk@0.2.3': {}
'@module-federation/webpack-bundler-runtime@0.2.3':
dependencies:
'@module-federation/runtime': 0.2.3
'@module-federation/sdk': 0.2.3
'@mswjs/cookies@1.1.0': {} '@mswjs/cookies@1.1.0': {}
'@mswjs/interceptors@0.23.0': '@mswjs/interceptors@0.23.0':
@ -18751,6 +18849,56 @@ snapshots:
estree-walker: 2.0.2 estree-walker: 2.0.2
picomatch: 2.3.1 picomatch: 2.3.1
'@rspack/binding-darwin-arm64@1.0.0-alpha.1':
optional: true
'@rspack/binding-darwin-x64@1.0.0-alpha.1':
optional: true
'@rspack/binding-linux-arm64-gnu@1.0.0-alpha.1':
optional: true
'@rspack/binding-linux-arm64-musl@1.0.0-alpha.1':
optional: true
'@rspack/binding-linux-x64-gnu@1.0.0-alpha.1':
optional: true
'@rspack/binding-linux-x64-musl@1.0.0-alpha.1':
optional: true
'@rspack/binding-win32-arm64-msvc@1.0.0-alpha.1':
optional: true
'@rspack/binding-win32-ia32-msvc@1.0.0-alpha.1':
optional: true
'@rspack/binding-win32-x64-msvc@1.0.0-alpha.1':
optional: true
'@rspack/binding@1.0.0-alpha.1':
optionalDependencies:
'@rspack/binding-darwin-arm64': 1.0.0-alpha.1
'@rspack/binding-darwin-x64': 1.0.0-alpha.1
'@rspack/binding-linux-arm64-gnu': 1.0.0-alpha.1
'@rspack/binding-linux-arm64-musl': 1.0.0-alpha.1
'@rspack/binding-linux-x64-gnu': 1.0.0-alpha.1
'@rspack/binding-linux-x64-musl': 1.0.0-alpha.1
'@rspack/binding-win32-arm64-msvc': 1.0.0-alpha.1
'@rspack/binding-win32-ia32-msvc': 1.0.0-alpha.1
'@rspack/binding-win32-x64-msvc': 1.0.0-alpha.1
'@rspack/core@1.0.0-alpha.1(@swc/helpers@0.5.11)':
dependencies:
'@module-federation/runtime-tools': 0.2.3
'@rspack/binding': 1.0.0-alpha.1
'@rspack/lite-tapable': 1.0.0-alpha.1
caniuse-lite: 1.0.30001579
optionalDependencies:
'@swc/helpers': 0.5.11
'@rspack/lite-tapable@1.0.0-alpha.1': {}
'@rushstack/eslint-patch@1.3.3': {} '@rushstack/eslint-patch@1.3.3': {}
'@shuding/opentype.js@1.4.0-beta.0': '@shuding/opentype.js@1.4.0-beta.0':
@ -20403,7 +20551,6 @@ snapshots:
braces@3.0.3: braces@3.0.3:
dependencies: dependencies:
fill-range: 7.1.1 fill-range: 7.1.1
optional: true
brorand@1.1.0: {} brorand@1.1.0: {}
@ -20779,7 +20926,6 @@ snapshots:
readdirp: 3.6.0 readdirp: 3.6.0
optionalDependencies: optionalDependencies:
fsevents: 2.3.3 fsevents: 2.3.3
optional: true
chownr@1.1.3: {} chownr@1.1.3: {}
@ -23125,7 +23271,6 @@ snapshots:
fill-range@7.1.1: fill-range@7.1.1:
dependencies: dependencies:
to-regex-range: 5.0.1 to-regex-range: 5.0.1
optional: true
finalhandler@1.1.2: finalhandler@1.1.2:
dependencies: dependencies:
@ -29374,7 +29519,7 @@ snapshots:
sass@1.77.6: sass@1.77.6:
dependencies: dependencies:
chokidar: 3.5.3 chokidar: 3.6.0
immutable: 4.1.0 immutable: 4.1.0
source-map-js: 1.0.2 source-map-js: 1.0.2
@ -29714,12 +29859,17 @@ snapshots:
source-map-support@0.5.13: source-map-support@0.5.13:
dependencies: dependencies:
buffer-from: 1.1.1 buffer-from: 1.1.2
source-map: 0.6.1 source-map: 0.6.1
source-map-support@0.5.20: source-map-support@0.5.20:
dependencies: dependencies:
buffer-from: 1.1.1 buffer-from: 1.1.2
source-map: 0.6.1
source-map-support@0.5.21:
dependencies:
buffer-from: 1.1.2
source-map: 0.6.1 source-map: 0.6.1
source-map-url@0.4.0: {} source-map-url@0.4.0: {}
@ -30319,14 +30469,14 @@ snapshots:
'@jridgewell/source-map': 0.3.3 '@jridgewell/source-map': 0.3.3
acorn: 8.11.3 acorn: 8.11.3
commander: 2.20.0 commander: 2.20.0
source-map-support: 0.5.20 source-map-support: 0.5.21
terser@5.5.1: terser@5.5.1:
dependencies: dependencies:
acorn: 8.11.3 acorn: 8.11.3
commander: 2.20.0 commander: 2.20.0
source-map: 0.7.4 source-map: 0.7.4
source-map-support: 0.5.20 source-map-support: 0.5.21
test-exclude@6.0.0: test-exclude@6.0.0:
dependencies: dependencies: