From 564a6d44eac049bb6329f5dadda03bed7f894f19 Mon Sep 17 00:00:00 2001 From: EGOIST Date: Thu, 3 Nov 2022 22:07:22 +0800 Subject: [PATCH] fix: use rollup v3, closes #749 --- package.json | 6 +- pnpm-lock.yaml | 96 +++++++++++++++------------ src/plugin.ts | 3 +- test/__snapshots__/index.test.ts.snap | 18 ++--- 4 files changed, 68 insertions(+), 55 deletions(-) diff --git a/package.json b/package.json index 13301f8fb..ac38eca89 100644 --- a/package.json +++ b/package.json @@ -36,13 +36,13 @@ "joycon": "^3.0.1", "postcss-load-config": "^3.0.1", "resolve-from": "^5.0.0", - "rollup": "^2.74.1", + "rollup": "^3.2.5", "source-map": "0.8.0-beta.0", "sucrase": "^3.20.3", "tree-kill": "^1.2.2" }, "devDependencies": { - "@rollup/plugin-json": "4.1.0", + "@rollup/plugin-json": "5.0.1", "@swc/core": "1.2.218", "@types/debug": "4.1.7", "@types/flat": "5.0.2", @@ -57,7 +57,7 @@ "postcss-simple-vars": "6.0.3", "prettier": "2.5.1", "resolve": "1.20.0", - "rollup-plugin-dts": "4.2.1", + "rollup-plugin-dts": "5.0.0", "rollup-plugin-hashbang": "2.2.2", "strip-json-comments": "4.0.0", "svelte": "3.46.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a816d320b..207fabe58 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,7 +1,7 @@ lockfileVersion: 5.4 specifiers: - '@rollup/plugin-json': 4.1.0 + '@rollup/plugin-json': 5.0.1 '@swc/core': 1.2.218 '@types/debug': 4.1.7 '@types/flat': 5.0.2 @@ -26,8 +26,8 @@ specifiers: prettier: 2.5.1 resolve: 1.20.0 resolve-from: ^5.0.0 - rollup: ^2.74.1 - rollup-plugin-dts: 4.2.1 + rollup: ^3.2.5 + rollup-plugin-dts: 5.0.0 rollup-plugin-hashbang: 2.2.2 source-map: 0.8.0-beta.0 strip-json-comments: 4.0.0 @@ -52,13 +52,13 @@ dependencies: joycon: 3.0.1 postcss-load-config: 3.1.0 resolve-from: 5.0.0 - rollup: 2.74.1 + rollup: 3.2.5 source-map: 0.8.0-beta.0 sucrase: 3.20.3 tree-kill: 1.2.2 devDependencies: - '@rollup/plugin-json': 4.1.0_rollup@2.74.1 + '@rollup/plugin-json': 5.0.1_rollup@3.2.5 '@swc/core': 1.2.218 '@types/debug': 4.1.7 '@types/flat': 5.0.2 @@ -73,7 +73,7 @@ devDependencies: postcss-simple-vars: 6.0.3_postcss@8.4.12 prettier: 2.5.1 resolve: 1.20.0 - rollup-plugin-dts: 4.2.1_rymbksdyfyl5jij5b5y6cpv63i + rollup-plugin-dts: 5.0.0_mwekjofbfztuuh2kb3ofhfbyx4 rollup-plugin-hashbang: 2.2.2 strip-json-comments: 4.0.0 svelte: 3.46.4 @@ -327,25 +327,32 @@ packages: '@nodelib/fs.scandir': 2.1.5 fastq: 1.13.0 - /@rollup/plugin-json/4.1.0_rollup@2.74.1: - resolution: {integrity: sha512-yfLbTdNS6amI/2OpmbiBoW12vngr5NW2jCJVZSBEz+H5KfUJZ2M7sDjk0U6GOOdCWFVScShte29o9NezJ53TPw==} + /@rollup/plugin-json/5.0.1_rollup@3.2.5: + resolution: {integrity: sha512-QCwhZZLvM8nRcTHyR1vOgyTMiAnjiNj1ebD/BMRvbO1oc/z14lZH6PfxXeegee2B6mky/u9fia4fxRM4TqrUaw==} + engines: {node: '>=14.0.0'} peerDependencies: - rollup: ^1.20.0 || ^2.0.0 + rollup: ^1.20.0||^2.0.0||^3.0.0 + peerDependenciesMeta: + rollup: + optional: true dependencies: - '@rollup/pluginutils': 3.1.0_rollup@2.74.1 - rollup: 2.74.1 + '@rollup/pluginutils': 5.0.2_rollup@3.2.5 + rollup: 3.2.5 dev: true - /@rollup/pluginutils/3.1.0_rollup@2.74.1: - resolution: {integrity: sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==} - engines: {node: '>= 8.0.0'} + /@rollup/pluginutils/5.0.2_rollup@3.2.5: + resolution: {integrity: sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==} + engines: {node: '>=14.0.0'} peerDependencies: - rollup: ^1.20.0||^2.0.0 + rollup: ^1.20.0||^2.0.0||^3.0.0 + peerDependenciesMeta: + rollup: + optional: true dependencies: - '@types/estree': 0.0.39 - estree-walker: 1.0.1 - picomatch: 2.3.0 - rollup: 2.74.1 + '@types/estree': 1.0.0 + estree-walker: 2.0.2 + picomatch: 2.3.1 + rollup: 3.2.5 dev: true /@swc/core-android-arm-eabi/1.2.218: @@ -506,8 +513,8 @@ packages: '@types/ms': 0.7.31 dev: true - /@types/estree/0.0.39: - resolution: {integrity: sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==} + /@types/estree/1.0.0: + resolution: {integrity: sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==} dev: true /@types/flat/5.0.2: @@ -654,7 +661,7 @@ packages: optional: true /color-name/1.1.3: - resolution: {integrity: sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=} + resolution: {integrity: sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==} dev: true optional: true @@ -956,13 +963,13 @@ packages: dev: false /escape-string-regexp/1.0.5: - resolution: {integrity: sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=} + resolution: {integrity: sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==} engines: {node: '>=0.8.0'} dev: true optional: true - /estree-walker/1.0.1: - resolution: {integrity: sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==} + /estree-walker/2.0.2: + resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} dev: true /execa/5.1.1: @@ -1068,7 +1075,7 @@ packages: dev: true /has-flag/3.0.0: - resolution: {integrity: sha1-tdRU3CGZriJWmfNGfloH87lVuv0=} + resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==} engines: {node: '>=4'} dev: true optional: true @@ -1203,8 +1210,8 @@ packages: vlq: 0.2.3 dev: true - /magic-string/0.26.1: - resolution: {integrity: sha512-ndThHmvgtieXe8J/VGPjG+Apu7v7ItcD5mhEIvOscWjPF/ccOiLxHaSuCAS2G+3x4GKsAbT8u7zdyamupui8Tg==} + /magic-string/0.26.7: + resolution: {integrity: sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow==} engines: {node: '>=12'} dependencies: sourcemap-codec: 1.4.8 @@ -1316,6 +1323,11 @@ packages: resolution: {integrity: sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==} engines: {node: '>=8.6'} + /picomatch/2.3.1: + resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} + engines: {node: '>=8.6'} + dev: true + /pirates/4.0.1: resolution: {integrity: sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA==} engines: {node: '>= 6'} @@ -1405,15 +1417,15 @@ packages: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} - /rollup-plugin-dts/4.2.1_rymbksdyfyl5jij5b5y6cpv63i: - resolution: {integrity: sha512-eaxQZNUJ5iQcxNGlpJ1CUgG4OSVqWjDZ3nNSWBIoGrpcote2aNphSe1RJOaSYkb8dwn3o+rYm1vvld/5z3EGSQ==} - engines: {node: '>=v12.22.11'} + /rollup-plugin-dts/5.0.0_mwekjofbfztuuh2kb3ofhfbyx4: + resolution: {integrity: sha512-OO8ayCvuJCKaQSShyVTARxGurVVk4ulzbuvz+0zFd1f93vlnWFU5pBMT7HFeS6uj7MvvZLx4kUAarGATSU1+Ng==} + engines: {node: '>=v14'} peerDependencies: - rollup: ^2.70 - typescript: ^4.6 + rollup: ^3.0.0 + typescript: ^4.1 dependencies: - magic-string: 0.26.1 - rollup: 2.74.1 + magic-string: 0.26.7 + rollup: 3.2.5 typescript: 4.6.3 optionalDependencies: '@babel/code-frame': 7.18.6 @@ -1426,20 +1438,20 @@ packages: magic-string: 0.22.5 dev: true - /rollup/2.74.1: - resolution: {integrity: sha512-K2zW7kV8Voua5eGkbnBtWYfMIhYhT9Pel2uhBk2WO5eMee161nPze/XRfvEQPFYz7KgrCCnmh2Wy0AMFLGGmMA==} + /rollup/2.77.0: + resolution: {integrity: sha512-vL8xjY4yOQEw79DvyXLijhnhh+R/O9zpF/LEgkCebZFtb6ELeN9H3/2T0r8+mp+fFTBHZ5qGpOpW2ela2zRt3g==} engines: {node: '>=10.0.0'} hasBin: true optionalDependencies: fsevents: 2.3.2 + dev: true - /rollup/2.77.0: - resolution: {integrity: sha512-vL8xjY4yOQEw79DvyXLijhnhh+R/O9zpF/LEgkCebZFtb6ELeN9H3/2T0r8+mp+fFTBHZ5qGpOpW2ela2zRt3g==} - engines: {node: '>=10.0.0'} + /rollup/3.2.5: + resolution: {integrity: sha512-/Ha7HhVVofduy+RKWOQJrxe4Qb3xyZo+chcpYiD8SoQa4AG7llhupUtyfKSSrdBM2mWJjhM8wZwmbY23NmlIYw==} + engines: {node: '>=14.18.0', npm: '>=8.0.0'} hasBin: true optionalDependencies: fsevents: 2.3.2 - dev: true /run-parallel/1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} @@ -1606,7 +1618,7 @@ packages: postcss: 8.4.12 postcss-load-config: 3.1.0 resolve-from: 5.0.0 - rollup: 2.74.1 + rollup: 2.77.0 source-map: 0.8.0-beta.0 sucrase: 3.20.3 tree-kill: 1.2.2 diff --git a/src/plugin.ts b/src/plugin.ts index ad8f0b958..1a8e31a8c 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -5,6 +5,7 @@ import { Format, NormalizedOptions } from '.' import { outputFile } from './fs' import { Logger } from './log' import { MaybePromise } from './utils' +import { SourceMap } from 'rollup' export type ChunkInfo = { type: 'chunk' @@ -30,7 +31,7 @@ export type RenderChunk = ( ) => MaybePromise< | { code: string - map?: object | string + map?: object | string | SourceMap | null } | undefined | null diff --git a/test/__snapshots__/index.test.ts.snap b/test/__snapshots__/index.test.ts.snap index 5f76bbf56..38ec57bc9 100644 --- a/test/__snapshots__/index.test.ts.snap +++ b/test/__snapshots__/index.test.ts.snap @@ -167,6 +167,15 @@ console.log(import_node_fs.default); " `; +exports[`not bundle \`package/subpath\` in dts (resolve) 1`] = ` +"import * as foo_bar from 'foo/bar'; + +declare const stuff: foo_bar.Foobar; + +export { stuff }; +" +`; + exports[`simple 1`] = ` "\\"use strict\\"; var __defProp = Object.defineProperty; @@ -204,15 +213,6 @@ var input_default = foo_default; " `; -exports[`not bundle \`package/subpath\` in dts (resolve) 1`] = ` -"import * as foo_bar from 'foo/bar'; - -declare const stuff: foo_bar.Foobar; - -export { stuff }; -" -`; - exports[`support baseUrl and paths in tsconfig.json 1`] = ` "var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor;