File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -72,13 +72,13 @@ export const getPkgConfig = (
72
72
dynamicImportVars ( {
73
73
warnOnError : true ,
74
74
} ) ,
75
+ esmInjectCreateRequire ( ) ,
75
76
...(
76
77
options . minify
77
78
? [ esbuildMinify ( esbuildConfig ) ]
78
79
: [ ]
79
80
) ,
80
81
patchBinary ( executablePaths ) ,
81
- esmInjectCreateRequire ( ) ,
82
82
] ,
83
83
output : [ ] as unknown as Output ,
84
84
external : [ ] as ( string | RegExp ) [ ] ,
Original file line number Diff line number Diff line change @@ -59,5 +59,25 @@ export default testSuite(({ describe }, nodePath: string) => {
59
59
expect ( await fixture . exists ( 'dist/index.mjs' ) ) . toBe ( true ) ;
60
60
expect ( await fixture . exists ( 'dist/index.js' ) ) . toBe ( true ) ;
61
61
} ) ;
62
+
63
+ test ( 'hashbang gets inserted at the top (despite other injections e.g. createRequire)' , async ( ) => {
64
+ await using fixture = await createFixture ( {
65
+ 'src/dynamic-require.ts' : 'require((() => \'fs\')());' ,
66
+ 'package.json' : createPackageJson ( {
67
+ bin : './dist/dynamic-require.mjs' ,
68
+ } ) ,
69
+ } ) ;
70
+
71
+ const pkgrollProcess = await pkgroll ( [ ] , {
72
+ cwd : fixture . path ,
73
+ nodePath,
74
+ } ) ;
75
+
76
+ expect ( pkgrollProcess . exitCode ) . toBe ( 0 ) ;
77
+ expect ( pkgrollProcess . stderr ) . toBe ( '' ) ;
78
+
79
+ const content = await fixture . readFile ( 'dist/dynamic-require.mjs' , 'utf8' ) ;
80
+ expect ( content . startsWith ( '#!/usr/bin/env node' ) ) . toBeTruthy ( ) ;
81
+ } ) ;
62
82
} ) ;
63
83
} ) ;
You can’t perform that action at this time.
0 commit comments