Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaking: Change peerDep to @babel/core #522

Merged
merged 3 commits into from
Oct 31, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{
"presets": [
["env", { "loose": true, "targets": { "node": "4.2" } }]
["@babel/env", {
"loose": true,
"targets": {
"node": "4.2"
}
}]
],
"env": {
"test": {
Expand Down
29 changes: 14 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
> This readme is for babel-loader v8 + Babel v7
> Check the [7.x branch](https://github.com/babel/babel-loader/tree/7.x) for docs with Babel v6

[![NPM Status](https://img.shields.io/npm/v/babel-loader.svg?style=flat)](https://www.npmjs.com/package/babel-loader)
[![Build Status](https://travis-ci.org/babel/babel-loader.svg?branch=master)](https://travis-ci.org/babel/babel-loader)
[![Build Status](https://ci.appveyor.com/api/projects/status/vgtpr2i5bykgyuqo/branch/master?svg=true)](https://ci.appveyor.com/project/danez/babel-loader/branch/master)
Expand All @@ -19,20 +22,16 @@ __Notes:__ Issues with the output should be reported on the babel [issue tracker

<h2 align="center">Install</h2>

> webpack 1.x | babel-loader <= 6.x
>
> webpack 2.x | babel-loader >= 7.x (recommended) (^6.2.10 will also work, but with deprecation warnings)
>
> webpack 3.x | babel-loader >= 7.1

```bash
yarn add babel-loader babel-core babel-preset-env webpack --dev
yarn add babel-loader @babel/core @babel/preset-env webpack --dev
```

We recommend using yarn, but you can also still use npm:

```bash
npm install --save-dev babel-loader babel-core babel-preset-env webpack
npm install --save-dev babel-loader @babel/core @babel/preset-env webpack
```

<h2 align="center">Usage</h2>
Expand All @@ -50,7 +49,7 @@ module: {
use: {
loader: 'babel-loader',
options: {
presets: ['env']
presets: ['@babel/env']
}
}
}
Expand All @@ -74,8 +73,8 @@ module: {
use: {
loader: 'babel-loader',
options: {
presets: ['env'],
plugins: [require('babel-plugin-transform-object-rest-spread')]
presets: ['@babel/env'],
plugins: [require('@babel/plugin-transform-object-rest-spread')]
}
}
}
Expand Down Expand Up @@ -130,8 +129,8 @@ rules: [
use: {
loader: 'babel-loader',
options: {
presets: ['env'],
plugins: ['transform-runtime']
presets: ['@babel/env'],
plugins: ['@babel/transform-runtime']
}
}
}
Expand All @@ -153,7 +152,7 @@ Since [babel-plugin-transform-runtime](https://github.com/babel/babel/tree/maste
The following approach will not work either:

```javascript
require('babel-runtime/core-js/promise').default = require('bluebird');
require('@babel/runtime/core-js/promise').default = require('bluebird');

var promise = new Promise;
```
Expand All @@ -163,9 +162,9 @@ which outputs to (using `runtime`):
```javascript
'use strict';

var _Promise = require('babel-runtime/core-js/promise')['default'];
var _Promise = require('@babel/runtime/core-js/promise')['default'];

require('babel-runtime/core-js/promise')['default'] = require('bluebird');
require('@babel/runtime/core-js/promise')['default'] = require('bluebird');

var promise = new _Promise();
```
Expand All @@ -177,7 +176,7 @@ One approach is to have a "bootstrap" step in your application that would first
```javascript
// bootstrap.js

require('babel-runtime/core-js/promise').default = require('bluebird');
require('@babel/runtime/core-js/promise').default = require('bluebird');

// ...

Expand Down
17 changes: 6 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,17 @@
"mkdirp": "^0.5.1"
},
"peerDependencies": {
"babel-core": "6 || 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc",
"@babel/core": "7 || ^7.0.0-beta || ^7.0.0-rc",
"webpack": "2 || 3"
},
"devDependencies": {
"ava": "^0.23.0",
"babel-cli": "^6.18.0",
"babel-core": "^6.0.0",
"@babel/cli": "7.0.0-beta.5",
"@babel/core": "7.0.0-beta.5",
"@babel/preset-env": "7.0.0-beta.5",
"ava": "0.23.0",
"babel-eslint": "^8.0.0",
"babel-plugin-istanbul": "^4.0.0",
"babel-plugin-react-intl": "^2.1.3",
"babel-preset-env": "^1.2.0",
"babel-register": "^6.18.0",
"cross-env": "^5.0.0",
"eslint": "^4.1.0",
"eslint-config-babel": "^7.0.0",
Expand Down Expand Up @@ -80,9 +79,6 @@
"text",
"json"
],
"require": [
"babel-register"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't need register either for nyc

],
"sourceMap": false,
"instrument": false
},
Expand All @@ -94,8 +90,7 @@
],
"source": [
"src/**/*.js"
],
"babel": "inherit"
]
},
"lint-staged": {
"scripts/*.js": [
Expand Down
6 changes: 3 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const babel = require("babel-core");
const babel = require("@babel/core");
const loaderUtils = require("loader-utils");
const path = require("path");
const cache = require("./fs-cache.js");
Expand Down Expand Up @@ -131,8 +131,8 @@ module.exports = function(source, inputSourceMap) {
sourceRoot: process.cwd(),
filename: filename,
cacheIdentifier: JSON.stringify({
"babel-loader": pkg.version,
"babel-core": babel.version,
"@babel/loader": pkg.version,
"@babel/core": babel.version,
babelrc: babelrcPath ? read(fileSystem, babelrcPath) : null,
env:
loaderOptions.forceEnv ||
Expand Down
19 changes: 10 additions & 9 deletions test/cache.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ test.cb("should output files to cache directory", t => {
exclude: /node_modules/,
query: {
cacheDirectory: t.context.cacheDirectory,
presets: ["env"],
presets: ["@babel/env"],
},
},
],
Expand Down Expand Up @@ -93,7 +93,7 @@ test.cb.serial(
exclude: /node_modules/,
query: {
cacheDirectory: true,
presets: ["env"],
presets: ["@babel/env"],
},
},
],
Expand Down Expand Up @@ -125,7 +125,7 @@ test.cb.serial(
loaders: [
{
test: /\.jsx?/,
loader: `${babelLoader}?cacheDirectory=true&presets[]=env`,
loader: `${babelLoader}?cacheDirectory=true&presets[]=@babel/preset-env`,
exclude: /node_modules/,
},
],
Expand All @@ -139,6 +139,7 @@ test.cb.serial(
files = files.filter(file => /\b[0-9a-f]{5,40}\.json\.gz\b/.test(file));

t.is(err, null);

t.true(files.length > 0);
t.end();
});
Expand All @@ -159,7 +160,7 @@ test.cb.skip("should read from cache directory if cached file exists", t => {
exclude: /node_modules/,
query: {
cacheDirectory: t.context.cacheDirectory,
presets: ["env"],
presets: ["@babel/env"],
},
},
],
Expand Down Expand Up @@ -195,7 +196,7 @@ test.cb("should have one file per module", t => {
exclude: /node_modules/,
query: {
cacheDirectory: t.context.cacheDirectory,
presets: ["env"],
presets: ["@babel/env"],
},
},
],
Expand Down Expand Up @@ -228,7 +229,7 @@ test.cb("should generate a new file if the identifier changes", t => {
query: {
cacheDirectory: t.context.cacheDirectory,
cacheIdentifier: "a",
presets: ["env"],
presets: ["@babel/env"],
},
},
],
Expand All @@ -247,7 +248,7 @@ test.cb("should generate a new file if the identifier changes", t => {
query: {
cacheDirectory: t.context.cacheDirectory,
cacheIdentifier: "b",
presets: ["env"],
presets: ["@babel/env"],
},
},
],
Expand Down Expand Up @@ -288,7 +289,7 @@ test.cb("should allow to specify the .babelrc file", t => {
query: {
cacheDirectory: t.context.cacheDirectory,
babelrc: path.join(__dirname, "fixtures/babelrc"),
presets: ["env"],
presets: ["@babel/env"],
},
},
],
Expand All @@ -307,7 +308,7 @@ test.cb("should allow to specify the .babelrc file", t => {
exclude: /node_modules/,
query: {
cacheDirectory: t.context.cacheDirectory,
presets: ["env"],
presets: ["@babel/env"],
},
},
],
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/babelrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"presets": ["env"]
"presets": ["@babel/env"]
}
2 changes: 1 addition & 1 deletion test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const globalConfig = {
test: /\.jsx?/,
loader: babelLoader,
query: {
presets: ["env"],
presets: ["@babel/env"],
},
exclude: /node_modules/,
},
Expand Down
Loading