From ea670a1a0ac4bd9e06d7bdba94f12281b54145b2 Mon Sep 17 00:00:00 2001 From: Evan Gillogley Date: Fri, 16 Jun 2023 13:25:45 +0100 Subject: [PATCH] fix(bundling): add skipTypeField back for rollup executor Added back as a workaround for libs that target both ESM and CJS. It will be addressed properly in the future once we use the exports field correctly. --- docs/generated/packages/rollup/executors/rollup.json | 5 +++++ .../rollup/src/executors/rollup/lib/update-package-json.ts | 5 +++-- packages/rollup/src/executors/rollup/schema.d.ts | 1 + packages/rollup/src/executors/rollup/schema.json | 5 +++++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/generated/packages/rollup/executors/rollup.json b/docs/generated/packages/rollup/executors/rollup.json index 35183f237417d..1db6a873ceb85 100644 --- a/docs/generated/packages/rollup/executors/rollup.json +++ b/docs/generated/packages/rollup/executors/rollup.json @@ -169,6 +169,11 @@ "type": "boolean", "description": "Whether to skip TypeScript type checking.", "default": false + }, + "skipTypeField": { + "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 } }, "required": ["tsConfig", "main", "outputPath"], diff --git a/packages/rollup/src/executors/rollup/lib/update-package-json.ts b/packages/rollup/src/executors/rollup/lib/update-package-json.ts index 992749df0d321..79843aa988085 100644 --- a/packages/rollup/src/executors/rollup/lib/update-package-json.ts +++ b/packages/rollup/src/executors/rollup/lib/update-package-json.ts @@ -45,8 +45,9 @@ export function updatePackageJson( packageJson.main = './index.cjs'; exports['.']['require'] = './index.cjs'; } - - packageJson.type = options.format.includes('esm') ? 'module' : 'commonjs'; + if (!options.skipTypeField) { + packageJson.type = options.format.includes('esm') ? 'module' : 'commonjs'; + } // Support for older TS versions < 4.5 packageJson.types = types; diff --git a/packages/rollup/src/executors/rollup/schema.d.ts b/packages/rollup/src/executors/rollup/schema.d.ts index ffef9aa4be9a3..750d186e3abf1 100644 --- a/packages/rollup/src/executors/rollup/schema.d.ts +++ b/packages/rollup/src/executors/rollup/schema.d.ts @@ -33,4 +33,5 @@ export interface RollupExecutorOptions { generateExportsField?: boolean; skipTypeCheck?: boolean; babelUpwardRootMode?: boolean; + skipTypeField?: boolean; } diff --git a/packages/rollup/src/executors/rollup/schema.json b/packages/rollup/src/executors/rollup/schema.json index 6510c4c224152..bbd35b6a81c22 100644 --- a/packages/rollup/src/executors/rollup/schema.json +++ b/packages/rollup/src/executors/rollup/schema.json @@ -156,6 +156,11 @@ "type": "boolean", "description": "Whether to skip TypeScript type checking.", "default": false + }, + "skipTypeField": { + "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 } }, "required": ["tsConfig", "main", "outputPath"],