Skip to content

Commit b349c7e

Browse files
committedJan 23, 2022
--keep-esm-loader option
1 parent a4a5096 commit b349c7e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed
 

‎.changeset/five-scissors-sell.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'bob-tsm': patch
3+
---
4+
5+
Add "--keep-esm-loader" option, it enables to keep the ESM Loader for forks (It can break certain environments like Next.js custom server)

‎packages/bob-tsm/src/bin.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ program
1515
.option('--tsmconfig <config>', 'Configuration file path', 'tsm.js')
1616
.option('--watch <patterns...>', 'Enable & specify watch mode')
1717
.option('--ignore <patterns...>', 'Ignore watch patterns')
18+
.option('--keep-esm-loader', 'Keep ESM Loader for forks (It can break certain environments like Next.js custom server)')
1819
.addOption(
1920
new Option(
2021
'--node-env,--node_env <NODE_ENV>',
@@ -44,9 +45,10 @@ program
4445
node_env: 'production' | 'prod' | 'development' | 'dev' | 'test';
4546
quiet?: boolean;
4647
paths?: boolean;
48+
keepEsmLoader?: boolean;
4749
}>();
4850

49-
const { watch, ignore, cjs, node_env, quiet, tsmconfig, paths } = options;
51+
const { watch, ignore, cjs, node_env, quiet, tsmconfig, paths, keepEsmLoader } = options;
5052

5153
const binDirname = dirname(fileURLToPath(import.meta.url));
5254

@@ -89,6 +91,12 @@ program
8991
});
9092
}
9193

94+
if (keepEsmLoader) {
95+
Object.assign((spawnEnv ||= { ...process.env }), {
96+
KEEP_LOADER_ARGV: '1',
97+
});
98+
}
99+
92100
const spawnOptions: SpawnOptions = {
93101
stdio: 'inherit',
94102
env: spawnEnv,

0 commit comments

Comments
 (0)
Please sign in to comment.