Skip to content

Conversation

@mitranim
Copy link

  • don't try to load missing babelrc (false check was too narrow)
  • don't swallow non-FS errors when checking if file exists

* don't try to load missing babelrc (`false` check was too narrow)
* don't swallow non-FS errors when checking if file exists
const loaderOptions = loaderUtils.getOptions(this) || {};
const fileSystem = this.fs ? this.fs : fs;
let babelrcPath = null;
if (loaderOptions.babelrc !== false) {
Copy link
Member

Choose a reason for hiding this comment

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

That completely changes the behaviour for when not setting babelrc option.

@danez
Copy link
Member

danez commented Jul 25, 2017

Can you describe what problem you actually try to resolve?

@mitranim
Copy link
Author

The problematic scenario is very basic, I'm surprised other people don't complain.

  • [email protected] + [email protected]
  • .babelrc in project root
  • rudimentary webpack config with use: {loader: 'babel-loader'} and no plugin options
  • run webpack --watch, touch a file → webpack blows up and dies

Specifically: babel-loader attempts to check for existence of babelrc with the undefined name (not a string, just undefined), passing it to Webpack's virtual filesystem, which assumes that the file name is a string and produces a synchronous exception.

Checking for false is naive. By default, most users won't specify a babelrc location, meaning the option is undefined. The change accommodates the most common use case while keeping the same general logic.

@zythum
Copy link

zythum commented Jul 27, 2017

because enhanced-resolve updated api. if exist
path is undefined will threw error webpack/enhanced-resolve#100

@danez
Copy link
Member

danez commented Jul 29, 2017

Merged in #495

@danez danez closed this Jul 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants