feat(bundling): add option to generate sourcemaps for Rollup build (#27539)
This PR adds `sourceMap` option to `@nx/rollup:rollup` executor and the `withNx` util (for Project Crystal). The same option is used for Webpack. ## Current Behavior <!-- This is the behavior we have today --> ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #9199
This commit is contained in:
parent
27982fbbe8
commit
fdb488b394
@ -158,7 +158,8 @@
|
|||||||
"type": "boolean",
|
"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.",
|
"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
|
"default": false
|
||||||
}
|
},
|
||||||
|
"sourceMap": { "description": "Output sourcemaps.", "type": "boolean" }
|
||||||
},
|
},
|
||||||
"required": ["tsConfig", "main", "outputPath"],
|
"required": ["tsConfig", "main", "outputPath"],
|
||||||
"definitions": {
|
"definitions": {
|
||||||
|
|||||||
@ -103,7 +103,7 @@ describe('Rollup Plugin', () => {
|
|||||||
expect(output).toMatch(/Hello/);
|
expect(output).toMatch(/Hello/);
|
||||||
}, 500000);
|
}, 500000);
|
||||||
|
|
||||||
it('should support additional entry-points', async () => {
|
it('should support additional entry-points and sourcemaps', async () => {
|
||||||
const myPkg = uniq('my-pkg');
|
const myPkg = uniq('my-pkg');
|
||||||
runCLI(`generate @nx/js:lib ${myPkg} --bundler=none`);
|
runCLI(`generate @nx/js:lib ${myPkg} --bundler=none`);
|
||||||
runCLI(
|
runCLI(
|
||||||
@ -120,7 +120,8 @@ describe('Rollup Plugin', () => {
|
|||||||
compiler: 'tsc',
|
compiler: 'tsc',
|
||||||
generateExportsField: true,
|
generateExportsField: true,
|
||||||
additionalEntryPoints: ['./src/{foo,bar}.ts'],
|
additionalEntryPoints: ['./src/{foo,bar}.ts'],
|
||||||
format: ['cjs', 'esm']
|
format: ['cjs', 'esm'],
|
||||||
|
sourceMap: true,
|
||||||
});
|
});
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
@ -131,12 +132,18 @@ describe('Rollup Plugin', () => {
|
|||||||
runCLI(`build ${myPkg}`);
|
runCLI(`build ${myPkg}`);
|
||||||
|
|
||||||
checkFilesExist(`dist/libs/${myPkg}/index.esm.js`);
|
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`);
|
||||||
|
checkFilesExist(`dist/libs/${myPkg}/index.cjs.js.map`);
|
||||||
checkFilesExist(`dist/libs/${myPkg}/index.cjs.d.ts`);
|
checkFilesExist(`dist/libs/${myPkg}/index.cjs.d.ts`);
|
||||||
checkFilesExist(`dist/libs/${myPkg}/foo.esm.js`);
|
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`);
|
||||||
|
checkFilesExist(`dist/libs/${myPkg}/foo.cjs.js.map`);
|
||||||
checkFilesExist(`dist/libs/${myPkg}/bar.esm.js`);
|
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`);
|
||||||
|
checkFilesExist(`dist/libs/${myPkg}/bar.cjs.js.map`);
|
||||||
expect(readJson(`dist/libs/${myPkg}/package.json`).exports).toEqual({
|
expect(readJson(`dist/libs/${myPkg}/package.json`).exports).toEqual({
|
||||||
'./package.json': './package.json',
|
'./package.json': './package.json',
|
||||||
'.': {
|
'.': {
|
||||||
|
|||||||
@ -147,6 +147,10 @@
|
|||||||
"type": "boolean",
|
"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.",
|
"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
|
"default": false
|
||||||
|
},
|
||||||
|
"sourceMap": {
|
||||||
|
"description": "Output sourcemaps.",
|
||||||
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"required": ["tsConfig", "main", "outputPath"],
|
"required": ["tsConfig", "main", "outputPath"],
|
||||||
|
|||||||
@ -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.
|
* Prevents 'type' field from being added to compiled package.json file. Use this if you are having an issue with this field.
|
||||||
*/
|
*/
|
||||||
skipTypeField?: boolean;
|
skipTypeField?: boolean;
|
||||||
|
/**
|
||||||
|
* Output sourcemaps.
|
||||||
|
*/
|
||||||
|
sourceMap?: boolean;
|
||||||
/**
|
/**
|
||||||
* The path to tsconfig file.
|
* The path to tsconfig file.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -127,6 +127,7 @@ export function withNx(
|
|||||||
// Cannot be joined with workspace root now, but will be handled by @nx/rollup/plugin.
|
// Cannot be joined with workspace root now, but will be handled by @nx/rollup/plugin.
|
||||||
options.outputPath
|
options.outputPath
|
||||||
: join(workspaceRoot, options.outputPath),
|
: join(workspaceRoot, options.outputPath),
|
||||||
|
sourcemap: options.sourceMap,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user