diff --git a/src/builders/build/builder.ts b/src/builders/build/builder.ts index 3d36a629..24b1d353 100644 --- a/src/builders/build/builder.ts +++ b/src/builders/build/builder.ts @@ -69,6 +69,7 @@ import { } from "./i18n.js"; import { updateScriptTags } from "./update-index-html.js"; import { createInternalAngularBuilder } from "./internal-angular-builder.js"; +import { appendFederationLicenses, LICENSES_FILE } from "./federation-licenses.js"; const originalWrite = process.stderr.write.bind(process.stderr); @@ -258,6 +259,16 @@ export async function* runBuilder( const cachePath = resolveCachePath(context.workspaceRoot, nfBuilderOptions.cachePath); + // Angular's 3rdpartylicenses.txt only covers its own bundles, so ours are appended to it. + // A cache hit runs no esbuild and leaves no metafile, so those builds skip the cache. + const extractFederationLicenses = !runViteServer && !!ngBuilderOptions.extractLicenses; + const cacheExternalArtifacts = + nfBuilderOptions.cacheExternalArtifacts !== false && !extractFederationLicenses; + + if (extractFederationLicenses && nfBuilderOptions.cacheExternalArtifacts !== false) { + logger.info("Bundling the shared externals without the cache to extract their licenses."); + } + const normalized = await normalizeFederationOptions( { projectName: nfBuilderOptions.projectName, @@ -275,7 +286,7 @@ export async function* runBuilder( dev: !!nfBuilderOptions.dev, entryPoints, buildNotifications: nfBuilderOptions.buildNotifications, - cacheExternalArtifacts: nfBuilderOptions.cacheExternalArtifacts !== false, + cacheExternalArtifacts, }, createFederationCache(cachePath, new SourceFileCache(cachePath)), ); @@ -727,6 +738,14 @@ export async function* runBuilder( continue; } + if (extractFederationLicenses) { + await appendFederationLicenses( + path.resolve(context.workspaceRoot, outputOptions.base, LICENSES_FILE), + adapter.metafiles(), + context.workspaceRoot, + ); + } + // The initial output's federation artifacts were already built above; only // rebuild on subsequent outputs, and only in watch mode. if (first || !watch) { diff --git a/src/builders/build/federation-licenses.spec.ts b/src/builders/build/federation-licenses.spec.ts new file mode 100644 index 00000000..82cfa17a --- /dev/null +++ b/src/builders/build/federation-licenses.spec.ts @@ -0,0 +1,109 @@ +import * as fs from "fs"; +import * as os from "os"; +import * as path from "path"; +import type { Metafile } from "esbuild"; + +import { appendFederationLicenses, LICENSES_FILE } from "./federation-licenses.js"; +import { + EXTRACTION_FILE_SEPARATOR, + extractLicenses, +} from "../../tools/esbuild/license-extractor.js"; + +let ws: string; +let licensesFile: string; + +function addPackage(name: string, license: string): void { + const dir = path.join(ws, "node_modules", name); + fs.mkdirSync(dir, { recursive: true }); + fs.writeFileSync(path.join(dir, "package.json"), JSON.stringify({ name, version: "1.0.0", license })); + fs.writeFileSync(path.join(dir, "LICENSE"), `${name} license text\n`); + fs.writeFileSync(path.join(dir, "index.js"), ""); +} + +function bundleOf(...packages: string[]): Metafile { + return { + inputs: {}, + outputs: { + "out/bundle.js": { + bytes: 1, + inputs: Object.fromEntries( + packages.map((name) => [`node_modules/${name}/index.js`, { bytesInOutput: 1 }]), + ), + imports: [], + exports: [], + }, + }, + }; +} + +function packagesIn(licenses: string): string[] { + return [...licenses.matchAll(/^Package: (.+)$/gm)].map((match) => match[1]!); +} + +beforeEach(() => { + ws = fs.mkdtempSync(path.join(os.tmpdir(), "nf-federation-licenses-")); + licensesFile = path.join(ws, "dist", LICENSES_FILE); + fs.mkdirSync(path.dirname(licensesFile)); + addPackage("zone.js", "MIT"); + addPackage("rxjs", "Apache-2.0"); + addPackage("@ngrx/store", "MIT"); +}); + +afterEach(() => { + fs.rmSync(ws, { recursive: true, force: true }); +}); + +describe("appendFederationLicenses", () => { + it("appends the packages of the federation bundles after Angular's own entries", async () => { + // What Angular writes for an app build that bundled only zone.js. + const angular = await extractLicenses([bundleOf("zone.js")], ws); + fs.writeFileSync(licensesFile, angular); + + await appendFederationLicenses(licensesFile, [bundleOf("rxjs", "zone.js"), bundleOf("@ngrx/store")], ws); + + const licenses = fs.readFileSync(licensesFile, "utf-8"); + expect(licenses.startsWith(angular)).toBe(true); + expect(packagesIn(licenses)).toEqual(["zone.js", "rxjs", "@ngrx/store"]); + expect(licenses).toContain("rxjs license text\n"); + expect(licenses.endsWith(EXTRACTION_FILE_SEPARATOR)).toBe(true); + }); + + it("matches what Angular writes when it bundles every package itself", async () => { + fs.writeFileSync(licensesFile, await extractLicenses([bundleOf("zone.js")], ws)); + + await appendFederationLicenses(licensesFile, [bundleOf("rxjs", "@ngrx/store")], ws); + + expect(fs.readFileSync(licensesFile, "utf-8")).toBe( + await extractLicenses([bundleOf("zone.js"), bundleOf("rxjs", "@ngrx/store")], ws), + ); + }); + + // A watch rebuild appends to a file Angular may not have rewritten. + it("adds nothing on a second run", async () => { + fs.writeFileSync(licensesFile, await extractLicenses([bundleOf("zone.js")], ws)); + await appendFederationLicenses(licensesFile, [bundleOf("rxjs")], ws); + const once = fs.readFileSync(licensesFile, "utf-8"); + + await appendFederationLicenses(licensesFile, [bundleOf("rxjs")], ws); + + expect(fs.readFileSync(licensesFile, "utf-8")).toBe(once); + }); + + it("leaves the file untouched when Angular already lists every package", async () => { + const angular = await extractLicenses([bundleOf("zone.js", "rxjs")], ws); + fs.writeFileSync(licensesFile, angular); + const writeFile = vi.spyOn(fs.promises, "writeFile"); + + await appendFederationLicenses(licensesFile, [bundleOf("rxjs")], ws); + + expect(writeFile).not.toHaveBeenCalled(); + expect(fs.readFileSync(licensesFile, "utf-8")).toBe(angular); + writeFile.mockRestore(); + }); + + it("writes nothing when Angular wrote no licenses file", async () => { + await appendFederationLicenses(licensesFile, [bundleOf("rxjs")], ws); + + expect(fs.existsSync(licensesFile)).toBe(false); + }); +}); diff --git a/src/builders/build/federation-licenses.ts b/src/builders/build/federation-licenses.ts new file mode 100644 index 00000000..1951ecc6 --- /dev/null +++ b/src/builders/build/federation-licenses.ts @@ -0,0 +1,40 @@ +import * as fs from "fs"; +import type { Metafile } from "esbuild"; + +import { + EXTRACTION_FILE_SEPARATOR, + extractLicenses, +} from "../../tools/esbuild/license-extractor.js"; + +export const LICENSES_FILE = "3rdpartylicenses.txt"; + +export async function appendFederationLicenses( + licensesFile: string, + metafiles: Metafile[], + workspaceRoot: string, +): Promise { + let written: string; + try { + written = await fs.promises.readFile(licensesFile, "utf-8"); + } catch (error) { + if ((error as NodeJS.ErrnoException).code === "ENOENT") return; + throw error; + } + + // Both files come from the same extractor, so a package Angular listed has the same entry. + const listed = new Set(entries(written)); + const missing = entries(await extractLicenses(metafiles, workspaceRoot)).filter( + (entry) => !listed.has(entry), + ); + + if (missing.length > 0) { + await fs.promises.writeFile( + licensesFile, + written + missing.map((entry) => entry + EXTRACTION_FILE_SEPARATOR).join(""), + ); + } +} + +function entries(licenses: string): string[] { + return licenses.split(EXTRACTION_FILE_SEPARATOR).slice(1, -1); +} diff --git a/src/builders/build/schema.json b/src/builders/build/schema.json index 1bc15a8f..de5ef0c8 100644 --- a/src/builders/build/schema.json +++ b/src/builders/build/schema.json @@ -78,7 +78,7 @@ "cacheExternalArtifacts": { "type": "boolean", "default": true, - "description": "Will cache the shared externals so they can be re-used between builds", + "description": "Will cache the shared externals so they can be re-used between builds. Builds that extract licenses (the Angular target's `extractLicenses`, on by default in production) bundle the shared externals without the cache, so 3rdpartylicenses.txt can list their packages.", "alias": "cache" }, "cachePath": { diff --git a/src/tools/esbuild/angular-esbuild-adapter.spec.ts b/src/tools/esbuild/angular-esbuild-adapter.spec.ts index b2acff93..e84c3c16 100644 --- a/src/tools/esbuild/angular-esbuild-adapter.spec.ts +++ b/src/tools/esbuild/angular-esbuild-adapter.spec.ts @@ -202,6 +202,48 @@ describe('createAngularBuildAdapter', () => { ]); }); + // Shared bundles only gained a metafile for 3rdpartylicenses.txt; core keeps matching them by name. + it('does not set entry on shared bundles', async () => { + vi.mocked(normalizeContextOptions).mockReturnValue( + normalizedWith({ isMappingOrExposed: false }) as never + ); + const ctx = makeCtx(); + ctx.rebuild.mockResolvedValue({ outputFiles: [], metafile: { inputs: {}, outputs: {} } }); + vi.mocked(createNodeModulesEsbuildContext).mockResolvedValue({ + ctx, + pluginDisposed: Promise.resolve(), + } as never); + const adapter = await createAngularBuildAdapter(ngBuilderOptions, context); + await adapter.setup('browser-shared', {} as never); + + await adapter.build('browser-shared'); + + expect(entriesByOutputName).toHaveBeenCalledWith(undefined, expect.anything(), '/ws'); + }); + + it('keeps the latest metafile of each bundle, ordered by bundle name', async () => { + const [first, second, rebuilt] = [1, 2, 3].map(n => ({ inputs: {}, outputs: {}, n })); + const ctx = makeCtx(); + ctx.rebuild + .mockResolvedValueOnce({ outputFiles: [], metafile: first }) + .mockResolvedValueOnce({ outputFiles: [], metafile: second }) + .mockResolvedValueOnce({ outputFiles: [], metafile: rebuilt }); + vi.mocked(createAngularEsbuildContext).mockResolvedValue({ + ctx, + pluginDisposed: Promise.resolve(), + } as never); + const adapter = await createAngularBuildAdapter(ngBuilderOptions, context); + await adapter.setup('remote-b', {} as never); + await adapter.setup('remote-a', {} as never); + + await adapter.build('remote-b'); + await adapter.build('remote-a'); + await adapter.build('remote-b'); + await adapter.disposeFederationContexts(); + + expect(adapter.metafiles()).toEqual([second, rebuilt]); + }); + // #181: writing outFile.text decoded binary assets as UTF-8, replacing invalid bytes with U+FFFD. it('writes binary outputs byte for byte', async () => { const png = new Uint8Array([0x89, 0x50, 0x4e, 0x47, 0xff, 0xfe, 0x00, 0x80]); diff --git a/src/tools/esbuild/angular-esbuild-adapter.ts b/src/tools/esbuild/angular-esbuild-adapter.ts index cf9875a9..b0c11a79 100644 --- a/src/tools/esbuild/angular-esbuild-adapter.ts +++ b/src/tools/esbuild/angular-esbuild-adapter.ts @@ -53,6 +53,8 @@ function writeOutputs( export interface AngularBuildAdapter extends NFBuildAdapter { // Disposes every mapping and exposed context, leaving esbuild running for the app build. disposeFederationContexts(): Promise; + // The latest metafile of each bundle built so far, ordered by bundle name. + metafiles(): esbuild.Metafile[]; } export async function createAngularBuildAdapter( @@ -63,6 +65,7 @@ export async function createAngularBuildAdapter( const sharedBundleSettings = await resolveSharedBundleSettings(ngBuilderOptions, context); const externalsCacheKey = createExternalsCacheKey(sharedBundleSettings); const bundleContextCache = new Map(); + const metafilesByBundle = new Map(); const disposeWhere = async ( matches: (entry: EsbuildContextResult, name: string) => boolean @@ -142,9 +145,11 @@ export async function createAngularBuildAdapter( bundleContext.cache.bundlerCache.invalidate(new Set(opts.modifiedFiles)); } const result = await bundleContext.ctx.rebuild(); - // Without `entry`, core matches hashed entries by file name (core#193). + if (result.metafile) metafilesByBundle.set(name, result.metafile); + // Without `entry`, core matches hashed entries by file name (core#193). Shared bundles + // aren't hashed and keep that matching; their metafile is only there for the licenses. const entryByOutputName = entriesByOutputName( - result.metafile, + bundleContext.isMappingOrExposed ? result.metafile : undefined, bundleContext.entryPoints, context.workspaceRoot ); @@ -158,5 +163,8 @@ export async function createAngularBuildAdapter( } }; - return { externalsCacheKey, setup, build, dispose, disposeFederationContexts }; + const metafiles = () => + [...metafilesByBundle.keys()].sort().map(name => metafilesByBundle.get(name)!); + + return { externalsCacheKey, setup, build, dispose, disposeFederationContexts, metafiles }; } diff --git a/src/tools/esbuild/license-extractor.spec.ts b/src/tools/esbuild/license-extractor.spec.ts new file mode 100644 index 00000000..5dc5ea9e --- /dev/null +++ b/src/tools/esbuild/license-extractor.spec.ts @@ -0,0 +1,87 @@ +import * as fs from 'fs'; +import { createRequire } from 'module'; +import * as os from 'os'; +import * as path from 'path'; +import type { Metafile } from 'esbuild'; + +import { EXTRACTION_FILE_SEPARATOR, extractLicenses } from './license-extractor.js'; + +// Angular's original, loaded by absolute file path because the exports map blocks the +// `@angular/build/src/...` specifier (#153). Test-only: used as the reference implementation. +const require = createRequire(import.meta.url); +const angularBuildRoot = path.dirname(require.resolve('@angular/build/package.json')); +const angular = require(path.join(angularBuildRoot, 'src/tools/esbuild/license-extractor.js')) as { + extractLicenses: (metafiles: Metafile[], rootDirectory: string) => Promise; +}; + +let ws: string; + +function write(rel: string, content: string): void { + const file = path.join(ws, rel); + fs.mkdirSync(path.dirname(file), { recursive: true }); + fs.writeFileSync(file, content); +} + +function metafile(inputs: Record): Metafile { + return { + inputs: {}, + outputs: { + 'out/bundle.js': { + bytes: 1, + inputs: Object.fromEntries( + Object.entries(inputs).map(([input, bytesInOutput]) => [input, { bytesInOutput }]) + ), + imports: [], + exports: [], + }, + }, + }; +} + +beforeEach(() => { + ws = fs.mkdtempSync(path.join(os.tmpdir(), 'nf-license-extractor-')); + write('node_modules/mit-pkg/package.json', JSON.stringify({ name: 'mit-pkg', version: '1.0.0', license: 'MIT' })); + write('node_modules/mit-pkg/LICENSE', 'MIT text\n'); + write('node_modules/mit-pkg/index.js', ''); + write( + 'node_modules/@scope/custom/package.json', + JSON.stringify({ name: '@scope/custom', version: '2.0.0', license: 'SEE LICENSE IN terms.txt' }) + ); + write('node_modules/@scope/custom/terms.txt', 'Custom terms\n'); + write('node_modules/@scope/custom/dist/index.js', ''); + write('node_modules/no-file/package.json', JSON.stringify({ name: 'no-file', version: '3.0.0', license: 'ISC' })); + write('node_modules/no-file/index.js', ''); + write('node_modules/shaken/package.json', JSON.stringify({ name: 'shaken', version: '4.0.0', license: 'MIT' })); + write('node_modules/shaken/index.js', ''); +}); + +afterEach(() => { + fs.rmSync(ws, { recursive: true, force: true }); +}); + +describe('extractLicenses', () => { + const metafiles = () => [ + metafile({ + 'src/app.ts': 10, + 'node_modules/mit-pkg/index.js': 10, + 'node_modules/@scope/custom/dist/index.js': 10, + 'node_modules/no-file/index.js': 10, + 'node_modules/shaken/index.js': 0, + }), + metafile({ 'node_modules/mit-pkg/index.js': 5 }), + ]; + + it('produces the same file as @angular/build', async () => { + expect(await extractLicenses(metafiles(), ws)).toBe(await angular.extractLicenses(metafiles(), ws)); + }); + + it('lists each package once, without tree-shaken ones', async () => { + const entries = (await extractLicenses(metafiles(), ws)).split(EXTRACTION_FILE_SEPARATOR); + + expect(entries.map(entry => entry.match(/^Package: (.+)$/m)?.[1]).filter(Boolean)).toEqual([ + 'mit-pkg', + '@scope/custom', + 'no-file', + ]); + }); +}); diff --git a/src/tools/esbuild/license-extractor.ts b/src/tools/esbuild/license-extractor.ts new file mode 100644 index 00000000..f887a256 --- /dev/null +++ b/src/tools/esbuild/license-extractor.ts @@ -0,0 +1,197 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * Use of this source code is governed by an MIT-style license that can be + * found in the LICENSE file at https://angular.dev/license + */ + +// upstream: angular/angular-cli packages/angular/build/src/tools/esbuild/license-extractor.ts @ 11dbe297f8 + +import type { Metafile } from 'esbuild'; +import { readFile, readdir } from 'node:fs/promises'; +import path from 'node:path'; + +/** + * The path segment used to signify that a file is part of a package. + */ +const NODE_MODULE_SEGMENT = 'node_modules'; + +/** + * String constant for the NPM recommended custom license wording. + * + * See: https://docs.npmjs.com/cli/v9/configuring-npm/package-json#license + * + * Example: + * ``` + * { + * "license" : "SEE LICENSE IN " + * } + * ``` + */ +const CUSTOM_LICENSE_TEXT = 'SEE LICENSE IN '; + +/** + * A regular expression for commonly named license files found within packages. + */ +const LICENSE_FILE_REGEXP = /^(?:mit-)?licen[cs]e(?:$|[-._])/i; + +/** + * Header text that will be added to the top of the output license extraction file. + */ +const EXTRACTION_FILE_HEADER = ''; + +/** + * The package entry separator to use within the output license extraction file. + */ +export const EXTRACTION_FILE_SEPARATOR = '-'.repeat(80) + '\n'; + +/** + * Extracts license information for each node module package included in the output + * files of the built code. This includes JavaScript and CSS output files. The esbuild + * metafile generated during the bundling steps is used as the source of information + * regarding what input files where included and where they are located. A path segment + * of `node_modules` is used to indicate that a file belongs to a package and its license + * should be include in the output licenses file. + * + * The package name and license field are extracted from the `package.json` file for the + * package. If a license file (e.g., `LICENSE`) is present in the root of the package, it + * will also be included in the output licenses file. + * + * @param metafile An esbuild metafile object. + * @param rootDirectory The root directory of the workspace. + * @returns A string containing the content of the output licenses file. + */ +export async function extractLicenses( + metafiles: Metafile[], + rootDirectory: string, +): Promise { + let extractedLicenseContent = `${EXTRACTION_FILE_HEADER}\n${EXTRACTION_FILE_SEPARATOR}`; + + const seenPaths = new Set(); + const seenPackageDirectories = new Set(); + const seenPackages = new Set(); + + for (const metafile of metafiles) { + for (const entry of Object.values(metafile.outputs)) { + for (const [inputPath, { bytesInOutput }] of Object.entries(entry.inputs)) { + // Skip if not included in output + if (bytesInOutput <= 0) { + continue; + } + + // Skip already processed paths + if (seenPaths.has(inputPath)) { + continue; + } + seenPaths.add(inputPath); + + // Skip non-package paths + if (!inputPath.includes(NODE_MODULE_SEGMENT)) { + continue; + } + + // Extract the package name from the path + let baseDirectory = path.join(rootDirectory, inputPath); + let nameOrScope, nameOrFile; + let found = false; + while (baseDirectory !== path.dirname(baseDirectory)) { + const segment = path.basename(baseDirectory); + if (segment === NODE_MODULE_SEGMENT) { + found = true; + break; + } + + nameOrFile = nameOrScope; + nameOrScope = segment; + baseDirectory = path.dirname(baseDirectory); + } + + // Skip non-package path edge cases that are not caught in the includes check above + if (!found || !nameOrScope) { + continue; + } + + const packageName = nameOrScope.startsWith('@') + ? `${nameOrScope}/${nameOrFile}` + : nameOrScope; + const packageDirectory = path.join(baseDirectory, packageName); + + if (seenPackageDirectories.has(packageDirectory)) { + continue; + } + seenPackageDirectories.add(packageDirectory); + + // Load the package's metadata to find the package's name, version, and license type + const packageJsonPath = path.join(packageDirectory, 'package.json'); + let packageJson; + try { + packageJson = JSON.parse(await readFile(packageJsonPath, 'utf-8')) as { + name: string; + version: string; + // The object form is deprecated and should only be present in old packages + license?: string | { type: string }; + }; + } catch { + // Invalid package + continue; + } + + // Skip already processed packages + const packageId = `${packageName}@${packageJson.version}`; + if (seenPackages.has(packageId)) { + continue; + } + seenPackages.add(packageId); + + // Attempt to find license text inside package + let licenseText = ''; + if ( + typeof packageJson.license === 'string' && + packageJson.license.toUpperCase().startsWith(CUSTOM_LICENSE_TEXT) + ) { + // Attempt to load the package's custom license + let customLicensePath; + const customLicenseFile = path.normalize( + packageJson.license.slice(CUSTOM_LICENSE_TEXT.length).trim(), + ); + if (customLicenseFile.startsWith('..') || path.isAbsolute(customLicenseFile)) { + // Path is attempting to access files outside of the package + // TODO: Issue warning? + } else { + customLicensePath = path.join(packageDirectory, customLicenseFile); + try { + licenseText = await readFile(customLicensePath, 'utf-8'); + // eslint-disable-next-line no-empty + } catch {} + } + } else { + // Search for a license file within the root of the package + const entries = await readdir(packageDirectory, { withFileTypes: true }).catch(() => []); + + for (const entry of entries) { + if ( + (entry.isFile() || entry.isSymbolicLink()) && + LICENSE_FILE_REGEXP.test(entry.name) + ) { + const packageLicensePath = path.join(packageDirectory, entry.name); + try { + licenseText = await readFile(packageLicensePath, 'utf-8'); + break; + // eslint-disable-next-line no-empty + } catch {} + } + } + } + + // Generate the package's license entry in the output content + extractedLicenseContent += `Package: ${packageJson.name}\n`; + extractedLicenseContent += `License: ${JSON.stringify(packageJson.license, null, 2)}\n`; + extractedLicenseContent += `\n${licenseText}\n`; + extractedLicenseContent += EXTRACTION_FILE_SEPARATOR; + } + } + } + + return extractedLicenseContent; +} diff --git a/src/tools/esbuild/node-modules-bundler.spec.ts b/src/tools/esbuild/node-modules-bundler.spec.ts index 47097af9..080d121d 100644 --- a/src/tools/esbuild/node-modules-bundler.spec.ts +++ b/src/tools/esbuild/node-modules-bundler.spec.ts @@ -375,4 +375,35 @@ describe('createNodeModulesEsbuildContext script options', () => { expect(text).toContain('default-build'); }); + + // The builder appends these packages to Angular's 3rdpartylicenses.txt. + it('reports the package files it bundled in a metafile', async () => { + const { ctx } = await createNodeModulesEsbuildContext( + { + context: { workspaceRoot: fixtureDir }, + entryPoints: [{ fileName: path.join(fixtureDir, 'entry.js'), outName: 'entry.js' }], + external: [], + outdir: path.join(fixtureDir, 'out'), + cache: { cachePath: path.join(fixtureDir, 'cache') }, + dev: false, + hash: false, + chunks: false, + } as never, + { target: ['es2022'], sourcemap: false, plugins: [], script: prodScript } + ); + + try { + const { metafile } = await ctx.rebuild(); + const inputs = Object.values(metafile!.outputs).flatMap(output => + Object.entries(output.inputs) + .filter(([, { bytesInOutput }]) => bytesInOutput > 0) + .map(([input]) => input.split(path.sep).join('/')) + ); + + expect(inputs).toContain('node_modules/cond-pkg/prod.js'); + expect(inputs).not.toContain('node_modules/cond-pkg/dev.js'); + } finally { + await ctx.dispose(); + } + }); }); diff --git a/src/tools/esbuild/node-modules-bundler.ts b/src/tools/esbuild/node-modules-bundler.ts index b03c6551..cad667cb 100644 --- a/src/tools/esbuild/node-modules-bundler.ts +++ b/src/tools/esbuild/node-modules-bundler.ts @@ -143,6 +143,7 @@ export async function createNodeModulesEsbuildContext( absWorkingDir: workspaceRoot, entryNames: hash ? "[name]-[hash]" : "[name]", write: false, + metafile: true, external, logLevel: "warning", bundle: true,