Skip to content

Commit

Permalink
node_modules is no longer compiled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeNiemiec committed Jun 8, 2020
1 parent 6779013 commit 6e3905b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@

**Please note that Webpacker 4.1.0 has an installer bug. Please use 4.2.0 or above**

## [[6.0.0]](https://github.com/rails/webpacker/compare/v5.1.1...v6.0.0) - 2020-TBD

- `node_modules` will no longer be compiled by default. This primarily fixes [rails issue #35501](https://github.com/rails/rails/issues/35501) as well as [numerous other webpacker issues](https://github.com/rails/webpacker/issues/2131#issuecomment-581618497). The disabled loader can still be required explicitly via:
```js
const nodeModules = require('@rails/webpacker/rules/node_modules.js')
environment.loaders.append('nodeModules', nodeModules)
```
- If you have added `environment.loaders.delete('nodeModules')` to your `environment.js`, this must be removed or you will receive an error (`Item nodeModules not found`).

## [[5.1.1]](https://github.com/rails/webpacker/compare/v5.1.0...v5.1.1) - 2020-04-20

- Update [TypeScript documentation](https://github.com/rails/webpacker/blob/master/docs/typescript.md) and installer to use babel-loader for typescript.[(#2541](https://github.com/rails/webpacker/pull/2541)
Expand Down
7 changes: 4 additions & 3 deletions package/environments/__tests__/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ describe('Environment', () => {
const defaultRules = Object.keys(rules)
const configRules = config.module.rules

expect(defaultRules.length).toEqual(7)
expect(configRules.length).toEqual(8)
expect(defaultRules.length).toEqual(6)
expect(configRules.length).toEqual(7)
})

test('should return cache path for nodeModules rule', () => {
const nodeModulesLoader = rules.nodeModules.use.find(rule => rule.loader === 'babel-loader')
const nodeModulesRule = require('../../rules/node_modules')
const nodeModulesLoader = nodeModulesRule.use.find(rule => rule.loader === 'babel-loader')

expect(nodeModulesLoader.options.cacheDirectory).toBeTruthy()
})
Expand Down
2 changes: 0 additions & 2 deletions package/rules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const css = require('./css')
const sass = require('./sass')
const moduleCss = require('./module.css')
const moduleSass = require('./module.sass')
const nodeModules = require('./node_modules')

// Webpack loaders are processed in reverse order
// https://webpack.js.org/concepts/loaders/#loader-features
Expand All @@ -15,6 +14,5 @@ module.exports = {
sass,
moduleCss,
moduleSass,
nodeModules,
babel
}

0 comments on commit 6e3905b

Please sign in to comment.