NativeScript / nativescript-dev-webpack

A package to help with webpacking NativeScript apps.
Apache License 2.0
97 stars 49 forks source link

Babel integration is not complete #1043

Open SamShekhovtsov opened 4 years ago

SamShekhovtsov commented 4 years ago

Environment

Describe the bug The Babel integration is not complete, it's not possible to use ES6 for webpack.config.js file. In case, if I do webpack.config.babel.js with ES6, the tns build android command returns error, however webpack --dev.android runs successfully.

To Reproduce create sample Nativescript 6.x application. Execute $ tns install babel, rename webpack.config.js to webpack.config.babel.js use ES6 javascript for the configuration file. Try to execute $ tns build android.

Expected behavior the project builds successfully, webpack.config.babel.js is automatically engaged.

DimitarTachev commented 4 years ago

Hi @SamShekhovtsov,

The Babel integration in NativeScript is handle in nativescript-dev-babel. This plugin is using the afterPrepare CLI hook (after the Webpack compilation) and processing only the output of the Webpack compilation. It's not meant to be able to process prepare configuration files like the webpack.config.babel.js.

Regarding the tns build error, NativeScript CLI does not support Webpack configuration file names different than webpack.config.js. You can find it hardcoded in its WebpackCompilerService. If the Webpack process will be able to handle ES6 code when we pass the .babel file, you could log an issue or open a PR in the CLI allowing such flow.