From e6430d50240aa78f19ff81dc5d0766a325037815 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Wed, 24 Feb 2021 07:12:38 -0800 Subject: [PATCH 1/2] chore(typescript): bump TypeScript version --- packages/typescript/package.json | 2 +- packages/typescript/test/test.js | 6 +----- pnpm-lock.yaml | 28 +++++++++++++++++++++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) 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/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/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' From 10f7b2b5760b5d98bfbe28773cb44af3cfef9df5 Mon Sep 17 00:00:00 2001 From: Ben McCann <322311+benmccann@users.noreply.github.com> Date: Wed, 24 Feb 2021 08:14:30 -0800 Subject: [PATCH 2/2] Revert "feat(typescript): error when no tsconfig and no rootDir (#794)" This reverts commit cbfd779dd3b78dc1ece7b41e1488bf69ac8de6fa. --- packages/typescript/src/preflight.ts | 7 --- .../typescript/test/snapshots/tsconfig.ts.md | 25 --------- .../test/snapshots/tsconfig.ts.snap | Bin 409 -> 0 bytes packages/typescript/test/tsconfig.ts | 50 ------------------ 4 files changed, 82 deletions(-) delete mode 100644 packages/typescript/test/snapshots/tsconfig.ts.md delete mode 100644 packages/typescript/test/snapshots/tsconfig.ts.snap delete mode 100644 packages/typescript/test/tsconfig.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 ecf6b0f74f435539fbb9f3bb652a5458bd699c59..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 409 zcmV;K0cQR|RzVqf00000000AB zkiSX;K@i4wF8?G%E+Hu_m$T8r#L6O-VuA!DhNxg8vbozNtLN>xyN3j^vG4%|3tKCn zzy}blY%G0%fSrw4*|>XpiDcnp=9~S^E;Dt6kcB>8KO5J}7mxQ3--lPvl`$Z5A|1Xi zUk-X5r}Q>jdLNV9MTn~gNTFOz!2)D9b!=$~tvjtJtuk08$TWrEq72z21xT`Dv4~(E zK^lQ=;0mM=WJ-{BxknRI=xpzAwc1C`Zg;0U3l2FyNld;MG2h!&M5q}o8~V|J1rtz> zLMmOs!dWnPN~I)&CPr!(D#ioMBo_26 zVuE`3d`JVVOplT-5BhBI9}Bp`GNdl+GtH8~!;VK?p9o?I#~_Xp5p}AQrO!cXRmU~0 zcD!t};SC|kDBf_K*|v=!kHA7uFoUA$q=W_4WBFGHNG|Mn#9DmqRh9e!Cr80{9s&RW DgmJNa 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); -});