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 1
1
import { builtinModules } from 'node:module'
2
2
import Debug from 'debug'
3
+ import { shimFile } from '../index'
3
4
import { toArray } from '../utils/general'
4
5
import type { ResolvedOptions } from '../options'
5
6
import type { PackageJson } from 'pkg-types'
@@ -13,6 +14,7 @@ export function ExternalPlugin(options: ResolvedOptions): Plugin {
13
14
name : 'tsdown:external' ,
14
15
async resolveId ( id , importer , extraOptions ) {
15
16
if ( extraOptions . isEntry ) return
17
+ if ( id === shimFile ) return
16
18
17
19
const { noExternal } = options
18
20
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'
3
2
import type { NormalizedFormat , ResolvedOptions } from '../options'
4
3
5
4
export function getShimsInject (
6
5
format : NormalizedFormat ,
7
6
platform : ResolvedOptions [ 'platform' ] ,
8
7
) : Record < string , [ string , string ] > | undefined {
9
8
if ( format === 'es' && platform === 'node' ) {
10
- const shimFile = path . resolve ( pkgRoot , 'esm-shims.js' )
11
9
return {
12
10
__dirname : [ shimFile , '__dirname' ] ,
13
11
__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> {
81
81
}
82
82
83
83
const 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' )
85
86
86
87
export type TsdownChunks = Partial <
87
88
Record < NormalizedFormat , Array < OutputChunk | OutputAsset > >
You can’t perform that action at this time.
0 commit comments