File tree Expand file tree Collapse file tree 3 files changed +5
-4
lines changed
Expand file tree Collapse file tree 3 files changed +5
-4
lines changed Original file line number Diff line number Diff line change 11import { builtinModules } from 'node:module'
22import Debug from 'debug'
3+ import { shimFile } from '../index'
34import { toArray } from '../utils/general'
45import type { ResolvedOptions } from '../options'
56import type { PackageJson } from 'pkg-types'
@@ -13,6 +14,7 @@ export function ExternalPlugin(options: ResolvedOptions): Plugin {
1314 name : 'tsdown:external' ,
1415 async resolveId ( id , importer , extraOptions ) {
1516 if ( extraOptions . isEntry ) return
17+ if ( id === shimFile ) return
1618
1719 const { noExternal } = options
1820 if ( typeof noExternal === 'function' && noExternal ( id , importer ) ) {
Original file line number Diff line number Diff line change 1- import path from 'node:path'
2- import { pkgRoot } from '../index'
1+ import { shimFile } from '../index'
32import type { NormalizedFormat , ResolvedOptions } from '../options'
43
54export function getShimsInject (
65 format : NormalizedFormat ,
76 platform : ResolvedOptions [ 'platform' ] ,
87) : Record < string , [ string , string ] > | undefined {
98 if ( format === 'es' && platform === 'node' ) {
10- const shimFile = path . resolve ( pkgRoot , 'esm-shims.js' )
119 return {
1210 __dirname : [ shimFile , '__dirname' ] ,
1311 __filename : [ shimFile , '__filename' ] ,
Original file line number Diff line number Diff line change @@ -81,7 +81,8 @@ export async function build(userOptions: Options = {}): Promise<void> {
8181}
8282
8383const dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
84- export const pkgRoot : string = path . resolve ( dirname , '..' )
84+ const pkgRoot : string = path . resolve ( dirname , '..' )
85+ export const shimFile : string = path . resolve ( pkgRoot , 'esm-shims.js' )
8586
8687export type TsdownChunks = Partial <
8788 Record < NormalizedFormat , Array < OutputChunk | OutputAsset > >
You can’t perform that action at this time.
0 commit comments