@@ -162,8 +162,7 @@ export function esbuildDepPlugin(
162162 const flatId = flattenId ( id )
163163 if ( flatId in qualified ) {
164164 return {
165- path : flatId ,
166- namespace : 'dep'
165+ path : qualified [ flatId ]
167166 }
168167 }
169168 }
@@ -179,7 +178,7 @@ export function esbuildDepPlugin(
179178 }
180179
181180 // ensure esbuild uses our resolved entries
182- let entry : { path : string ; namespace : string } | undefined
181+ let entry : { path : string } | undefined
183182 // if this is an entry, return entry namespace resolve result
184183 if ( ! importer ) {
185184 if ( ( entry = resolveEntry ( id ) ) ) return entry
@@ -198,48 +197,6 @@ export function esbuildDepPlugin(
198197 }
199198 )
200199
201- // For entry files, we'll read it ourselves and construct a proxy module
202- // to retain the entry's raw id instead of file path so that esbuild
203- // outputs desired output file structure.
204- // It is necessary to do the re-exporting to separate the virtual proxy
205- // module from the actual module since the actual module may get
206- // referenced via relative imports - if we don't separate the proxy and
207- // the actual module, esbuild will create duplicated copies of the same
208- // module!
209- const root = path . resolve ( config . root )
210- build . onLoad ( { filter : / .* / , namespace : 'dep' } , ( { path : id } ) => {
211- const entryFile = qualified [ id ]
212-
213- let relativePath = normalizePath ( path . relative ( root , entryFile ) )
214- if (
215- ! relativePath . startsWith ( './' ) &&
216- ! relativePath . startsWith ( '../' ) &&
217- relativePath !== '.'
218- ) {
219- relativePath = `./${ relativePath } `
220- }
221-
222- let contents = ''
223- const { hasImports, exports, hasReExports } = exportsData [ id ]
224- if ( ! hasImports && ! exports . length ) {
225- // cjs
226- contents += `export default require("${ relativePath } ");`
227- } else {
228- if ( exports . includes ( 'default' ) ) {
229- contents += `import d from "${ relativePath } ";export default d;`
230- }
231- if ( hasReExports || exports . length > 1 || exports [ 0 ] !== 'default' ) {
232- contents += `\nexport * from "${ relativePath } "`
233- }
234- }
235-
236- return {
237- loader : 'js' ,
238- contents,
239- resolveDir : root
240- }
241- } )
242-
243200 build . onLoad (
244201 { filter : / .* / , namespace : 'browser-external' } ,
245202 ( { path } ) => {
0 commit comments