diff --git a/docs/generated/packages/rollup/executors/rollup.json b/docs/generated/packages/rollup/executors/rollup.json index 60f58625fd..aeb4be2119 100644 --- a/docs/generated/packages/rollup/executors/rollup.json +++ b/docs/generated/packages/rollup/executors/rollup.json @@ -158,7 +158,8 @@ "type": "boolean", "description": "Prevents 'type' field from being added to compiled package.json file. Use this if you are having an issue with this field.", "default": false - } + }, + "sourceMap": { "description": "Output sourcemaps.", "type": "boolean" } }, "required": ["tsConfig", "main", "outputPath"], "definitions": { diff --git a/e2e/rollup/src/rollup.test.ts b/e2e/rollup/src/rollup.test.ts index 02f1d9ada9..9026b03540 100644 --- a/e2e/rollup/src/rollup.test.ts +++ b/e2e/rollup/src/rollup.test.ts @@ -103,7 +103,7 @@ describe('Rollup Plugin', () => { expect(output).toMatch(/Hello/); }, 500000); - it('should support additional entry-points', async () => { + it('should support additional entry-points and sourcemaps', async () => { const myPkg = uniq('my-pkg'); runCLI(`generate @nx/js:lib ${myPkg} --bundler=none`); runCLI( @@ -120,7 +120,8 @@ describe('Rollup Plugin', () => { compiler: 'tsc', generateExportsField: true, additionalEntryPoints: ['./src/{foo,bar}.ts'], - format: ['cjs', 'esm'] + format: ['cjs', 'esm'], + sourceMap: true, }); ` ); @@ -131,12 +132,18 @@ describe('Rollup Plugin', () => { runCLI(`build ${myPkg}`); checkFilesExist(`dist/libs/${myPkg}/index.esm.js`); + checkFilesExist(`dist/libs/${myPkg}/index.esm.js.map`); checkFilesExist(`dist/libs/${myPkg}/index.cjs.js`); + checkFilesExist(`dist/libs/${myPkg}/index.cjs.js.map`); checkFilesExist(`dist/libs/${myPkg}/index.cjs.d.ts`); checkFilesExist(`dist/libs/${myPkg}/foo.esm.js`); + checkFilesExist(`dist/libs/${myPkg}/foo.esm.js.map`); checkFilesExist(`dist/libs/${myPkg}/foo.cjs.js`); + checkFilesExist(`dist/libs/${myPkg}/foo.cjs.js.map`); checkFilesExist(`dist/libs/${myPkg}/bar.esm.js`); + checkFilesExist(`dist/libs/${myPkg}/bar.esm.js.map`); checkFilesExist(`dist/libs/${myPkg}/bar.cjs.js`); + checkFilesExist(`dist/libs/${myPkg}/bar.cjs.js.map`); expect(readJson(`dist/libs/${myPkg}/package.json`).exports).toEqual({ './package.json': './package.json', '.': { diff --git a/packages/rollup/src/executors/rollup/schema.json b/packages/rollup/src/executors/rollup/schema.json index 751c6e78fa..6a155f9438 100644 --- a/packages/rollup/src/executors/rollup/schema.json +++ b/packages/rollup/src/executors/rollup/schema.json @@ -147,6 +147,10 @@ "type": "boolean", "description": "Prevents 'type' field from being added to compiled package.json file. Use this if you are having an issue with this field.", "default": false + }, + "sourceMap": { + "description": "Output sourcemaps.", + "type": "boolean" } }, "required": ["tsConfig", "main", "outputPath"], diff --git a/packages/rollup/src/plugins/with-nx/with-nx-options.ts b/packages/rollup/src/plugins/with-nx/with-nx-options.ts index 9558d569ef..70d76c206e 100644 --- a/packages/rollup/src/plugins/with-nx/with-nx-options.ts +++ b/packages/rollup/src/plugins/with-nx/with-nx-options.ts @@ -68,6 +68,10 @@ export interface RollupWithNxPluginOptions { * Prevents 'type' field from being added to compiled package.json file. Use this if you are having an issue with this field. */ skipTypeField?: boolean; + /** + * Output sourcemaps. + */ + sourceMap?: boolean; /** * The path to tsconfig file. */ diff --git a/packages/rollup/src/plugins/with-nx/with-nx.ts b/packages/rollup/src/plugins/with-nx/with-nx.ts index 7882e23066..3c14757b4a 100644 --- a/packages/rollup/src/plugins/with-nx/with-nx.ts +++ b/packages/rollup/src/plugins/with-nx/with-nx.ts @@ -127,6 +127,7 @@ export function withNx( // Cannot be joined with workspace root now, but will be handled by @nx/rollup/plugin. options.outputPath : join(workspaceRoot, options.outputPath), + sourcemap: options.sourceMap, })); }