feat(bundling): use tsconfig.lib.json for rollup.config.ts (#30453)
## Current Behavior Currently when we're using `rollup.config.ts` rollup is picking up wrong tsconfig. Because of this not everything works as expected: - `You are using one of Typescript's compiler options 'declaration', 'declarationMap' or 'composite'. In this case 'outDir' or 'declarationDir' must be specified to generate declaration files.` error appears , because lib tsconfig.json doesn't have outputDir at all - even if we add outDir to `tsconfig.base.json` we'll have another error `[!] (plugin typescript) RollupError: [plugin typescript] @rollup/plugin-typescript TS6377: Cannot write file '/workspaces/abapify-docs/dist/tsconfig.tsbuildinfo' because it will overwrite '.tsbuildinfo' file generated by referenced project '/workspaces/abapify-docs/packages/abap-to-markdown'` This happens becase it tries to write all tsbuildinfo files into a root dist folder. ## Expected Behavior Using rollup.config.ts should just work in a similar way as js|cjs|mjs config work. ## Solution According to docs: > This option supports the same syntax as the [--plugin](https://rollupjs.org/command-line-interface/#p-plugin-plugin-plugin) option i.e., you can specify the option multiple times, you can omit the @rollup/plugin- prefix and just write typescript and you can specify plugin options via ={...}. So it means we can use something like this: ``` rollup -c rollup.config.ts --configPlugin typescript={tsconfig:\'tsconfig.lib.json\'} ``` ## Related Issue(s) Solution is taken from this issue:: https://github.com/rollup/plugins/issues/1713#issuecomment-2201138846
This commit is contained in:
parent
73e2c506bb
commit
ddaf77b109
@ -1,6 +1,7 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`@nx/rollup/plugin non-root project should create nodes 1`] = `
|
||||
exports[`@nx/rollup/plugin non-root project should create nodes 1`
|
||||
] = `
|
||||
[
|
||||
[
|
||||
"mylib/rollup.config.cjs",
|
||||
@ -67,7 +68,8 @@ exports[`@nx/rollup/plugin non-root project should create nodes 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`@nx/rollup/plugin non-root project should create nodes 2`] = `
|
||||
exports[`@nx/rollup/plugin non-root project should create nodes 2`
|
||||
] = `
|
||||
[
|
||||
[
|
||||
"mylib/rollup.config.cts",
|
||||
@ -78,7 +80,7 @@ exports[`@nx/rollup/plugin non-root project should create nodes 2`] = `
|
||||
"targets": {
|
||||
"build": {
|
||||
"cache": true,
|
||||
"command": "rollup -c rollup.config.cts --configPlugin @rollup/plugin-typescript",
|
||||
"command": "rollup -c rollup.config.cts --configPlugin typescript={tsconfig:\\'tsconfig.lib.json\\'}",
|
||||
"dependsOn": [
|
||||
"^build",
|
||||
],
|
||||
@ -134,7 +136,8 @@ exports[`@nx/rollup/plugin non-root project should create nodes 2`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`@nx/rollup/plugin root project should create nodes 1`] = `
|
||||
exports[`@nx/rollup/plugin root project should create nodes 1`
|
||||
] = `
|
||||
[
|
||||
[
|
||||
"rollup.config.cjs",
|
||||
@ -200,7 +203,8 @@ exports[`@nx/rollup/plugin root project should create nodes 1`] = `
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`@nx/rollup/plugin root project should create nodes 2`] = `
|
||||
exports[`@nx/rollup/plugin root project should create nodes 2`
|
||||
] = `
|
||||
[
|
||||
[
|
||||
"rollup.config.cts",
|
||||
@ -211,7 +215,7 @@ exports[`@nx/rollup/plugin root project should create nodes 2`] = `
|
||||
"targets": {
|
||||
"build": {
|
||||
"cache": true,
|
||||
"command": "rollup -c rollup.config.cts --configPlugin @rollup/plugin-typescript",
|
||||
"command": "rollup -c rollup.config.cts --configPlugin typescript={tsconfig:\\'tsconfig.lib.json\\'}",
|
||||
"dependsOn": [
|
||||
"^build",
|
||||
],
|
||||
|
||||
@ -188,7 +188,9 @@ async function buildRollupTarget(
|
||||
const targets: Record<string, TargetConfiguration> = {};
|
||||
targets[options.buildTargetName] = {
|
||||
command: `rollup -c ${basename(configFilePath)}${
|
||||
isTsConfig ? ` --configPlugin ${tsConfigPlugin}` : ''
|
||||
isTsConfig
|
||||
? ` --configPlugin typescript={tsconfig:\\'tsconfig.lib.json\\'}`
|
||||
: ''
|
||||
}`,
|
||||
options: { cwd: projectRoot },
|
||||
cache: true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user