Skip to content

Commit f964c44

Browse files
committed
node16 fixes
1 parent 9b14535 commit f964c44

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

src/commands/build.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ const filesToExcludeFromDist = [
4141
'**/temp',
4242
];
4343

44+
function compilerOptionsToArgs(options: Record<string, unknown>): string[] {
45+
return Object.entries(options)
46+
.filter(([, value]) => !!value)
47+
.flatMap(([key, value]) => [`--${key}`, `${value}`]);
48+
}
49+
4450
function assertTypeScriptBuildResult(
4551
result: Awaited<ReturnType<typeof execa>>,
4652
reporter: ConsolaInstance,
@@ -65,13 +71,14 @@ async function buildTypeScript(
6571
assertTypeScriptBuildResult(
6672
await execa('npx', [
6773
'tsc',
68-
...(tsconfig ? ['--project', tsconfig] : []),
69-
'--module node16', // not nodenext because this keeps up with latest node and we dont want to break something suddenly
70-
'--sourceMap false',
71-
'--inlineSourceMap false',
72-
...(options.incremental ? ['--incremental'] : []),
73-
'--outDir',
74-
outDir,
74+
...compilerOptionsToArgs({
75+
project: tsconfig,
76+
module: 'node16',
77+
sourceMap: false,
78+
inlineSourceMap: false,
79+
incremental: options.incremental,
80+
outDir,
81+
}),
7582
]),
7683
reporter,
7784
);

test/integration.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ it('can bundle a simple project', async () => {
3333
export default _default;
3434
`);
3535
expect(await fse.readFile(indexMjsFilePath, 'utf8')).toMatchInlineSnapshot(`
36-
export var someNumber = 1;
36+
export const someNumber = 1;
3737
export default 'kek';
3838
`);
3939
expect(await fse.readFile(readmeFilePath, 'utf8')).toMatchInlineSnapshot('Hello!');
@@ -355,7 +355,7 @@ it('can build an esm only project', async () => {
355355
`);
356356

357357
expect(await fse.readFile(indexJsFilePath, 'utf8')).toMatchInlineSnapshot(
358-
'export var someNumber = 1;',
358+
`export const someNumber = 1;`,
359359
);
360360
expect(await fse.readFile(indexDtsFilePath, 'utf8')).toMatchInlineSnapshot(
361361
'export declare const someNumber = 1;',
@@ -732,7 +732,7 @@ it('can bundle a tsconfig-build-json project', async () => {
732732
`);
733733
await expect(fse.readFile(path.resolve(baseDistPath, 'esm', 'index.js'), 'utf8')).resolves
734734
.toMatchInlineSnapshot(`
735-
export var hello = 1;
735+
export const hello = 1;
736736
export default 'there';
737737
`);
738738

@@ -776,7 +776,7 @@ it('can bundle a simple project with additional exports', async () => {
776776
`);
777777
await expect(fse.readFile(path.join(dist, 'esm', 'index.js'), 'utf8')).resolves
778778
.toMatchInlineSnapshot(`
779-
export var someLetter = 'a';
779+
export const someLetter = 'a';
780780
export default { b: 'c' };
781781
`);
782782

@@ -798,7 +798,7 @@ it('can bundle a simple project with additional exports', async () => {
798798
`);
799799
await expect(fse.readFile(path.join(dist, 'esm', 'sub', 'index.js'), 'utf8')).resolves
800800
.toMatchInlineSnapshot(`
801-
export var someOtherLetter = 'd';
801+
export const someOtherLetter = 'd';
802802
export default { e: 'f' };
803803
`);
804804

0 commit comments

Comments
 (0)