diff --git a/docs/generated/packages/rollup/executors/rollup.json b/docs/generated/packages/rollup/executors/rollup.json index 35183f237417d7..2e0c5501f0f0e2 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": "Prevent type field from being added to package json. Use this if you have an esm library with common js imports.", + "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 992749df0d3213..79843aa988085a 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 ffef9aa4be9a3c..750d186e3abf16 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 6510c4c224152e..acdb038fb9e0c5 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": "Prevent type field from being added to package json. Use this if you have an esm library with common js imports.", + "default": false } }, "required": ["tsConfig", "main", "outputPath"],