diff --git a/packages/typescript/package.json b/packages/typescript/package.json index 8d9a3b676..a389d5a21 100644 --- a/packages/typescript/package.json +++ b/packages/typescript/package.json @@ -61,7 +61,7 @@ "@types/node": "^10.0.0", "buble": "^0.20.0", "rollup": "^2.14.0", - "typescript": "^4.1.2" + "typescript": "^4.2.2" }, "types": "types/index.d.ts" } diff --git a/packages/typescript/src/preflight.ts b/packages/typescript/src/preflight.ts index 39cc1731c..3b7e70e2d 100644 --- a/packages/typescript/src/preflight.ts +++ b/packages/typescript/src/preflight.ts @@ -17,8 +17,6 @@ ${pluginName}: Rollup requires that TypeScript produces ES Modules. Unfortunatel "module" other than "esnext". Unless you know what you're doing, please change "module" to "esnext" in the target tsconfig.json file or plugin options.`.replace(/\n/g, ''); -const rootDirErrorMessage = `${pluginName}: The "rootDir" or "rootDirs" option is required when the "tsconfig" option is not specified and "declaration" is "true".`; - const tsLibErrorMessage = `${pluginName}: Could not find module 'tslib', which is required by this plugin. Is it installed?`; let undef; @@ -30,11 +28,6 @@ export const preflight = ({ config, context, rollupOptions, tslib }: PreflightOp context.warn(moduleErrorMessage); } - const { options } = config; - if (options.declaration && !options.configFilePath && !options.rootDir && !options.rootDirs) { - context.error(rootDirErrorMessage); - } - if (!rollupOptions.preserveModules && tslib === null) { context.error(tsLibErrorMessage); } diff --git a/packages/typescript/test/snapshots/tsconfig.ts.md b/packages/typescript/test/snapshots/tsconfig.ts.md deleted file mode 100644 index cd5733ae1..000000000 --- a/packages/typescript/test/snapshots/tsconfig.ts.md +++ /dev/null @@ -1,25 +0,0 @@ -# Snapshot report for `test/tsconfig.ts` - -The actual snapshot is saved in `tsconfig.ts.snap`. - -Generated by [AVA](https://avajs.dev). - -## inline config without tsconfig + rootDir - -> Snapshot 1 - - [ - 'main.js', - 'types/main.d.ts', - ] - -## inline config without tsconfig without rootDir fails - -> Snapshot 1 - - Error { - code: 'PLUGIN_ERROR', - hook: 'buildStart', - plugin: 'typescript', - message: '@rollup/plugin-typescript: The "rootDir" or "rootDirs" option is required when the "tsconfig" option is not specified and "declaration" is "true".', - } diff --git a/packages/typescript/test/snapshots/tsconfig.ts.snap b/packages/typescript/test/snapshots/tsconfig.ts.snap deleted file mode 100644 index ecf6b0f74..000000000 Binary files a/packages/typescript/test/snapshots/tsconfig.ts.snap and /dev/null differ diff --git a/packages/typescript/test/test.js b/packages/typescript/test/test.js index 55bfb158e..47cf62734 100644 --- a/packages/typescript/test/test.js +++ b/packages/typescript/test/test.js @@ -1020,11 +1020,7 @@ test.serial('picks up on newly included typescript files in watch mode', async ( t.true(usage, 'should contain usage'); }); -// TODO: upgrade TypeScript when there is a release containing the fix for this issue -// https://github.com/microsoft/TypeScript/pull/41811. Then enable this test -// More details at https://github.com/rollup/plugins/issues/287. This fails with the message: -// Unexpected token (Note that you need plugins to import files that are not JavaScript) -test.serial.skip('works when code is in src directory', async (t) => { +test.serial('works when code is in src directory', async (t) => { const bundle = await rollup({ input: 'fixtures/src-dir/src/index.ts', output: [ diff --git a/packages/typescript/test/tsconfig.ts b/packages/typescript/test/tsconfig.ts deleted file mode 100644 index 567e9d9b6..000000000 --- a/packages/typescript/test/tsconfig.ts +++ /dev/null @@ -1,50 +0,0 @@ -import test from 'ava'; -import { rollup } from 'rollup'; - -import typescript from '..'; - -import { getCode, onwarn } from '../../../util/test'; - -test.beforeEach(() => process.chdir(__dirname)); - -test.serial('inline config without tsconfig + rootDir', async (t) => { - const bundle = await rollup({ - input: 'fixtures/basic/main.ts', - plugins: [ - typescript({ - declaration: true, - declarationDir: 'fixtures/basic/dist/types', - exclude: 'fixtures/basic/dist/types', - include: 'fixtures/basic/*.ts', - tsconfig: false, - rootDir: 'fixtures/basic' - }) - ], - onwarn - }); - const files = await getCode(bundle, { format: 'esm', dir: 'fixtures/basic/dist' }, true); - const [, { source }] = files; - - t.snapshot(files.map(({ fileName }) => fileName)); - t.true((source as string)?.includes('declare const answer = 42;')); -}); - -test.serial('inline config without tsconfig without rootDir fails', async (t) => { - const fail = () => - rollup({ - input: 'fixtures/basic/main.ts', - plugins: [ - typescript({ - declaration: true, - declarationDir: 'fixtures/basic/dist/types', - exclude: 'fixtures/basic/dist/types', - include: 'fixtures/basic/*.ts', - tsconfig: false - }) - ], - onwarn - }); - - const error = await t.throwsAsync(fail); - t.snapshot(error); -}); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index fee7f3d3f..3c62f4cf0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -460,11 +460,11 @@ importers: devDependencies: '@rollup/plugin-buble': 0.21.3_rollup@2.32.1 '@rollup/plugin-commonjs': 11.1.0_rollup@2.32.1 - '@rollup/plugin-typescript': 5.0.2_rollup@2.32.1+typescript@4.1.2 + '@rollup/plugin-typescript': 5.0.2_rollup@2.32.1+typescript@4.2.2 '@types/node': 10.17.48 buble: 0.20.0 rollup: 2.32.1 - typescript: 4.1.2 + typescript: 4.2.2 specifiers: '@rollup/plugin-buble': ^0.21.3 '@rollup/plugin-commonjs': ^11.1.0 @@ -474,7 +474,7 @@ importers: buble: ^0.20.0 resolve: ^1.17.0 rollup: ^2.14.0 - typescript: ^4.1.2 + typescript: ^4.2.2 packages/url: dependencies: '@rollup/pluginutils': 3.1.0_rollup@2.32.1 @@ -1790,6 +1790,21 @@ packages: typescript: '>=3.4.0' resolution: integrity: sha512-CkS028Itwjqm1uLbFVfpJgtVtnNvZ+og/m6UlNRR5wOOnNTWPcVQzOu5xGdEX+WWJxdvWIqUq2uR/RBt2ZipWg== + /@rollup/plugin-typescript/5.0.2_rollup@2.32.1+typescript@4.2.2: + dependencies: + '@rollup/pluginutils': 3.1.0_rollup@2.32.1 + resolve: 1.18.1 + rollup: 2.32.1 + typescript: 4.2.2 + dev: true + engines: + node: '>=8.0.0' + peerDependencies: + rollup: ^2.14.0 + tslib: '*' + typescript: '>=3.4.0' + resolution: + integrity: sha512-CkS028Itwjqm1uLbFVfpJgtVtnNvZ+og/m6UlNRR5wOOnNTWPcVQzOu5xGdEX+WWJxdvWIqUq2uR/RBt2ZipWg== /@rollup/plugin-typescript/6.0.0_rollup@2.32.1+typescript@4.1.2: dependencies: '@rollup/pluginutils': 3.1.0_rollup@2.32.1 @@ -7441,6 +7456,13 @@ packages: hasBin: true resolution: integrity: sha512-thGloWsGH3SOxv1SoY7QojKi0tc+8FnOmiarEGMbd/lar7QOEd3hvlx3Fp5y6FlDUGl9L+pd4n2e+oToGMmhRQ== + /typescript/4.2.2: + dev: true + engines: + node: '>=4.2.0' + hasBin: true + resolution: + integrity: sha512-tbb+NVrLfnsJy3M59lsDgrzWIflR4d4TIUjz+heUnHZwdF7YsrMTKoRERiIvI2lvBG95dfpLxB21WZhys1bgaQ== /unicode-canonical-property-names-ecmascript/1.0.4: engines: node: '>=4'