diff --git a/packages/js/src/executors/swc/swc.impl.ts b/packages/js/src/executors/swc/swc.impl.ts index 0ca1827d54c69..e5a7e40c8667a 100644 --- a/packages/js/src/executors/swc/swc.impl.ts +++ b/packages/js/src/executors/swc/swc.impl.ts @@ -170,9 +170,6 @@ export async function* swcExecutor( format: [ determineModuleFormatFromSwcrc(options.swcCliOptions.swcrcPath), ], - // As long as d.ts files match their .js counterparts, we don't need to emit them. - // TSC can match them correctly based on file names. - skipTypings: true, }, context ); @@ -192,9 +189,6 @@ export async function* swcExecutor( format: [ determineModuleFormatFromSwcrc(options.swcCliOptions.swcrcPath), ], - // As long as d.ts files match their .js counterparts, we don't need to emit them. - // TSC can match them correctly based on file names. - skipTypings: true, extraDependencies: swcHelperDependency ? [swcHelperDependency] : [], }, context diff --git a/packages/js/src/executors/tsc/tsc.batch-impl.ts b/packages/js/src/executors/tsc/tsc.batch-impl.ts index ae9a13b4a7315..57e39621f5f73 100644 --- a/packages/js/src/executors/tsc/tsc.batch-impl.ts +++ b/packages/js/src/executors/tsc/tsc.batch-impl.ts @@ -96,9 +96,6 @@ export async function* tscBatchExecutor( context.root ), format: [determineModuleFormatFromTsConfig(tsConfig)], - // As long as d.ts files match their .js counterparts, we don't need to emit them. - // TSC can match them correctly based on file names. - skipTypings: true, }, taskInfo.context, taskInfo.projectGraphNode, @@ -144,9 +141,6 @@ export async function* tscBatchExecutor( context.root ), format: [determineModuleFormatFromTsConfig(t.options.tsConfig)], - // As long as d.ts files match their .js counterparts, we don't need to emit them. - // TSC can match them correctly based on file names. - skipTypings: true, }, t.context, t.projectGraphNode, diff --git a/packages/js/src/executors/tsc/tsc.impl.ts b/packages/js/src/executors/tsc/tsc.impl.ts index 88373d7fb0ecb..8e668c8e1db55 100644 --- a/packages/js/src/executors/tsc/tsc.impl.ts +++ b/packages/js/src/executors/tsc/tsc.impl.ts @@ -117,9 +117,6 @@ export async function* tscExecutor( context.root ), format: [determineModuleFormatFromTsConfig(options.tsConfig)], - // As long as d.ts files match their .js counterparts, we don't need to emit them. - // TSC can match them correctly based on file names. - skipTypings: true, }, context, target, @@ -155,9 +152,6 @@ export async function* tscExecutor( options.additionalEntryPoints, context.root ), - // As long as d.ts files match their .js counterparts, we don't need to emit them. - // TSC can match them correctly based on file names. - skipTypings: true, format: [determineModuleFormatFromTsConfig(options.tsConfig)], }, context, diff --git a/packages/rollup/src/plugins/package-json/update-package-json.spec.ts b/packages/rollup/src/plugins/package-json/update-package-json.spec.ts index 8023a9f27038c..c04a83889728c 100644 --- a/packages/rollup/src/plugins/package-json/update-package-json.spec.ts +++ b/packages/rollup/src/plugins/package-json/update-package-json.spec.ts @@ -35,6 +35,7 @@ describe('updatePackageJson', () => { main: './index.esm.js', module: './index.esm.js', type: 'module', + types: './index.esm.d.ts', }); spy.mockRestore(); @@ -59,6 +60,7 @@ describe('updatePackageJson', () => { }, main: './index.cjs.js', type: 'commonjs', + types: './index.cjs.d.ts', }); spy.mockRestore(); @@ -87,6 +89,7 @@ describe('updatePackageJson', () => { }, main: './index.cjs.js', module: './index.esm.js', + types: './index.cjs.d.ts', }); spy.mockRestore(); @@ -118,6 +121,7 @@ describe('updatePackageJson', () => { main: './index.esm.js', module: './index.esm.js', type: 'module', + types: './index.esm.d.ts', }); spy.mockRestore(); @@ -140,6 +144,7 @@ describe('updatePackageJson', () => { main: './index.esm.js', module: './index.esm.js', type: 'module', + types: './index.esm.d.ts', }); spy.mockRestore(); @@ -159,6 +164,7 @@ describe('updatePackageJson', () => { expect(utils.writeJsonFile).toHaveBeenCalledWith(expect.anything(), { main: './index.cjs.js', type: 'commonjs', + types: './index.cjs.d.ts', }); spy.mockRestore(); @@ -178,6 +184,7 @@ describe('updatePackageJson', () => { expect(utils.writeJsonFile).toHaveBeenCalledWith(expect.anything(), { main: './index.cjs.js', module: './index.esm.js', + types: './index.cjs.d.ts', }); spy.mockRestore(); @@ -202,6 +209,7 @@ describe('updatePackageJson', () => { main: './index.esm.js', module: './index.esm.js', type: 'module', + types: './index.esm.d.ts', exports: { './foo': './foo.esm.js', }, @@ -231,6 +239,7 @@ describe('updatePackageJson', () => { expect(utils.writeJsonFile).toHaveBeenCalledWith(expect.anything(), { main: './index.esm.js', module: './index.esm.js', + types: './index.esm.d.ts', exports: { './foo': './foo.esm.js', }, @@ -258,6 +267,7 @@ describe('updatePackageJson', () => { main: './index.esm.js', module: './index.esm.js', type: 'module', + types: './index.esm.d.ts', exports: { './foo': './foo.esm.js', }, @@ -286,6 +296,7 @@ describe('updatePackageJson', () => { main: './index.esm.js', module: './index.esm.js', type: 'module', + types: './index.esm.d.ts', exports: { './foo': './foo.esm.js', }, diff --git a/packages/rollup/src/plugins/package-json/update-package-json.ts b/packages/rollup/src/plugins/package-json/update-package-json.ts index ce10c36a69c6b..aaddad649afe8 100644 --- a/packages/rollup/src/plugins/package-json/update-package-json.ts +++ b/packages/rollup/src/plugins/package-json/update-package-json.ts @@ -102,6 +102,8 @@ export function updatePackageJson( } } + packageJson.types ??= packageJson.main.replace(/\.js$/, '.d.ts'); + writeJsonFile( join(workspaceRoot, options.outputPath, 'package.json'), packageJson