Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: babel/babel-loader
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v8.0.4
Choose a base ref
...
head repository: babel/babel-loader
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Oct 4, 2018

  1. Fix license header and link

    MattGurneyAMP authored Oct 4, 2018
    Copy the full SHA
    98f936d View commit details
  2. Merge pull request #698 from MattGurneyAMP/patch-1

    Fix license header and link
    xtuc authored Oct 4, 2018
    Copy the full SHA
    364387d View commit details

Commits on Oct 19, 2018

  1. Fix config issue in example (#708)

    alexturpin authored and loganfsmyth committed Oct 19, 2018
    Copy the full SHA
    1bda840 View commit details

Commits on Dec 6, 2018

  1. Add node 11 and 10 (#744)

    danez authored Dec 6, 2018
    Copy the full SHA
    2c61de5 View commit details
  2. 3
    Copy the full SHA
    6df8af1 View commit details

Commits on Dec 24, 2018

  1. Copy the full SHA
    66f92af View commit details

Commits on Jan 4, 2019

  1. chore: Update ava

    danez committed Jan 4, 2019
    Copy the full SHA
    de51b5d View commit details
  2. 8.0.5

    danez committed Jan 4, 2019
    Copy the full SHA
    20c9e0e View commit details

Commits on Mar 2, 2019

  1. Copy the full SHA
    3e2ba74 View commit details
  2. Update dependencies

    danez committed Mar 2, 2019
    Copy the full SHA
    a015f5a View commit details
  3. Remove babel 6 mentions

    danez authored Mar 2, 2019
    Copy the full SHA
    858034b View commit details
  4. Update LICENSE

    danez authored Mar 2, 2019
    Copy the full SHA
    5da4fa0 View commit details

Commits on May 12, 2019

  1. chore: migrate on pify (#785)

    evilebottnawi authored and danez committed May 12, 2019
    Copy the full SHA
    f63f4d8 View commit details
  2. Reduced memory usage (#781)

    * Update index.js
    
    * Update index.js
    popuguytheparrot authored and danez committed May 12, 2019
    Copy the full SHA
    4c02657 View commit details
  3. Fix lint

    danez committed May 12, 2019
    Copy the full SHA
    8d4353f View commit details
  4. Update dependencies

    danez committed May 12, 2019
    Copy the full SHA
    a53fc37 View commit details
  5. Copy the full SHA
    5d5991a View commit details
  6. Add node 12

    danez committed May 12, 2019
    Copy the full SHA
    cfb0ad8 View commit details
  7. 8.0.6

    danez committed May 12, 2019
    Copy the full SHA
    62a8579 View commit details

Commits on Jul 15, 2019

  1. Bump lodash from 4.17.11 to 4.17.14 (#800)

    Bumps [lodash](https://github.com/lodash/lodash) from 4.17.11 to 4.17.14.
    - [Release notes](https://github.com/lodash/lodash/releases)
    - [Commits](lodash/lodash@4.17.11...4.17.14)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and danez committed Jul 15, 2019
    Copy the full SHA
    799b574 View commit details
  2. Bump lodash.merge from 4.6.1 to 4.6.2 (#801)

    Bumps [lodash.merge](https://github.com/lodash/lodash) from 4.6.1 to 4.6.2.
    - [Release notes](https://github.com/lodash/lodash/releases)
    - [Commits](https://github.com/lodash/lodash/commits)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and danez committed Jul 15, 2019
    Copy the full SHA
    473d03b View commit details

Commits on Aug 29, 2019

  1. Bump mixin-deep from 1.3.1 to 1.3.2 (#807)

    Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2.
    - [Release notes](https://github.com/jonschlinkert/mixin-deep/releases)
    - [Commits](jonschlinkert/mixin-deep@1.3.1...1.3.2)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and existentialism committed Aug 29, 2019
    Copy the full SHA
    38a8c64 View commit details
  2. Bump eslint-utils from 1.3.1 to 1.4.2 (#806)

    Bumps [eslint-utils](https://github.com/mysticatea/eslint-utils) from 1.3.1 to 1.4.2.
    - [Release notes](https://github.com/mysticatea/eslint-utils/releases)
    - [Commits](mysticatea/eslint-utils@v1.3.1...v1.4.2)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    dependabot[bot] authored and JLHwung committed Aug 29, 2019
    Copy the full SHA
    a961168 View commit details

Commits on Oct 1, 2019

  1. Copy the full SHA
    26aa687 View commit details
  2. chore: Upgrade more dev dependencies

    Also do not run travis on node 6
    danez committed Oct 1, 2019
    Copy the full SHA
    26d1676 View commit details
  3. Copy the full SHA
    15df92f View commit details

Commits on Oct 29, 2019

  1. Copy the full SHA
    8a0a25a View commit details

Commits on Dec 17, 2019

  1. docs(readme): fix typo (#818)

    frederickfogerty authored and JLHwung committed Dec 17, 2019
    Copy the full SHA
    758d4b5 View commit details

Commits on Jan 30, 2020

  1. Copy the full SHA
    a967311 View commit details
  2. Merge pull request #821 from PatNeedham/docs/contributing-typo

    docs(contributing): fix typo
    nicolo-ribaudo authored Jan 30, 2020
    Copy the full SHA
    8b47312 View commit details

Commits on Feb 21, 2020

  1. Add schema validation (#822)

    * Add `schema-utils`
    
    * Add schema validation
    ogonkov authored Feb 21, 2020
    Copy the full SHA
    5f55638 View commit details
  2. Update src/injectCaller.js

    JLHwung authored Feb 21, 2020
    Copy the full SHA
    1c35731 View commit details

Commits on Feb 26, 2020

  1. Merge pull request #814 from nicolo-ribaudo/tla

    Add supportsTopLevelAwait to caller
    nicolo-ribaudo authored Feb 26, 2020
    Copy the full SHA
    b568420 View commit details

Commits on Feb 28, 2020

  1. feat: expose webpack target via babel caller (#826)

    Co-authored-by: Brian Ng <bng412@gmail.com>
    DylanPiercey and existentialism authored Feb 28, 2020
    Copy the full SHA
    13a8238 View commit details

Commits on Mar 14, 2020

  1. Bump acorn from 6.3.0 to 6.4.1 (#828)

    Bumps [acorn](https://github.com/acornjs/acorn) from 6.3.0 to 6.4.1.
    - [Release notes](https://github.com/acornjs/acorn/releases)
    - [Commits](acornjs/acorn@6.3.0...6.4.1)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Mar 14, 2020
    Copy the full SHA
    ecb2b02 View commit details

Commits on Mar 20, 2020

  1. Copy the full SHA
    0817bb6 View commit details
  2. 8.1.0

    existentialism committed Mar 20, 2020
    Copy the full SHA
    3ff9926 View commit details

Commits on Mar 23, 2020

  1. 1
    Copy the full SHA
    47958ca View commit details
  2. Merge pull request #839 from babel/replace-mkdir-by-make-dir

    chore: replace mkdirp by make-dir@2
    nicolo-ribaudo authored Mar 23, 2020
    Copy the full SHA
    adac459 View commit details

Commits on Jul 16, 2020

  1. Bump lodash from 4.17.15 to 4.17.19 (#859)

    Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
    - [Release notes](https://github.com/lodash/lodash/releases)
    - [Commits](lodash/lodash@4.17.15...4.17.19)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jul 16, 2020
    Copy the full SHA
    85f3310 View commit details

Commits on Jul 30, 2020

  1. Bump elliptic from 6.5.1 to 6.5.3 (#860)

    Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.1 to 6.5.3.
    - [Release notes](https://github.com/indutny/elliptic/releases)
    - [Commits](indutny/elliptic@v6.5.1...v6.5.3)
    
    Signed-off-by: dependabot[bot] <support@github.com>
    
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Jul 30, 2020
    Copy the full SHA
    ade058e View commit details

Commits on Sep 15, 2020

  1. Copy the full SHA
    84486ec View commit details

Commits on Sep 16, 2020

  1. Copy the full SHA
    fd7d3d4 View commit details

Commits on Sep 29, 2020

  1. Add docs for using babel with Webpack (#869)

    Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
    Co-authored-by: Brian Ng <bng412@gmail.com>
    3 people authored Sep 29, 2020
    Copy the full SHA
    57f2a6d View commit details

Commits on Oct 14, 2020

  1. test: apply webpack@5 (#868)

    hiroppy authored Oct 14, 2020
    Copy the full SHA
    a92949a View commit details

Commits on Nov 8, 2020

  1. Copy the full SHA
    b773c17 View commit details
  2. Update Babel (#876)

    nicolo-ribaudo authored Nov 8, 2020
    Copy the full SHA
    989103c View commit details
  3. fix: use async config loading if available (#825)

    Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
    the-spyke and nicolo-ribaudo authored Nov 8, 2020
    Copy the full SHA
    d8cff97 View commit details

Commits on Nov 9, 2020

  1. 2
    Copy the full SHA
    4e9c59f View commit details
  2. Use Yarn 2 (#878)

    nicolo-ribaudo authored Nov 9, 2020
    Copy the full SHA
    144efda View commit details
6 changes: 2 additions & 4 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -3,11 +3,9 @@
"es6": true,
"node": true
},
"extends": ["eslint-config-babel"],
"extends": ["eslint-config-babel", "eslint-config-prettier"],
"plugins": ["prettier"],
"rules": {
"arrow-parens": "off",
"quotes": "off",
"prettier/prettier": ["error", { "trailingComma": "all" }]
"prettier/prettier": "error"
}
}
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## **BEFORE YOU SUBMIT** please read the following:
<!--
If you have a support request or question please submit them to
[StackOverflow](http://stackoverflow.com/questions/tagged/babel) using the tag
[StackOverflow](http://stackoverflow.com/questions/tagged/babeljs) using the tag
`[babel]` or
the [Babel Slack](babeljs.slack.com). Future support requests will be closed.
-->
50 changes: 50 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: babel-loader

on: [push, pull_request]

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "*"
- name: Install dependencies
run: yarn
- name: Lint
run: yarn run lint
test:
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]
node-version: [10.x, 12.x, 14.x, 15.x]
webpack-version: [latest, '4']
include:
- node: 14.x
os: ubuntu-latest
coverage: true
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: yarn
- name: Install webpack ${{ matrix.webpack-version }}
run: yarn add -D webpack@${{ matrix.webpack-version }}
- name: Build babel-loader
run: yarn run build
env:
BABEL_ENV: test
- name: Run tests for webpack version ${{ matrix.webpack-version }}
run: yarn test-only
- name: Submit coverage data to codecov
uses: codecov/codecov-action@v1
if: ${{ matrix.coverage }}
with:
token: ${{ secrets.CODECOV_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -4,3 +4,7 @@ lib
node_modules
npm-debug.log
test/output
.yarn/*
!.yarn/releases
.pnp.*
.vscode
11 changes: 11 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"arrowParens": "avoid",
"trailingComma": "all",
"useTabs": false,
"semi": true,
"singleQuote": false,
"bracketSpacing": true,
"jsxBracketSameLine": false,
"tabWidth": 2,
"printWidth": 80
}
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

55 changes: 55 additions & 0 deletions .yarn/releases/yarn-2.3.3.cjs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarnPath: .yarn/releases/yarn-2.3.3.cjs
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -10,8 +10,8 @@

I'm not too strict with coding styles.

While personally I'm using the [node-style-guide](https://github.com/felixge/node-style-guide), as long you don't to something too weird or fancy, that's probably ok.
While personally I'm using the [node-style-guide](https://github.com/felixge/node-style-guide), as long you don't do something too weird or fancy, that's probably ok.

If, however, you want to ensure that you're following the node style guide, you can use [JSCS](https://github.com/jscs-dev/node-jscs). The rules are already set on the [.jscsrc](https://github.com/babel/babel-loader/blob/master/.jscsrc) file and there's most likely some [package](http://jscs.info/overview.html#friendly-packages) to your editor already.

Documentation, wether in the state of JavaDoc or simple line comments are always welcome.
Documentation, whether in the state of JavaDoc or simple line comments are always welcome.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014-2016 Luís Couto <hello@luiscouto.pt>
Copyright (c) 2014-2019 Luís Couto <hello@luiscouto.pt>

MIT License

82 changes: 63 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -2,8 +2,6 @@
> 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/77y5mk6amwqt0q88/branch/master?svg=true)](https://ci.appveyor.com/project/babel/babel-loader/branch/master)
[![codecov](https://codecov.io/gh/babel/babel-loader/branch/master/graph/badge.svg)](https://codecov.io/gh/babel/babel-loader)

<div align="center">
@@ -29,12 +27,6 @@ This package allows transpiling JavaScript files using [Babel](https://github.co
npm install -D babel-loader @babel/core @babel/preset-env webpack
```

> webpack 4.x | babel-loader 7.x | babel 6.x
```bash
npm install -D babel-loader@7 babel-core babel-preset-env webpack
```

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

webpack documentation: [Loaders](https://webpack.js.org/loaders/)
@@ -74,7 +66,7 @@ module: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env'],
plugins: [require('@babel/plugin-proposal-object-rest-spread')]
plugins: ['@babel/plugin-proposal-object-rest-spread']
}
}
}
@@ -84,15 +76,13 @@ module: {

This loader also supports the following loader-specific option:

* `cacheDirectory`: Default `false`. When set, the given directory will be used to cache the results of the loader. Future webpack builds will attempt to read from the cache to avoid needing to run the potentially expensive Babel recompilation process on each run. If the value is blank (`loader: 'babel-loader?cacheDirectory'`) or `true` (`loader: 'babel-loader?cacheDirectory=true'`), the loader will use the default cache directory in `node_modules/.cache/babel-loader` or fallback to the default OS temporary file directory if no `node_modules` folder could be found in any root directory.
* `cacheDirectory`: Default `false`. When set, the given directory will be used to cache the results of the loader. Future webpack builds will attempt to read from the cache to avoid needing to run the potentially expensive Babel recompilation process on each run. If the value is set to `true` in options (`{cacheDirectory: true}`), the loader will use the default cache directory in `node_modules/.cache/babel-loader` or fallback to the default OS temporary file directory if no `node_modules` folder could be found in any root directory.

* `cacheIdentifier`: Default is a string composed by the `babel-core`'s version, the `babel-loader`'s version, the contents of `.babelrc` file if it exists, and the value of the environment variable `BABEL_ENV` with a fallback to the `NODE_ENV` environment variable. This can be set to a custom value to force cache busting if the identifier changes.
* `cacheIdentifier`: Default is a string composed by the `@babel/core`'s version, the `babel-loader`'s version, the contents of `.babelrc` file if it exists, and the value of the environment variable `BABEL_ENV` with a fallback to the `NODE_ENV` environment variable. This can be set to a custom value to force cache busting if the identifier changes.

* `cacheCompression`: Default `true`. When set, each Babel transform output will be compressed with Gzip. If you want to opt-out of cache compression, set it to `false` -- your project may benefit from this if it transpiles thousands of files.

* `customize`: Default `null`. The path of a module that exports a `custom` callback [like the one that you'd pass to `.custom()`](#customized-loader). Since you already have to make a new file to use this, it is recommended that you instead use `.custom` to create a wrapper loader. Only use this is you _must_ continue using `babel-loader` directly, but still want to customize.

**Note**: The `sourceMap` option is ignored. Instead, source maps are automatically enabled when webpack is configured to use them (via the [`devtool`](https://webpack.js.org/configuration/devtool/#devtool) config option).
* `customize`: Default `null`. The path of a module that exports a `custom` callback [like the one that you'd pass to `.custom()`](#customized-loader). Since you already have to make a new file to use this, it is recommended that you instead use `.custom` to create a wrapper loader. Only use this if you _must_ continue using `babel-loader` directly, but still want to customize.

## Troubleshooting

@@ -110,11 +100,11 @@ Babel uses very small helpers for common functions such as `_extend`. By default

You can instead require the Babel runtime as a separate module to avoid the duplication.

The following configuration disables automatic per-file runtime injection in Babel, requiring `babel-plugin-transform-runtime` instead and making all helper references use it.
The following configuration disables automatic per-file runtime injection in Babel, requiring `@babel/plugin-transform-runtime` instead and making all helper references use it.

See the [docs](https://babeljs.io/docs/plugins/transform-runtime/) for more information.

**NOTE**: You must run `npm install -D @babel/plugin-transform-runtime` to include this in your project and `babel-runtime` itself as a dependency with `npm install @babel/runtime`.
**NOTE**: You must run `npm install -D @babel/plugin-transform-runtime` to include this in your project and `@babel/runtime` itself as a dependency with `npm install @babel/runtime`.

```javascript
rules: [
@@ -136,7 +126,7 @@ rules: [

#### **NOTE**: transform-runtime & custom polyfills (e.g. Promise library)

Since [babel-plugin-transform-runtime](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime) includes a polyfill that includes a custom [regenerator-runtime](https://github.com/facebook/regenerator/blob/master/packages/regenerator-runtime/runtime.js) and [core-js](https://github.com/zloirock/core-js), the following usual shimming method using `webpack.ProvidePlugin` will not work:
Since [@babel/plugin-transform-runtime](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime) includes a polyfill that includes a custom [regenerator-runtime](https://github.com/facebook/regenerator/blob/master/packages/regenerator-runtime/runtime.js) and [core-js](https://github.com/zloirock/core-js), the following usual shimming method using `webpack.ProvidePlugin` will not work:

```javascript
// ...
@@ -192,7 +182,7 @@ If you receive this message, it means that you have the npm package `babel` inst

webpack then tries to load the `babel` package instead of the `babel-loader`.

To fix this, you should uninstall the npm package `babel`, as it is deprecated in Babel v6. (Instead, install `babel-cli` or `babel-core`.)
To fix this, you should uninstall the npm package `babel`, as it is deprecated in Babel v6. (Instead, install `@babel/cli` or `@babel/core`.)
In the case one of your dependencies is installing `babel` and you cannot uninstall it yourself, use the complete name of the loader in the webpack config:
```javascript
{
@@ -201,6 +191,59 @@ In the case one of your dependencies is installing `babel` and you cannot uninst
}
```

### Exclude libraries that should not be transpiled

`core-js` and `webpack/buildin` will cause errors if they are transpiled by Babel.

You will need to exclude them form `babel-loader`.

```js
{
"loader": "babel-loader",
"options": {
"exclude": [
// \\ for Windows, \/ for Mac OS and Linux
/node_modules[\\\/]core-js/,
/node_modules[\\\/]webpack[\\\/]buildin/,
],
"presets": [
"@babel/preset-env"
]
}
}
```

## Customize config based on webpack target

Webpack supports bundling multiple [targets](https://webpack.js.org/concepts/targets/). For cases where you may want different Babel configurations for each target (like `web` _and_ `node`), this loader provides a `target` property via Babel's [caller](https://babeljs.io/docs/en/config-files#apicallercb) API.

For example, to change the environment targets passed to `@babel/preset-env` based on the webpack target:

```javascript
// babel.config.js

module.exports = api => {
return {
plugins: [
"@babel/plugin-proposal-nullish-coalescing-operator",
"@babel/plugin-proposal-optional-chaining"
],
presets: [
[
"@babel/preset-env",
{
useBuiltIns: "entry",
// caller.target will be the same as the target option from webpack
targets: api.caller(caller => caller && caller.target === "node")
? { node: "current" }
: { chrome: "58", ie: "11" }
}
]
]
}
}
```

## Customized Loader

`babel-loader` exposes a loader-builder utility that allows users to add custom handling
@@ -296,4 +339,5 @@ be passed to `babel.transform`.
Given Babel's result object, allow loaders to make additional tweaks to it.


## [License](https://couto.mit-license.org/)
## License
[MIT](https://couto.mit-license.org/)
18 changes: 0 additions & 18 deletions appveyor.yml

This file was deleted.

File renamed without changes.
Loading