babel / babel-loader

📦 Babel loader for webpack
MIT License
4.82k stars 449 forks source link

Unable to transpile ES6 class with Babel7 WebPack4 on Windows #810

Open ricoudev opened 4 years ago

ricoudev commented 4 years ago

Hello, I'm submitting a bug report. I spent several hours but nothing seems to work. The issue here is related when babel trying to transpile some ES6 Javascript Class files, on windows environement. Babel Loader doesn't seem to find the mandatory plugin "@babel/plugin-proposal-class-properties" on Windows.

The compiling error says : Module build failed (from ./node_modules/babel-loader/lib/index.js): SyntaxError: C:\WTServer\WWW\webpack-issue\src\js\components\ScrollControl.js: Support for the experimental syntax 'classProperties' isn't currently enabled (5:11):

But actually, Babel is not able to interpret any JS Class file, and probably because no loader was initialized correctly

I've also try to follow the guideline by using with Babel7 the dedicated file "babel.config.js" but this file is never loaded. In webpack.config.js, I have the correct declaration with Babel (I've just used it with the "require" syntax to make sure with Windows that files are correctly loaded".

The same projet work successfully on Linux (Ubuntu 16.04 LTS), it seems to related to Windows Env only.

Webpack Version: 4.29

Babel Core Version: 7.4

Babel Loader Version: 8.0.5

Please tell us about your environment: Windows 10

Current behavior: Transpiling failed

Expected/desired behavior: Working Transpiling

How to reproduce the bug To help to reproduce the current issue I'm facing of, I've set a dedicated githup repo. You just need to install modules by typing "npm install" and then the following command "npm run watch-dev"

Repo : https://github.com/ricoudev/webpack-issue

JLHwung commented 4 years ago

Looking into the repo, doesn't babel.config.js_ should be renamed to babel.config.js?

eric-dev-nm commented 4 years ago

Looking into the repo, doesn't babel.config.js_ should be renamed to babel.config.js?

Actually, I'm glad you asked. You can try to rename it (without any undescore before) but, for unknown reason, the file won't be loaded on Windows 10 environment. I don't understand why because this is part of the recommandation for Babel7. That's why, I've directly set the options settings inside the package.config.js to make sure.

ricoudev commented 4 years ago

Hi, any updates on this issue?