@@ -5,6 +5,7 @@ import { dedent } from "../../utils/dedent";
55import type { Plugin } from "esbuild" ;
66import type { NodeJSCompatMode } from "miniflare" ;
77
8+
89/**
910 * An esbuild plugin that will:
1011 * - mark any `node:...` imports as external
@@ -19,11 +20,11 @@ export const nodejsCompatPlugin = (mode: NodeJSCompatMode): Plugin => ({
1920 const seen = new Set < string > ( ) ;
2021
2122 // Prevent multiple warnings per package
22- const warnedPackaged = new Map < string , string [ ] > ( ) ;
23+ const warnedPackages = new Map < string , string [ ] > ( ) ;
2324
2425 pluginBuild . onStart ( ( ) => {
2526 seen . clear ( ) ;
26- warnedPackaged . clear ( ) ;
27+ warnedPackages . clear ( ) ;
2728 } ) ;
2829 pluginBuild . onResolve (
2930 { filter : / n o d e : .* / } ,
@@ -44,9 +45,9 @@ export const nodejsCompatPlugin = (mode: NodeJSCompatMode): Plugin => ({
4445 if ( result . errors . length > 0 ) {
4546 // esbuild couldn't resolve the package
4647 // We should warn the user, but not fail the build
47- const pathWarnedPackaged = warnedPackaged . get ( path ) ?? [ ] ;
48- pathWarnedPackaged . push ( importer ) ;
49- warnedPackaged . set ( path , pathWarnedPackaged ) ;
48+ const pathWarnedPackages = warnedPackages . get ( path ) ?? [ ] ;
49+ pathWarnedPackages . push ( importer ) ;
50+ warnedPackages . set ( path , pathWarnedPackages ) ;
5051
5152 return { external : true } ;
5253 }
@@ -64,10 +65,10 @@ export const nodejsCompatPlugin = (mode: NodeJSCompatMode): Plugin => ({
6465 pluginBuild . onEnd ( ( ) => {
6566 if (
6667 pluginBuild . initialOptions . format === "iife" &&
67- warnedPackaged . size > 0
68+ warnedPackages . size > 0
6869 ) {
6970 const paths = new Intl . ListFormat ( "en-US" ) . format (
70- Array . from ( warnedPackaged . keys ( ) )
71+ Array . from ( warnedPackages . keys ( ) )
7172 . map ( ( p ) => `"${ p } "` )
7273 . sort ( )
7374 ) ;
@@ -91,7 +92,7 @@ export const nodejsCompatPlugin = (mode: NodeJSCompatMode): Plugin => ({
9192 // can be collated
9293 pluginBuild . onEnd ( ( ) => {
9394 if ( mode !== "v1" ) {
94- warnedPackaged . forEach ( ( importers : string [ ] , path : string ) => {
95+ warnedPackages . forEach ( ( importers : string [ ] , path : string ) => {
9596 logger . warn (
9697 dedent `
9798 The package "${ path } " wasn't found on the file system but is built into node.
@@ -108,4 +109,4 @@ function toList(items: string[], absWorkingDir: string | undefined): string {
108109 return items
109110 . map ( ( i ) => ` - ${ chalk . blue ( relative ( absWorkingDir ?? "/" , i ) ) } ` )
110111 . join ( "\n" ) ;
111- }
112+ }
0 commit comments