Unverified Commit 2a510e50 authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

Add opt-in Module Federation producer declarations

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 715928f0
...@@ -3,12 +3,13 @@ use std::collections::BTreeSet; ...@@ -3,12 +3,13 @@ use std::collections::BTreeSet;
use anyhow::{Context, Result, bail}; use anyhow::{Context, Result, bail};
use next_core::app_structure::FileSystemPathVec; use next_core::app_structure::FileSystemPathVec;
use turbo_rcstr::RcStr; use turbo_rcstr::RcStr;
use turbo_tasks::{Completion, ResolvedVc, Vc}; use turbo_tasks::{Completion, Completions, ResolvedVc, Vc};
use turbo_tasks_fs::{File, FileContent, FileSystemPath}; use turbo_tasks_fs::{File, FileContent, FileSystemPath};
use turbopack::module_federation::{module_federation_container_source, shared_provider_version}; use turbopack::module_federation::{module_federation_container_source, shared_provider_version};
use turbopack_browser::BrowserChunkingContext; use turbopack_browser::BrowserChunkingContext;
use turbopack_core::{ use turbopack_core::{
asset::AssetContent, asset::AssetContent,
changed::any_source_content_changed_of_module,
chunk::{ chunk::{
AssetSuffix, ChunkableModule, ChunkingContext, ChunkingContextExt, EntryChunkGroupResult, AssetSuffix, ChunkableModule, ChunkingContext, ChunkingContextExt, EntryChunkGroupResult,
availability_info::AvailabilityInfo, availability_info::AvailabilityInfo,
...@@ -351,7 +352,25 @@ impl Endpoint for ModuleFederationEndpoint { ...@@ -351,7 +352,25 @@ impl Endpoint for ModuleFederationEndpoint {
#[turbo_tasks::function] #[turbo_tasks::function]
async fn client_changed(self: Vc<Self>) -> Result<Vc<Completion>> { async fn client_changed(self: Vc<Self>) -> Result<Vc<Completion>> {
Ok(self.await?.project.federation_changed(self.output_assets())) let project = self.await?.project;
let outputs = project.federation_changed(self.output_assets());
if !project
.next_config()
.turbopack_module_federation()
.await?
.dts_enabled
{
return Ok(outputs);
}
// A declaration-only edit need not change the emitted JS. Watch the exposed source
// graph as well so development type archives cannot silently become stale.
let source =
any_source_content_changed_of_module(*self.entry_module().to_resolved().await?);
Ok(Vc::<Completions>::cell(vec![
outputs.to_resolved().await?,
source.to_resolved().await?,
])
.completed())
} }
#[turbo_tasks::function] #[turbo_tasks::function]
......
...@@ -199,6 +199,42 @@ module.exports = { ...@@ -199,6 +199,42 @@ module.exports = {
For CDN deployments, configure the same header on the CDN response for the manifest. This does not change the CORS policy of other Next.js assets. For CDN deployments, configure the same header on the CDN response for the manifest. This does not change the CORS policy of other Next.js assets.
## Publishing TypeScript declarations
A **producer** that exposes TypeScript modules can opt into the upstream Module Federation type archive and declaration API. Install the optional build-time peer in the producing app:
```bash
pnpm add @module-federation/dts-plugin@^2.9.0
```
```ts filename="next.config.ts"
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
turbopackModuleFederation: {
name: 'catalog',
exposes: { './product': './app/product.tsx' },
dts: {
generateTypes: {
tsConfigPath: './tsconfig.json',
// Optional: abortOnError: false, extractThirdParty: true,
// extractRemoteTypes: true,
},
},
},
},
}
export default nextConfig
```
Use `dts: { generateTypes: true }` for upstream generation defaults with `abortOnError: true`. `tsConfigPath` must resolve inside the producing project; custom output names or paths and `consumeTypes` are not supported. A host-only config cannot enable generation. Apps without DTS need no DTS package or generation work.
Successful builds serve `/_next/static/@mf-types.zip` (real declarations for exposed modules) and `/_next/static/@mf-types.d.ts` (remote API keys). The producer manifest advertises them under `metaData.types` with `path`, `name`, `zip` and `api`. Development edits to exposed TypeScript refresh the files without a restart. Declaration errors fail production builds by default and appear as development issues. Setting `abortOnError: false` instead logs a warning and publishes neither file nor manifest type metadata; it **does not** disable Next.js' own TypeScript build checks. Type artifacts are never served from a previous successful generation after a DTS error.
This option only **produces** declarations. Hosts must acquire and configure remote declarations themselves; automatic host-side download/import resolution is not yet supported.
## Sharing modules ## Sharing modules
The `shared` option uses webpack-compatible share keys and configuration: The `shared` option uses webpack-compatible share keys and configuration:
......
...@@ -111,6 +111,7 @@ ...@@ -111,6 +111,7 @@
"styled-jsx": "5.1.6" "styled-jsx": "5.1.6"
}, },
"peerDependencies": { "peerDependencies": {
"@module-federation/dts-plugin": "^2.9.0",
"@opentelemetry/api": "^1.1.0", "@opentelemetry/api": "^1.1.0",
"@playwright/test": "^1.51.1", "@playwright/test": "^1.51.1",
"babel-plugin-react-compiler": "*", "babel-plugin-react-compiler": "*",
...@@ -119,6 +120,9 @@ ...@@ -119,6 +120,9 @@
"sass": "^1.3.0" "sass": "^1.3.0"
}, },
"peerDependenciesMeta": { "peerDependenciesMeta": {
"@module-federation/dts-plugin": {
"optional": true
},
"babel-plugin-react-compiler": { "babel-plugin-react-compiler": {
"optional": true "optional": true
}, },
......
...@@ -21,6 +21,7 @@ import { normalizePath } from '../../lib/normalize-path' ...@@ -21,6 +21,7 @@ import { normalizePath } from '../../lib/normalize-path'
import type { ProjectOptions, RawEntrypoints } from '../swc/types' import type { ProjectOptions, RawEntrypoints } from '../swc/types'
import { Bundler } from '../../lib/bundler' import { Bundler } from '../../lib/bundler'
import { getStrictRouteMatchingDefaultWarning } from '../../server/lib/router-utils/strict-route-matching-config' import { getStrictRouteMatchingDefaultWarning } from '../../server/lib/router-utils/strict-route-matching-config'
import { writeModuleFederationTypes } from '../../lib/module-federation-types'
export async function turbopackBuild(telemetry: Telemetry): Promise<{ export async function turbopackBuild(telemetry: Telemetry): Promise<{
duration: number duration: number
...@@ -191,6 +192,11 @@ export async function turbopackBuild(telemetry: Telemetry): Promise<{ ...@@ -191,6 +192,11 @@ export async function turbopackBuild(telemetry: Telemetry): Promise<{
strictRouteMatchingDefaultWarning: strictRouteMatchingDefaultWarning:
getStrictRouteMatchingDefaultWarning(config), getStrictRouteMatchingDefaultWarning(config),
}) })
await writeModuleFederationTypes({
projectDir: dir,
distDir,
federation: config.experimental.turbopackModuleFederation,
})
// Skip when telemetry is fully off — featureUsage() isn't free. // Skip when telemetry is fully off — featureUsage() isn't free.
if (telemetry.isEnabled || process.env.NEXT_TELEMETRY_DEBUG) { if (telemetry.isEnabled || process.env.NEXT_TELEMETRY_DEBUG) {
......
import { promises as fs } from 'node:fs'
import { createRequire } from 'node:module'
import path from 'node:path'
import semver from 'next/dist/compiled/semver'
import type { TurbopackModuleFederationOptions } from '../server/config-shared'
import * as Log from '../build/output/log'
type DtsPlugin = {
normalizeGenerateTypesOptions(options: {
context: string
outputDir: string
dtsOptions: {
generateTypes: {
tsConfigPath: string
abortOnError: true
extractThirdParty?: boolean
extractRemoteTypes?: boolean
compileInChildProcess: false
}
consumeTypes: false
}
pluginOptions: {
name: string
filename: string
exposes: Record<string, unknown>
shared: Record<string, unknown>
}
}): unknown
generateTypesAPI(options: { dtsManagerOptions: unknown }): Promise<unknown>
}
const ZIP = '@mf-types.zip'
const API = '@mf-types.d.ts'
/** Reject ZIP members that could escape the extraction root on any supported platform. */
export function validateFederationTypesArchive(archive: Buffer): void {
const start = Math.max(0, archive.length - 22 - 0xffff)
let end = -1
for (let offset = archive.length - 22; offset >= start; offset--) {
if (
archive.readUInt32LE(offset) === 0x06054b50 &&
offset + 22 + archive.readUInt16LE(offset + 20) === archive.length
) {
end = offset
break
}
}
if (end < 0)
throw new Error(
'Module Federation DTS generator emitted an invalid ZIP archive'
)
const count = archive.readUInt16LE(end + 10)
const size = archive.readUInt32LE(end + 12)
let offset = archive.readUInt32LE(end + 16)
if (
!count ||
count === 0xffff ||
offset === 0xffffffff ||
offset + size > end
) {
throw new Error(
'Module Federation DTS generator emitted an invalid ZIP directory'
)
}
for (let index = 0; index < count; index++) {
if (offset + 46 > end || archive.readUInt32LE(offset) !== 0x02014b50) {
throw new Error(
'Module Federation DTS generator emitted an invalid ZIP entry'
)
}
const nameLength = archive.readUInt16LE(offset + 28)
const extraLength = archive.readUInt16LE(offset + 30)
const commentLength = archive.readUInt16LE(offset + 32)
const next = offset + 46 + nameLength + extraLength + commentLength
if (next > end)
throw new Error('Module Federation DTS ZIP entry exceeds its directory')
const name = archive.toString('utf8', offset + 46, offset + 46 + nameLength)
const segments = name.split('/')
if (
!name ||
name.startsWith('/') ||
/[\\:\0]/.test(name) ||
segments.some(
(part, partIndex) =>
part === '..' ||
part === '.' ||
(part === '' && partIndex !== segments.length - 1)
)
) {
throw new Error(
`Module Federation DTS ZIP contains an unsafe entry: ${name}`
)
}
offset = next
}
}
function toRecord<T>(
entries: Record<string, T> | Array<string | Record<string, T>>
): Record<string, T | string> {
if (!Array.isArray(entries)) return entries
return Object.assign(
{},
...entries.map((entry) =>
typeof entry === 'string' ? { [entry]: entry } : entry
)
)
}
function loadGenerator(projectDir: string): DtsPlugin {
const fromProject = createRequire(path.join(projectDir, 'package.json'))
let packageJson: { version: string }
try {
packageJson = fromProject('@module-federation/dts-plugin/package.json')
} catch {
throw new Error(
'Module Federation DTS generation requires @module-federation/dts-plugin@^2.9.0. Install it in the producing app.'
)
}
if (!semver.satisfies(packageJson.version, '^2.9.0')) {
throw new Error(
`Module Federation DTS generation requires @module-federation/dts-plugin@^2.9.0; found ${packageJson.version}.`
)
}
return fromProject('@module-federation/dts-plugin') as DtsPlugin
}
async function resolveTsConfig(projectDir: string, configPath: string) {
// The schema validates lexical traversal; realpath also rejects symlink escapes.
const root = await fs.realpath(projectDir)
let config: string
try {
config = await fs.realpath(path.join(root, configPath))
} catch (error) {
throw new Error(
`Module Federation dts.generateTypes.tsConfigPath '${configPath}' could not be read: ${error}`
)
}
const relative = path.relative(root, config)
if (
!relative ||
relative === '..' ||
relative.startsWith(`..${path.sep}`) ||
path.isAbsolute(relative)
) {
throw new Error(
'Module Federation dts.generateTypes.tsConfigPath must remain inside the project'
)
}
return configPath
}
type GenerationContext = {
projectDir: string
distDir: string
federation: TurbopackModuleFederationOptions | undefined
}
async function generateTypes({
projectDir,
distDir,
federation,
}: GenerationContext) {
if (!federation?.dts) return
const options = federation.dts.generateTypes
const generation = options === true ? {} : options
const name = federation.name
if (!name || !federation.exposes) {
throw new Error(
'Module Federation DTS generation requires a named producer with exposes'
)
}
const staging = path.join(distDir, 'cache', 'module-federation-types')
const staticDir = path.join(distDir, 'static')
const manifestPath = path.join(staticDir, 'mf-manifest.json')
const zipPath = path.join(staticDir, ZIP)
const apiPath = path.join(staticDir, API)
const updateManifest = async (publish: boolean) => {
const manifest = JSON.parse(await fs.readFile(manifestPath, 'utf8'))
if (publish) {
manifest.metaData.types = {
path: '',
name: '@mf-types',
zip: ZIP,
api: API,
}
} else {
delete manifest.metaData.types
}
const temp = `${manifestPath}.${process.pid}.tmp`
try {
await fs.writeFile(temp, JSON.stringify(manifest, null, 2))
await fs.rename(temp, manifestPath)
} finally {
await fs.rm(temp, { force: true })
}
}
// Unadvertise the previous pair before removing it so consumers cannot see
// metadata pointing at files from a previous successful generation.
await updateManifest(false)
await Promise.all([
fs.rm(zipPath, { force: true }),
fs.rm(apiPath, { force: true }),
])
await fs.rm(staging, { recursive: true, force: true })
await fs.mkdir(staging, { recursive: true })
// Missing peers and invalid config always fail, even with abortOnError: false.
const plugin = loadGenerator(projectDir)
const tsConfigPath = await resolveTsConfig(
projectDir,
generation.tsConfigPath ?? './tsconfig.json'
)
try {
const dtsManagerOptions = plugin.normalizeGenerateTypesOptions({
context: projectDir,
outputDir: staging,
dtsOptions: {
generateTypes: {
tsConfigPath,
// The upstream lenient mode silently leaves partial files after a failure.
// Interpret the public abortOnError option here instead.
abortOnError: true,
extractThirdParty: generation.extractThirdParty,
extractRemoteTypes: generation.extractRemoteTypes,
compileInChildProcess: false,
},
consumeTypes: false,
},
pluginOptions: {
name,
filename: federation.filename ?? `${name}.js`,
exposes: toRecord(federation.exposes),
shared: federation.shared ? toRecord(federation.shared) : {},
},
})
await plugin.generateTypesAPI({ dtsManagerOptions })
for (const filename of [ZIP, API]) {
if (!(await fs.stat(path.join(staging, filename))).size) {
throw new Error(
`Module Federation DTS generator emitted an empty ${filename}`
)
}
}
validateFederationTypesArchive(await fs.readFile(path.join(staging, ZIP)))
await fs.rename(path.join(staging, ZIP), zipPath)
await fs.rename(path.join(staging, API), apiPath)
await updateManifest(true)
} catch (error) {
await Promise.all([
fs.rm(zipPath, { force: true }),
fs.rm(apiPath, { force: true }),
])
await updateManifest(false)
if (generation.abortOnError !== false) throw error
Log.warn(
`Module Federation type generation failed; omitting types: ${error}`
)
} finally {
await fs.rm(staging, { recursive: true, force: true })
}
}
const pendingByOutput = new Map<string, Promise<void>>()
/** Publish a complete upstream type pair, or no types at all. Serialize writes per project. */
export function writeModuleFederationTypes(
context: GenerationContext
): Promise<void> {
if (!context.federation?.dts) return Promise.resolve()
const previous = pendingByOutput.get(context.distDir) ?? Promise.resolve()
const current = previous.catch(() => {}).then(() => generateTypes(context))
pendingByOutput.set(context.distDir, current)
const cleanup = () => {
if (pendingByOutput.get(context.distDir) === current) {
pendingByOutput.delete(context.distDir)
}
}
// A previous failed generation must not prevent a later source edit from fixing it.
current.then(cleanup, cleanup)
return current
}
...@@ -250,6 +250,34 @@ const zTurbopackModuleFederationFilename = z ...@@ -250,6 +250,34 @@ const zTurbopackModuleFederationFilename = z
'Module Federation filename must be a safe relative path without empty or ".." segments' 'Module Federation filename must be a safe relative path without empty or ".." segments'
) )
const zTurbopackModuleFederationTsConfigPath = z
.string()
.refine(
(value) =>
value.length > 0 &&
!value.startsWith('/') &&
!value.startsWith('\\') &&
!/[\\:\0?#]/.test(value) &&
value.split('/').every((segment) => segment !== '' && segment !== '..') &&
value.split('/').at(-1) !== '.',
'Module Federation dts.generateTypes.tsConfigPath must be a safe relative project path'
)
const zTurbopackModuleFederationDts = z.union([
z.literal(false),
z.strictObject({
generateTypes: z.union([
z.literal(true),
z.strictObject({
tsConfigPath: zTurbopackModuleFederationTsConfigPath.optional(),
abortOnError: z.boolean().optional(),
extractThirdParty: z.boolean().optional(),
extractRemoteTypes: z.boolean().optional(),
}),
]),
}),
])
const zTurbopackModuleFederationConfig: zod.ZodType<TurbopackModuleFederationOptions> = const zTurbopackModuleFederationConfig: zod.ZodType<TurbopackModuleFederationOptions> =
z z
.strictObject({ .strictObject({
...@@ -292,6 +320,7 @@ const zTurbopackModuleFederationConfig: zod.ZodType<TurbopackModuleFederationOpt ...@@ -292,6 +320,7 @@ const zTurbopackModuleFederationConfig: zod.ZodType<TurbopackModuleFederationOpt
remoteType: z.literal('script').optional(), remoteType: z.literal('script').optional(),
shareStrategy: z.enum(['version-first', 'loaded-first']).optional(), shareStrategy: z.enum(['version-first', 'loaded-first']).optional(),
implementation: z.string().min(1).optional(), implementation: z.string().min(1).optional(),
dts: zTurbopackModuleFederationDts.optional(),
runtimePlugins: z runtimePlugins: z
.array( .array(
z.union([ z.union([
...@@ -313,6 +342,17 @@ const zTurbopackModuleFederationConfig: zod.ZodType<TurbopackModuleFederationOpt ...@@ -313,6 +342,17 @@ const zTurbopackModuleFederationConfig: zod.ZodType<TurbopackModuleFederationOpt
'Module Federation exposes require a non-empty container name', 'Module Federation exposes require a non-empty container name',
}) })
} }
if (
config.dts &&
(!config.exposes || Object.keys(config.exposes).length === 0)
) {
context.addIssue({
code: z.ZodIssueCode.custom,
path: ['dts'],
message:
'Module Federation dts.generateTypes requires exposed modules',
})
}
}) })
const zTurbopackConfig: zod.ZodType<TurbopackOptions> = z.strictObject({ const zTurbopackConfig: zod.ZodType<TurbopackOptions> = z.strictObject({
......
...@@ -338,6 +338,22 @@ export type TurbopackModuleFederationSharedConfig = ...@@ -338,6 +338,22 @@ export type TurbopackModuleFederationSharedConfig =
version?: string | false version?: string | false
} }
export type TurbopackModuleFederationDtsOptions =
| false
| {
/** Generate a standard type archive and API for this exposed container. */
generateTypes:
| true
| {
/** Relative path to a TypeScript configuration within this project. */
tsConfigPath?: string
/** Fail on declaration errors (default: true). */
abortOnError?: boolean
extractThirdParty?: boolean
extractRemoteTypes?: boolean
}
}
export interface TurbopackModuleFederationOptions { export interface TurbopackModuleFederationOptions {
/** Name of this container. Required when exposing modules. */ /** Name of this container. Required when exposing modules. */
name?: string name?: string
...@@ -365,6 +381,8 @@ export interface TurbopackModuleFederationOptions { ...@@ -365,6 +381,8 @@ export interface TurbopackModuleFederationOptions {
runtimePlugins?: Array<string | [string, unknown]> runtimePlugins?: Array<string | [string, unknown]>
/** Package supplying the enhanced runtime-tools entrypoints. */ /** Package supplying the enhanced runtime-tools entrypoints. */
implementation?: string implementation?: string
/** Opt-in producer declaration generation; requires @module-federation/dts-plugin. */
dts?: TurbopackModuleFederationDtsOptions
} }
export interface WebpackConfigContext { export interface WebpackConfigContext {
......
...@@ -350,6 +350,57 @@ describe('loadConfig', () => { ...@@ -350,6 +350,57 @@ describe('loadConfig', () => {
}) })
}) })
describe('experimental.turbopackModuleFederation.dts', () => {
const producer = {
name: 'remote',
exposes: { './Widget': './src/Widget.tsx' },
}
const parse = (federation: Record<string, unknown>) =>
configSchema.safeParse({
experimental: { turbopackModuleFederation: federation },
})
it('accepts disabled and supported producer generation options', () => {
expect(parse({ dts: false })).toHaveProperty('success', true)
expect(
parse({ ...producer, dts: { generateTypes: true } })
).toHaveProperty('success', true)
expect(
parse({
...producer,
dts: {
generateTypes: {
tsConfigPath: './configs/tsconfig.json',
abortOnError: false,
extractThirdParty: true,
extractRemoteTypes: false,
},
},
})
).toHaveProperty('success', true)
})
it('rejects host generation, unsupported options and unsafe paths', () => {
for (const federation of [
{ dts: { generateTypes: true } },
{ ...producer, dts: true },
{ ...producer, dts: { consumeTypes: true, generateTypes: true } },
{ ...producer, dts: { generateTypes: { outputDir: '/tmp' } } },
{ ...producer, dts: { generateTypes: false } },
{
...producer,
dts: { generateTypes: { tsConfigPath: '../secret.json' } },
},
{
...producer,
dts: { generateTypes: { tsConfigPath: 'C:\\secret.json' } },
},
]) {
expect(parse(federation)).toHaveProperty('success', false)
}
})
})
describe('experimental.durableUseCacheEntries', () => { describe('experimental.durableUseCacheEntries', () => {
const originalTurbopack = process.env.TURBOPACK const originalTurbopack = process.env.TURBOPACK
......
...@@ -1255,6 +1255,11 @@ export async function createHotReloaderTurbopack( ...@@ -1255,6 +1255,11 @@ export async function createHotReloaderTurbopack(
logErrors: true, logErrors: true,
dev: { dev: {
moduleFederationTypes: {
projectDir: projectPath,
distDir,
federation: nextConfig.experimental.turbopackModuleFederation,
},
assetMapper, assetMapper,
changeSubscriptions, changeSubscriptions,
clients: [ clients: [
......
...@@ -37,6 +37,8 @@ import { ...@@ -37,6 +37,8 @@ import {
type TopLevelIssuesMap, type TopLevelIssuesMap,
} from '../../shared/lib/turbopack/utils' } from '../../shared/lib/turbopack/utils'
import { MIDDLEWARE_FILENAME, PROXY_FILENAME } from '../../lib/constants' import { MIDDLEWARE_FILENAME, PROXY_FILENAME } from '../../lib/constants'
import type { TurbopackModuleFederationOptions } from '../config-shared'
import { writeModuleFederationTypes } from '../../lib/module-federation-types'
const onceErrorSet = new Set() const onceErrorSet = new Set()
/** /**
...@@ -613,6 +615,11 @@ type HandleEntrypointsHooks = { ...@@ -613,6 +615,11 @@ type HandleEntrypointsHooks = {
} }
type HandleEntrypointsDevOpts = { type HandleEntrypointsDevOpts = {
moduleFederationTypes: {
projectDir: string
distDir: string
federation: TurbopackModuleFederationOptions | undefined
}
assetMapper: AssetMapper assetMapper: AssetMapper
changeSubscriptions: ChangeSubscriptions changeSubscriptions: ChangeSubscriptions
clients: Array<ws> clients: Array<ws>
...@@ -763,7 +770,35 @@ export async function handleEntrypoints({ ...@@ -763,7 +770,35 @@ export async function handleEntrypoints({
if (moduleFederation) { if (moduleFederation) {
const key = getEntryKey('assets', 'client', 'module-federation') const key = getEntryKey('assets', 'client', 'module-federation')
const writtenEndpoint = await moduleFederation.writeToDisk() const withDtsIssues = async (result: TurbopackResult<WrittenEndpoint>) => {
try {
await writeModuleFederationTypes(dev.moduleFederationTypes)
return result
} catch (error) {
const message = String(error)
Log.error(`Module Federation type generation failed: ${message}`)
return {
...result,
issues: [
...result.issues,
{
severity: 'error',
stage: 'code generation',
filePath: '[project]',
title: {
type: 'text' as const,
value: 'Module Federation type generation failed',
},
description: { type: 'text' as const, value: message },
documentationLink: '',
},
],
}
}
}
const writtenEndpoint = await withDtsIssues(
await moduleFederation.writeToDisk()
)
dev?.hooks.handleWrittenEndpoint(key, writtenEndpoint, false) dev?.hooks.handleWrittenEndpoint(key, writtenEndpoint, false)
processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors) processIssues(currentEntryIssues, key, writtenEndpoint, false, logErrors)
dev?.hooks.subscribeToChanges( dev?.hooks.subscribeToChanges(
...@@ -771,7 +806,9 @@ export async function handleEntrypoints({ ...@@ -771,7 +806,9 @@ export async function handleEntrypoints({
/** includeIssues=*/ false, /** includeIssues=*/ false,
moduleFederation, moduleFederation,
async () => { async () => {
const updatedEndpoint = await moduleFederation.writeToDisk() const updatedEndpoint = await withDtsIssues(
await moduleFederation.writeToDisk()
)
dev?.hooks.handleWrittenEndpoint(key, updatedEndpoint, false) dev?.hooks.handleWrittenEndpoint(key, updatedEndpoint, false)
processIssues( processIssues(
currentEntryIssues, currentEntryIssues,
...@@ -787,6 +824,11 @@ export async function handleEntrypoints({ ...@@ -787,6 +824,11 @@ export async function handleEntrypoints({
data: `error in Module Federation subscription: ${error}`, data: `error in Module Federation subscription: ${error}`,
}) })
) )
// A type-only source edit can happen immediately after startup. Wait until the
// source graph subscription is registered before advertising the DTS endpoint.
if (dev.moduleFederationTypes.federation?.dts) {
await dev.changeSubscriptions.get(key)
}
} }
if (middleware) { if (middleware) {
......
...@@ -1255,6 +1255,9 @@ importers: ...@@ -1255,6 +1255,9 @@ importers:
packages/next: packages/next:
dependencies: dependencies:
'@module-federation/dts-plugin':
specifier: ^2.9.0
version: 2.9.1(typescript@6.0.2)
'@next/env': '@next/env':
specifier: workspace:* specifier: workspace:*
version: link:../next-env version: link:../next-env
...@@ -4422,12 +4425,24 @@ packages: ...@@ -4422,12 +4425,24 @@ packages:
resolution: {integrity: sha512-d//GE8/Yh7aC3e7p+kZG8JqqEAwwDUmAfvH1quogtbk+ksS6E0RR6toKKESPYYZVre0meqkJb27zb+dhqE9Sgw==} resolution: {integrity: sha512-d//GE8/Yh7aC3e7p+kZG8JqqEAwwDUmAfvH1quogtbk+ksS6E0RR6toKKESPYYZVre0meqkJb27zb+dhqE9Sgw==}
engines: {node: '>=18'} engines: {node: '>=18'}
'@module-federation/dts-plugin@2.9.1':
resolution: {integrity: sha512-OnJQNRrjUfI1UJu+rIUzC0jl2uQcpRp/hIbMLZChSleFLlYpvvMzu/s33E7oiST421HAg9gilgYLj1WAn1SSOw==}
peerDependencies:
typescript: ^4.9.0 || ^5.0.0 || ^6.0.0 || ^7.0.0
vue-tsc: '>=1.0.24'
peerDependenciesMeta:
vue-tsc:
optional: true
'@module-federation/error-codes@0.21.6': '@module-federation/error-codes@0.21.6':
resolution: {integrity: sha512-MLJUCQ05KnoVl8xd6xs9a5g2/8U+eWmVxg7xiBMeR0+7OjdWUbHwcwgVFatRIwSZvFgKHfWEiI7wsU1q1XbTRQ==} resolution: {integrity: sha512-MLJUCQ05KnoVl8xd6xs9a5g2/8U+eWmVxg7xiBMeR0+7OjdWUbHwcwgVFatRIwSZvFgKHfWEiI7wsU1q1XbTRQ==}
'@module-federation/error-codes@2.9.1': '@module-federation/error-codes@2.9.1':
resolution: {integrity: sha512-5lqrIZTeMiKdn4uuX/+X8uN/4C0yqI8P3WO42DNRR7B9gCA4HMDCHrrxU8odQup9bzRsN5TJSz3av6d2iNmPgA==} resolution: {integrity: sha512-5lqrIZTeMiKdn4uuX/+X8uN/4C0yqI8P3WO42DNRR7B9gCA4HMDCHrrxU8odQup9bzRsN5TJSz3av6d2iNmPgA==}
'@module-federation/managers@2.9.1':
resolution: {integrity: sha512-X20XDvkTbClfG8Ig0VQW2GcUCzLAopb7fxdrVyk3kqLVeB6fLoNLhzA8K/S5xhnkeY7YhrOxZBujMnK5wETxtA==}
'@module-federation/runtime-core@0.21.6': '@module-federation/runtime-core@0.21.6':
resolution: {integrity: sha512-5Hd1Y5qp5lU/aTiK66lidMlM/4ji2gr3EXAtJdreJzkY+bKcI5+21GRcliZ4RAkICmvdxQU5PHPL71XmNc7Lsw==} resolution: {integrity: sha512-5Hd1Y5qp5lU/aTiK66lidMlM/4ji2gr3EXAtJdreJzkY+bKcI5+21GRcliZ4RAkICmvdxQU5PHPL71XmNc7Lsw==}
...@@ -4452,6 +4467,9 @@ packages: ...@@ -4452,6 +4467,9 @@ packages:
'@module-federation/sdk@2.9.1': '@module-federation/sdk@2.9.1':
resolution: {integrity: sha512-JneBWSHr9ZCZHa5geNUleVK2vBTugWXLIXlV72UAhgHm1cTMYKZljnhRSX59n7Xssz4Yk+m+W3rYg6Eb4ouL8w==} resolution: {integrity: sha512-JneBWSHr9ZCZHa5geNUleVK2vBTugWXLIXlV72UAhgHm1cTMYKZljnhRSX59n7Xssz4Yk+m+W3rYg6Eb4ouL8w==}
'@module-federation/third-party-dts-extractor@2.9.1':
resolution: {integrity: sha512-8H3/SWPD93EHmLG0F30J0ihsGI+LpCT7xdc6YXQWX+1lkgzwJoWTwm4j+LMQRP+1OtSxrpEW5ebcKqKeTZ2B+Q==}
'@module-federation/webpack-bundler-runtime@0.21.6': '@module-federation/webpack-bundler-runtime@0.21.6':
resolution: {integrity: sha512-7zIp3LrcWbhGuFDTUMLJ2FJvcwjlddqhWGxi/MW3ur1a+HaO8v5tF2nl+vElKmbG1DFLU/52l3PElVcWf/YcsQ==} resolution: {integrity: sha512-7zIp3LrcWbhGuFDTUMLJ2FJvcwjlddqhWGxi/MW3ur1a+HaO8v5tF2nl+vElKmbG1DFLU/52l3PElVcWf/YcsQ==}
...@@ -7580,6 +7598,10 @@ packages: ...@@ -7580,6 +7598,10 @@ packages:
engines: {node: '>=0.4.0'} engines: {node: '>=0.4.0'}
hasBin: true hasBin: true
adm-zip@0.6.0:
resolution: {integrity: sha512-XleryMhbuksdKtofnWZ9Sk+4CUTbms4Mb/EU32SZwToAyZ5RgVos/ki8n+yr0LWHOGKuakbXTuuYNHLQjhddgg==}
engines: {node: '>=14.0'}
agent-base@6.0.2: agent-base@6.0.2:
resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==}
engines: {node: '>= 6.0.0'} engines: {node: '>= 6.0.0'}
...@@ -11890,6 +11912,11 @@ packages: ...@@ -11890,6 +11912,11 @@ packages:
isomorphic-unfetch@3.0.0: isomorphic-unfetch@3.0.0:
resolution: {integrity: sha512-V0tmJSYfkKokZ5mgl0cmfQMTb7MLHsBMngTkbLY0eXvKqiVRRoZP04Ly+KhKrJfKtzC9E6Pp15Jo+bwh7Vi2XQ==} resolution: {integrity: sha512-V0tmJSYfkKokZ5mgl0cmfQMTb7MLHsBMngTkbLY0eXvKqiVRRoZP04Ly+KhKrJfKtzC9E6Pp15Jo+bwh7Vi2XQ==}
isomorphic-ws@5.0.0:
resolution: {integrity: sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==}
peerDependencies:
ws: '*'
isstream@0.1.2: isstream@0.1.2:
resolution: {integrity: sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==} resolution: {integrity: sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==}
...@@ -17078,6 +17105,10 @@ packages: ...@@ -17078,6 +17105,10 @@ packages:
resolution: {integrity: sha512-RqslV2Us5BrllB+JeiZnK4peryVTndy9Dnqq62S3yYRRTj0tFQCwEniUy2167skdGOy3vqRzEvl1Dm4sV2ReDg==} resolution: {integrity: sha512-RqslV2Us5BrllB+JeiZnK4peryVTndy9Dnqq62S3yYRRTj0tFQCwEniUy2167skdGOy3vqRzEvl1Dm4sV2ReDg==}
engines: {node: '>=20.18.1'} engines: {node: '>=20.18.1'}
undici@7.29.0:
resolution: {integrity: sha512-IDxfleLmmbSskfWSUATiN1nfn2rDuvnMOqb5CWR92iIfojA0Ud+ulOAAEQ57LPr9rWmsreUyf5lwyao+7GNNVw==}
engines: {node: '>=20.18.1'}
unfetch@4.2.0: unfetch@4.2.0:
resolution: {integrity: sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==} resolution: {integrity: sha512-F9p7yYCn6cIW9El1zi0HI6vqpeIvBsr3dSuRO6Xuppb1u5rXpCPmMvLSyECLhybr9isec8Ohl0hPekMVrEinDA==}
...@@ -17805,6 +17836,18 @@ packages: ...@@ -17805,6 +17836,18 @@ packages:
utf-8-validate: utf-8-validate:
optional: true optional: true
ws@8.21.3:
resolution: {integrity: sha512-201TZ/kPWxoPr/OKWjquZR1SWKXcvxdH+e1xrx89b3YbmzLMFCLfnaG1HFIgWzJOEWZ7MvpK++odZufgYR50Rw==}
engines: {node: '>=10.0.0'}
peerDependencies:
bufferutil: ^4.0.1
utf-8-validate: '>=5.0.2'
peerDependenciesMeta:
bufferutil:
optional: true
utf-8-validate:
optional: true
xdg-app-paths@5.1.0: xdg-app-paths@5.1.0:
resolution: {integrity: sha512-RAQ3WkPf4KTU1A8RtFx3gWywzVKe00tfOPFfl2NDGqbIFENQO4kqAJp7mhQjNj/33W5x5hiWWUdyfPq/5SU3QA==} resolution: {integrity: sha512-RAQ3WkPf4KTU1A8RtFx3gWywzVKe00tfOPFfl2NDGqbIFENQO4kqAJp7mhQjNj/33W5x5hiWWUdyfPq/5SU3QA==}
engines: {node: '>=6'} engines: {node: '>=6'}
...@@ -20831,11 +20874,30 @@ snapshots: ...@@ -20831,11 +20874,30 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
'@module-federation/dts-plugin@2.9.1(typescript@6.0.2)':
dependencies:
'@module-federation/error-codes': 2.9.1
'@module-federation/managers': 2.9.1
'@module-federation/sdk': 2.9.1
'@module-federation/third-party-dts-extractor': 2.9.1
adm-zip: 0.6.0
isomorphic-ws: 5.0.0(ws@8.21.3)
typescript: 6.0.2
undici: 7.29.0
ws: 8.21.3
transitivePeerDependencies:
- bufferutil
- utf-8-validate
'@module-federation/error-codes@0.21.6': {} '@module-federation/error-codes@0.21.6': {}
'@module-federation/error-codes@2.9.1': '@module-federation/error-codes@2.9.1':
optional: true optional: true
'@module-federation/managers@2.9.1':
dependencies:
'@module-federation/sdk': 2.9.1
'@module-federation/runtime-core@0.21.6': '@module-federation/runtime-core@0.21.6':
dependencies: dependencies:
'@module-federation/error-codes': 0.21.6 '@module-federation/error-codes': 0.21.6
...@@ -20876,6 +20938,8 @@ snapshots: ...@@ -20876,6 +20938,8 @@ snapshots:
'@module-federation/sdk@2.9.1': '@module-federation/sdk@2.9.1':
optional: true optional: true
'@module-federation/third-party-dts-extractor@2.9.1': {}
'@module-federation/webpack-bundler-runtime@0.21.6': '@module-federation/webpack-bundler-runtime@0.21.6':
dependencies: dependencies:
'@module-federation/runtime': 0.21.6 '@module-federation/runtime': 0.21.6
...@@ -24163,6 +24227,8 @@ snapshots: ...@@ -24163,6 +24227,8 @@ snapshots:
acorn@8.8.0: {} acorn@8.8.0: {}
adm-zip@0.6.0: {}
agent-base@6.0.2(supports-color@8.1.1): agent-base@6.0.2(supports-color@8.1.1):
dependencies: dependencies:
debug: 4.1.1(supports-color@8.1.1) debug: 4.1.1(supports-color@8.1.1)
...@@ -29674,6 +29740,10 @@ snapshots: ...@@ -29674,6 +29740,10 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- encoding - encoding
isomorphic-ws@5.0.0(ws@8.21.3):
dependencies:
ws: 8.21.3
isstream@0.1.2: {} isstream@0.1.2: {}
istanbul-lib-coverage@3.2.0: {} istanbul-lib-coverage@3.2.0: {}
...@@ -36410,6 +36480,8 @@ snapshots: ...@@ -36410,6 +36480,8 @@ snapshots:
undici@7.22.0: {} undici@7.22.0: {}
undici@7.29.0: {}
unfetch@4.2.0: {} unfetch@4.2.0: {}
unherit@1.1.2: unherit@1.1.2:
...@@ -37361,6 +37433,8 @@ snapshots: ...@@ -37361,6 +37433,8 @@ snapshots:
ws@8.2.3: {} ws@8.2.3: {}
ws@8.21.3: {}
xdg-app-paths@5.1.0: xdg-app-paths@5.1.0:
dependencies: dependencies:
xdg-portable: 7.3.0 xdg-portable: 7.3.0
import type { ReactNode } from 'react'
export default function Root({ children }: { children: ReactNode }) {
return (
<html>
<body>{children}</body>
</html>
)
}
export default function Page() {
return <p>hello world</p>
}
export interface WidgetProps {
label: 'initial-label'
}
export function Widget({ label }: WidgetProps) {
return <span className="widget">{label}</span>
}
export const widgetVersion = 42 as const
export default Widget
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
experimental: {
turbopackModuleFederation: {
name: 'typedProducer',
exposes: {
'./Widget': './lib/Widget.tsx',
'./answer': './lib/answer.ts',
},
dts: {
generateTypes: {
tsConfigPath: './tsconfig.json',
abortOnError: true,
},
},
},
},
}
export default nextConfig
...@@ -320,6 +320,80 @@ pub enum ModuleFederationShareStrategy { ...@@ -320,6 +320,80 @@ pub enum ModuleFederationShareStrategy {
LoadedFirst, LoadedFirst,
} }
#[derive(
Clone,
Debug,
Default,
PartialEq,
Eq,
Serialize,
Deserialize,
Encode,
Decode,
NonLocalValue,
OperationValue,
)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub struct UnnormalizedModuleFederationGenerateTypes {
pub ts_config_path: Option<RcStr>,
pub abort_on_error: Option<bool>,
pub extract_third_party: Option<bool>,
pub extract_remote_types: Option<bool>,
}
#[derive(
Clone,
Debug,
PartialEq,
Eq,
Serialize,
Deserialize,
Encode,
Decode,
NonLocalValue,
OperationValue,
)]
#[serde(untagged)]
pub enum UnnormalizedModuleFederationGenerateTypesConfig {
Enabled(bool),
Options(UnnormalizedModuleFederationGenerateTypes),
}
#[derive(
Clone,
Debug,
PartialEq,
Eq,
Serialize,
Deserialize,
Encode,
Decode,
NonLocalValue,
OperationValue,
)]
#[serde(deny_unknown_fields, rename_all = "camelCase")]
pub struct UnnormalizedModuleFederationDtsOptions {
pub generate_types: UnnormalizedModuleFederationGenerateTypesConfig,
}
#[derive(
Clone,
Debug,
PartialEq,
Eq,
Serialize,
Deserialize,
Encode,
Decode,
NonLocalValue,
OperationValue,
)]
#[serde(untagged)]
pub enum UnnormalizedModuleFederationDts {
Disabled(bool),
Options(UnnormalizedModuleFederationDtsOptions),
}
#[derive( #[derive(
Clone, Clone,
Debug, Debug,
...@@ -344,6 +418,7 @@ pub struct UnnormalizedModuleFederationConfig { ...@@ -344,6 +418,7 @@ pub struct UnnormalizedModuleFederationConfig {
pub remote_type: Option<ModuleFederationRemoteType>, pub remote_type: Option<ModuleFederationRemoteType>,
pub share_strategy: Option<ModuleFederationShareStrategy>, pub share_strategy: Option<ModuleFederationShareStrategy>,
pub implementation: Option<RcStr>, pub implementation: Option<RcStr>,
pub dts: Option<UnnormalizedModuleFederationDts>,
#[bincode(with = "turbo_bincode::serde_self_describing")] #[bincode(with = "turbo_bincode::serde_self_describing")]
pub runtime_plugins: Option<Vec<serde_json::Value>>, pub runtime_plugins: Option<Vec<serde_json::Value>>,
} }
...@@ -359,6 +434,7 @@ pub struct ModuleFederationConfig { ...@@ -359,6 +434,7 @@ pub struct ModuleFederationConfig {
pub share_scope: RcStr, pub share_scope: RcStr,
pub share_strategy: ModuleFederationShareStrategy, pub share_strategy: ModuleFederationShareStrategy,
pub implementation: Option<RcStr>, pub implementation: Option<RcStr>,
pub dts_enabled: bool,
pub runtime_plugins: Vec<ModuleFederationRuntimePlugin>, pub runtime_plugins: Vec<ModuleFederationRuntimePlugin>,
} }
...@@ -466,6 +542,35 @@ impl UnnormalizedModuleFederationSharedEntries { ...@@ -466,6 +542,35 @@ impl UnnormalizedModuleFederationSharedEntries {
impl UnnormalizedModuleFederationConfig { impl UnnormalizedModuleFederationConfig {
pub fn normalize(self) -> Result<ModuleFederationConfig> { pub fn normalize(self) -> Result<ModuleFederationConfig> {
let dts_enabled = match self.dts {
None | Some(UnnormalizedModuleFederationDts::Disabled(false)) => false,
Some(UnnormalizedModuleFederationDts::Disabled(true)) => {
bail!("Module Federation dts must be false or an object with generateTypes")
}
Some(UnnormalizedModuleFederationDts::Options(options)) => {
match options.generate_types {
UnnormalizedModuleFederationGenerateTypesConfig::Enabled(true) => {}
UnnormalizedModuleFederationGenerateTypesConfig::Enabled(false) => {
bail!(
"Module Federation dts.generateTypes must be true or an options object"
)
}
UnnormalizedModuleFederationGenerateTypesConfig::Options(options) => {
if let Some(path) = options.ts_config_path {
validate_dts_ts_config_path(&path)?;
}
}
}
if self
.exposes
.as_ref()
.is_none_or(|exposes| exposes.clone().into_entries().is_empty())
{
bail!("Module Federation dts.generateTypes requires exposed modules");
}
true
}
};
let share_scope = self.share_scope.unwrap_or_else(|| "default".into()); let share_scope = self.share_scope.unwrap_or_else(|| "default".into());
let runtime_plugins = self let runtime_plugins = self
.runtime_plugins .runtime_plugins
...@@ -499,6 +604,7 @@ impl UnnormalizedModuleFederationConfig { ...@@ -499,6 +604,7 @@ impl UnnormalizedModuleFederationConfig {
share_scope: share_scope.clone(), share_scope: share_scope.clone(),
share_strategy: self.share_strategy.unwrap_or_default(), share_strategy: self.share_strategy.unwrap_or_default(),
implementation: self.implementation, implementation: self.implementation,
dts_enabled,
runtime_plugins, runtime_plugins,
..Default::default() ..Default::default()
}; };
...@@ -814,6 +920,20 @@ fn parse_remote_external(external: &str) -> Result<ModuleFederationRemoteExterna ...@@ -814,6 +920,20 @@ fn parse_remote_external(external: &str) -> Result<ModuleFederationRemoteExterna
}) })
} }
fn validate_dts_ts_config_path(path: &str) -> Result<()> {
if path.is_empty()
|| path.starts_with(['/', '\\'])
|| path.contains(['\\', ':', '\0', '?', '#'])
|| path.split('/').any(|part| part.is_empty() || part == "..")
|| path.rsplit('/').next() == Some(".")
{
bail!(
"Module Federation dts.generateTypes.tsConfigPath must be a safe relative project path"
);
}
Ok(())
}
pub fn validate_output_filename(filename: &str) -> Result<()> { pub fn validate_output_filename(filename: &str) -> Result<()> {
if filename.is_empty() if filename.is_empty()
|| filename.starts_with('/') || filename.starts_with('/')
...@@ -989,6 +1109,42 @@ mod tests { ...@@ -989,6 +1109,42 @@ mod tests {
} }
} }
#[test]
fn validates_dts_producer_options() {
for json in [
r#"{"name":"remote","exposes":{"./Widget":"./src/Widget.tsx"},"dts":{"generateTypes":true}}"#,
r#"{"name":"remote","exposes":{"./Widget":"./src/Widget.tsx"},"dts":{"generateTypes":{"tsConfigPath":"./configs/tsconfig.json","abortOnError":false,"extractThirdParty":true,"extractRemoteTypes":false}}}"#,
] {
let config = serde_json::from_str::<UnnormalizedModuleFederationConfig>(json)
.unwrap()
.normalize()
.unwrap();
assert!(config.dts_enabled, "{json}");
}
let disabled =
serde_json::from_str::<UnnormalizedModuleFederationConfig>(r#"{"dts":false}"#)
.unwrap()
.normalize()
.unwrap();
assert!(!disabled.dts_enabled);
for json in [
r#"{"dts":true}"#,
r#"{"dts":{"generateTypes":true}}"#,
r#"{"name":"remote","exposes":{},"dts":{"generateTypes":true}}"#,
r#"{"name":"remote","exposes":{"./A":"./a.ts"},"dts":{"generateTypes":false}}"#,
r#"{"name":"remote","exposes":{"./A":"./a.ts"},"dts":{"consumeTypes":true,"generateTypes":true}}"#,
r#"{"name":"remote","exposes":{"./A":"./a.ts"},"dts":{"generateTypes":{"outputDir":"/tmp"}}}"#,
r#"{"name":"remote","exposes":{"./A":"./a.ts"},"dts":{"generateTypes":{"tsConfigPath":"../secret.json"}}}"#,
r#"{"name":"remote","exposes":{"./A":"./a.ts"},"dts":{"generateTypes":{"tsConfigPath":"/tmp/tsconfig.json"}}}"#,
r#"{"name":"remote","exposes":{"./A":"./a.ts"},"dts":{"generateTypes":{"tsConfigPath":"C:\\secret.json"}}}"#,
] {
let result = serde_json::from_str::<UnnormalizedModuleFederationConfig>(json)
.and_then(|config| config.normalize().map_err(serde::de::Error::custom));
assert!(result.is_err(), "{json}");
}
}
#[test] #[test]
fn validates_output_filenames() { fn validates_output_filenames() {
assert!(validate_output_filename("remoteEntry.js").is_ok()); assert!(validate_output_filename("remoteEntry.js").is_ok());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment