diff --git a/packages/replace/README.md b/packages/replace/README.md index c81dd9be9..cc3e32d38 100644 --- a/packages/replace/README.md +++ b/packages/replace/README.md @@ -13,7 +13,7 @@ ## Requirements -This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v8.0.0+) and Rollup v1.20.0+. +This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v14.0.0+) and Rollup v1.20.0+. ## Install diff --git a/packages/replace/package.json b/packages/replace/package.json index c2e352d35..442d41af2 100644 --- a/packages/replace/package.json +++ b/packages/replace/package.json @@ -13,8 +13,16 @@ "author": "Rich Harris ", "homepage": "https://github.com/rollup/plugins/tree/master/packages/replace#readme", "bugs": "https://github.com/rollup/plugins/issues", - "main": "dist/rollup-plugin-replace.cjs.js", - "module": "dist/rollup-plugin-replace.es.js", + "main": "dist/cjs/index.js", + "module": "dist/es/index.js", + "exports": { + "types": "./types/index.d.ts", + "import": "./dist/es/index.js", + "default": "./dist/cjs/index.js" + }, + "engines": { + "node": ">=14.0.0" + }, "scripts": { "build": "rollup -c", "ci:coverage": "nyc pnpm test && nyc report --reporter=text-lcov > coverage.lcov", @@ -31,6 +39,7 @@ }, "files": [ "dist", + "!dist/**/*.map", "src", "types", "README.md" @@ -44,21 +53,26 @@ "modules" ], "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", - "magic-string": "^0.25.7" + "@rollup/pluginutils": "^4.2.1", + "magic-string": "^0.26.4" }, "devDependencies": { "@rollup/plugin-buble": "^0.21.3", - "del-cli": "^3.0.1", + "del-cli": "^5.0.0", "locate-character": "^2.0.5", - "rollup": "^2.67.3", - "source-map": "^0.7.3", - "typescript": "^3.9.7" + "rollup": "^3.0.0-7", + "source-map": "^0.7.4", + "typescript": "^4.8.3" }, - "types": "types/index.d.ts", + "types": "./types/index.d.ts", "ava": { "workerThreads": false, "files": [ diff --git a/packages/replace/rollup.config.js b/packages/replace/rollup.config.js deleted file mode 100755 index 2244813fc..000000000 --- a/packages/replace/rollup.config.js +++ /dev/null @@ -1,15 +0,0 @@ -import buble from '@rollup/plugin-buble'; - -import pkg from './package.json'; - -const external = Object.keys(pkg.dependencies).concat('path'); - -export default { - input: 'src/index.js', - plugins: [buble()], - external, - output: [ - { file: pkg.main, format: 'cjs', exports: 'auto' }, - { file: pkg.module, format: 'es' } - ] -}; diff --git a/packages/replace/rollup.config.mjs b/packages/replace/rollup.config.mjs new file mode 100755 index 000000000..888000cd3 --- /dev/null +++ b/packages/replace/rollup.config.mjs @@ -0,0 +1,13 @@ +import { readFileSync } from 'fs'; + +import buble from '@rollup/plugin-buble'; + +import { createConfig } from '../../shared/rollup.config.mjs'; + +export default { + ...createConfig({ + pkg: JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')) + }), + input: 'src/index.js', + plugins: [buble()] +}; diff --git a/packages/replace/test/form.js b/packages/replace/test/form.js index 998d699c7..9685dcc99 100644 --- a/packages/replace/test/form.js +++ b/packages/replace/test/form.js @@ -6,7 +6,7 @@ const { readdirSync, readFileSync } = require('fs'); const test = require('ava'); -const replace = require('../dist/rollup-plugin-replace.cjs.js'); +const replace = require('..'); const transformContext = {}; diff --git a/packages/replace/test/function.js b/packages/replace/test/function.js index fa15d002d..20dab0779 100644 --- a/packages/replace/test/function.js +++ b/packages/replace/test/function.js @@ -7,7 +7,7 @@ const { readdirSync } = require('fs'); const test = require('ava'); const { rollup } = require('rollup'); -const replace = require('../dist/rollup-plugin-replace.cjs.js'); +const replace = require('..'); const { execute, getCodeFromBundle } = require('./helpers/util'); diff --git a/packages/replace/test/misc.js b/packages/replace/test/misc.js index 97124a702..cedfbcfff 100644 --- a/packages/replace/test/misc.js +++ b/packages/replace/test/misc.js @@ -5,7 +5,7 @@ const { join } = require('path'); const test = require('ava'); const { rollup } = require('rollup'); -const replace = require('../dist/rollup-plugin-replace.cjs.js'); +const replace = require('..'); const { getOutputFromGenerated } = require('./helpers/util'); @@ -63,7 +63,7 @@ test('can be configured with output plugins', async (t) => { }) ); - t.is(code.trim(), 'log("environment", "production");'); + t.is(code.trim(), 'log("environment", "production");\n//# sourceMappingURL=main.js.map'); t.truthy(map); }); diff --git a/packages/replace/test/sourcemaps.js b/packages/replace/test/sourcemaps.js index 1cff04538..65cc5e0cd 100644 --- a/packages/replace/test/sourcemaps.js +++ b/packages/replace/test/sourcemaps.js @@ -10,7 +10,7 @@ delete global.fetch; const { SourceMapConsumer } = require('source-map'); global.fetch = fetch; -const replace = require('../dist/rollup-plugin-replace.cjs.js'); +const replace = require('..'); const { getOutputFromGenerated } = require('./helpers/util'); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5e29fb549..a9cd5dffc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -437,23 +437,23 @@ importers: packages/replace: specifiers: '@rollup/plugin-buble': ^0.21.3 - '@rollup/pluginutils': ^3.1.0 - del-cli: ^3.0.1 + '@rollup/pluginutils': ^4.2.1 + del-cli: ^5.0.0 locate-character: ^2.0.5 - magic-string: ^0.25.7 - rollup: ^2.67.3 - source-map: ^0.7.3 - typescript: ^3.9.7 + magic-string: ^0.26.4 + rollup: ^3.0.0-7 + source-map: ^0.7.4 + typescript: ^4.8.3 dependencies: - '@rollup/pluginutils': 3.1.0_rollup@2.79.1 - magic-string: 0.25.9 + '@rollup/pluginutils': 4.2.1 + magic-string: 0.26.7 devDependencies: - '@rollup/plugin-buble': 0.21.3_rollup@2.79.1 - del-cli: 3.0.1 + '@rollup/plugin-buble': 0.21.3_rollup@3.0.0-7 + del-cli: 5.0.0 locate-character: 2.0.5 - rollup: 2.79.1 + rollup: 3.0.0-7 source-map: 0.7.4 - typescript: 3.9.10 + typescript: 4.8.3 packages/run: specifiers: @@ -7398,12 +7398,6 @@ packages: is-typedarray: 1.0.0 dev: true - /typescript/3.9.10: - resolution: {integrity: sha512-w6fIxVE/H1PkLKcCPsFqKE7Kv7QUwhU8qQY2MueZXWx5cPZdwFupLgKK3vntcK98BtNHZtAF4LA/yl2a7k8R6Q==} - engines: {node: '>=4.2.0'} - hasBin: true - dev: true - /typescript/4.8.3: resolution: {integrity: sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==} engines: {node: '>=4.2.0'}