Skip to content

Commit

Permalink
fix(babel): prepare for Rollup 3
Browse files Browse the repository at this point in the history
BREAKING CHANGES: Requires Node 14
  • Loading branch information
lukastaegert committed Sep 30, 2022
1 parent 32aa6d2 commit 45a3f3a
Show file tree
Hide file tree
Showing 14 changed files with 231 additions and 172 deletions.
14 changes: 7 additions & 7 deletions packages/babel/README.md
Expand Up @@ -26,7 +26,7 @@ Using Rollup with `@rollup/plugin-babel` makes the process far easier.

## Requirements

This plugin requires an [LTS](https://github.com/nodejs/Release) Node version (v10.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

Expand All @@ -45,7 +45,7 @@ const config = {
input: 'src/index.js',
output: {
dir: 'output',
format: 'esm'
format: 'es'
},
plugins: [babel({ babelHelpers: 'bundled' })]
};
Expand Down Expand Up @@ -174,7 +174,7 @@ export default {
],
output: [
{ file: 'bundle.cjs.js', format: 'cjs' },
{ file: 'bundle.esm.js', format: 'esm' }
{ file: 'bundle.esm.js', format: 'es' }
]
};
```
Expand All @@ -188,10 +188,10 @@ import { getBabelOutputPlugin } from '@rollup/plugin-babel';
export default {
input: 'main.js',
output: [
{ file: 'bundle.js', format: 'esm' },
{ file: 'bundle.js', format: 'es' },
{
file: 'bundle.es5.js',
format: 'esm',
format: 'es',
plugins: [getBabelOutputPlugin({ presets: ['@babel/preset-env'] })]
}
]
Expand All @@ -212,7 +212,7 @@ export default {
output: [
{
file: 'bundle.js',
format: 'esm',
format: 'es',
plugins: [getBabelOutputPlugin({ presets: ['@babel/preset-env'] })]
}
]
Expand Down Expand Up @@ -261,7 +261,7 @@ Note that this will only work for `esm` and `cjs` formats, and you need to make
```js
rollup.rollup({...})
.then(bundle => bundle.generate({
format: 'esm',
format: 'es',
plugins: [getBabelOutputPlugin({
presets: ['@babel/preset-env'],
plugins: [['@babel/plugin-transform-runtime', { useESModules: true }]]
Expand Down
40 changes: 22 additions & 18 deletions packages/babel/package.json
Expand Up @@ -13,10 +13,14 @@
"author": "Rich Harris",
"homepage": "https://github.com/rollup/plugins/tree/master/packages/babel#readme",
"bugs": "https://github.com/rollup/plugins/issues",
"main": "dist/index.js",
"module": "dist/index.es.js",
"main": "./dist/cjs/index.js",
"module": "./dist/es/index.js",
"exports": {
"require": "./dist/cjs/index.js",
"import": "./dist/es/index.js"
},
"engines": {
"node": ">= 10.0.0"
"node": ">=14.0.0"
},
"scripts": {
"build": "rollup -c",
Expand All @@ -32,7 +36,7 @@
"test:ts": "tsc types/index.d.ts test/types.ts --noEmit"
},
"files": [
"dist",
"dist/**/*.{js,json}",
"types",
"README.md",
"LICENSE"
Expand All @@ -48,35 +52,35 @@
"peerDependencies": {
"@babel/core": "^7.0.0",
"@types/babel__core": "^7.1.9",
"rollup": "^1.20.0||^2.0.0"
"rollup": "^1.20.0||^2.0.0||^3.0.0"
},
"peerDependenciesMeta": {
"rollup": {
"optional": true
},
"@types/babel__core": {
"optional": true
}
},
"dependencies": {
"@babel/helper-module-imports": "^7.10.4",
"@rollup/pluginutils": "^3.1.0"
"@babel/helper-module-imports": "^7.18.6",
"@rollup/pluginutils": "^4.2.1"
},
"devDependencies": {
"@babel/core": "^7.10.5",
"@babel/plugin-external-helpers": "^7.10.4",
"@babel/plugin-proposal-decorators": "^7.10.5",
"@babel/core": "^7.19.1",
"@babel/plugin-external-helpers": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.19.1",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-transform-runtime": "^7.10.5",
"@babel/preset-env": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.19.1",
"@babel/preset-env": "^7.19.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^10.0.0",
"@rollup/plugin-node-resolve": "^14.1.0",
"@types/babel__core": "^7.1.9",
"rollup": "^2.67.3",
"source-map": "^0.7.3"
"rollup": "^3.0.0-7",
"source-map": "^0.7.4"
},
"types": "types/index.d.ts",
"ava": {
"babel": {
"compileEnhancements": false
},
"files": [
"!**/fixtures/**",
"!**/helpers/**",
Expand Down
20 changes: 0 additions & 20 deletions packages/babel/rollup.config.js

This file was deleted.

18 changes: 18 additions & 0 deletions packages/babel/rollup.config.mjs
@@ -0,0 +1,18 @@
import { readFileSync } from 'fs';

import { createConfig } from '../../shared/rollup.config.mjs';

import { babel } from './src/index.js';

const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));

export default {
...createConfig({ pkg }),
input: './src/index.js',
plugins: [
babel({
presets: [['@babel/preset-env', { targets: { node: 8 } }]],
babelHelpers: 'bundled'
})
]
};
2 changes: 1 addition & 1 deletion packages/babel/src/bundledHelpersPlugin.js
@@ -1,6 +1,6 @@
import { addNamed } from '@babel/helper-module-imports';

import { HELPERS } from './constants';
import { HELPERS } from './constants.js';

export default function importHelperPlugin({ types: t }) {
return {
Expand Down
10 changes: 5 additions & 5 deletions packages/babel/src/index.js
@@ -1,11 +1,11 @@
import * as babel from '@babel/core';
import { createFilter } from '@rollup/pluginutils';

import { BUNDLED, HELPERS } from './constants';
import bundledHelpersPlugin from './bundledHelpersPlugin';
import preflightCheck from './preflightCheck';
import transformCode from './transformCode';
import { addBabelPlugin, escapeRegExpCharacters, warnOnce, stripQuery } from './utils';
import { BUNDLED, HELPERS } from './constants.js';
import bundledHelpersPlugin from './bundledHelpersPlugin.js';
import preflightCheck from './preflightCheck.js';
import transformCode from './transformCode.js';
import { addBabelPlugin, escapeRegExpCharacters, warnOnce, stripQuery } from './utils.js';

const unpackOptions = ({
extensions = babel.DEFAULT_EXTENSIONS,
Expand Down
3 changes: 3 additions & 0 deletions packages/babel/src/package.json
@@ -0,0 +1,3 @@
{
"type": "module"
}
4 changes: 2 additions & 2 deletions packages/babel/src/preflightCheck.js
@@ -1,7 +1,7 @@
import * as babel from '@babel/core';

import { INLINE, RUNTIME, EXTERNAL, BUNDLED } from './constants';
import { addBabelPlugin } from './utils';
import { INLINE, RUNTIME, EXTERNAL, BUNDLED } from './constants.js';
import { addBabelPlugin } from './utils.js';

const MODULE_ERROR =
'Rollup requires that your Babel configuration keeps ES6 module syntax intact. ' +
Expand Down

0 comments on commit 45a3f3a

Please sign in to comment.