Skip to content

Commit 7d9352e

Browse files
authoredMar 20, 2023
fix(bundling): respect --sourcemap option for esbuild (#15778)
1 parent d1ddd52 commit 7d9352e

File tree

5 files changed

+49
-2
lines changed

5 files changed

+49
-2
lines changed
 

‎docs/generated/packages/esbuild/executors/esbuild.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,13 @@
114114
"default": false
115115
},
116116
"sourcemap": {
117-
"type": "boolean",
117+
"oneOf": [
118+
{
119+
"type": "string",
120+
"enum": ["linked", "inline", "external", "both"]
121+
},
122+
{ "type": "boolean" }
123+
],
118124
"alias": "sourceMap",
119125
"description": "Generate sourcemap.",
120126
"default": false

‎packages/esbuild/src/executors/esbuild/lib/build-esbuild-options.spec.ts

+35
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,39 @@ describe('buildEsbuildOptions', () => {
356356
},
357357
});
358358
});
359+
360+
it('should set sourcemap', () => {
361+
expect(
362+
buildEsbuildOptions(
363+
'esm',
364+
{
365+
bundle: false,
366+
platform: 'node',
367+
main: 'apps/myapp/src/index.ts',
368+
outputPath: 'dist/apps/myapp',
369+
tsConfig: 'apps/myapp/tsconfig.app.json',
370+
project: 'apps/myapp/package.json',
371+
outputFileName: 'index.js',
372+
assets: [],
373+
singleEntry: true,
374+
sourcemap: true,
375+
external: [],
376+
},
377+
context
378+
)
379+
).toEqual({
380+
bundle: false,
381+
entryNames: '[dir]/[name]',
382+
entryPoints: ['apps/myapp/src/index.ts'],
383+
format: 'esm',
384+
platform: 'node',
385+
outdir: 'dist/apps/myapp',
386+
tsconfig: 'apps/myapp/tsconfig.app.json',
387+
external: undefined,
388+
sourcemap: true,
389+
outExtension: {
390+
'.js': '.js',
391+
},
392+
});
393+
});
359394
});

‎packages/esbuild/src/executors/esbuild/lib/build-esbuild-options.ts

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function buildEsbuildOptions(
3939
target: options.target,
4040
metafile: options.metafile,
4141
tsconfig: options.tsConfig,
42+
sourcemap: options.sourcemap,
4243
format,
4344
outExtension: {
4445
'.js': outExtension,

‎packages/esbuild/src/executors/esbuild/schema.d.ts

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface EsBuildExecutorOptions {
1212
esbuildOptions?: Record<string, any>;
1313
external?: string[];
1414
format?: Array<'esm' | 'cjs'>;
15+
generatePackageJson?: boolean;
1516
main: string;
1617
metafile?: boolean;
1718
minify?: boolean;
@@ -20,6 +21,7 @@ export interface EsBuildExecutorOptions {
2021
outputPath: string;
2122
platform?: 'node' | 'browser' | 'neutral';
2223
project: string;
24+
sourcemap?: boolean | 'linked' | 'inline' | 'external' | 'both';
2325
skipTypeCheck?: boolean;
2426
target?: string;
2527
thirdParty?: boolean;

‎packages/esbuild/src/executors/esbuild/schema.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@
9292
"default": false
9393
},
9494
"sourcemap": {
95-
"type": "boolean",
95+
"oneOf": [
96+
{ "type": "string", "enum": ["linked", "inline", "external", "both"] },
97+
{ "type": "boolean" }
98+
],
9699
"alias": "sourceMap",
97100
"description": "Generate sourcemap.",
98101
"default": false

1 commit comments

Comments
 (1)

vercel[bot] commented on Mar 20, 2023

@vercel[bot]

Successfully deployed to the following URLs:

nx-dev – ./

nx.dev
nx-dev-git-master-nrwl.vercel.app
nx-five.vercel.app
nx-dev-nrwl.vercel.app

Please sign in to comment.