Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have the same babel plugins enabled as in Vue CLI #61

Open
davidyuk opened this issue Feb 18, 2021 · 1 comment
Open

Have the same babel plugins enabled as in Vue CLI #61

davidyuk opened this issue Feb 18, 2021 · 1 comment

Comments

@davidyuk
Copy link

Describe the bug
Vue CLI has a richer set of Babel features than Uvue supports, we have to manually add missed features otherwise server failing with a message:

✔ Client
  Compiled successfully in 21.96s

✖ Server
  Compiled with some errors in 20.21s



 DONE  Compiled successfully in 21970ms                                                                                            5:02:08 PM

 I  Server is running: http://localhost:8080
 I  Type "rs" to restart server
[1613656928782] INFO  (17507 on Deniss-MacBook-Pro.local): Server listening: http://localhost:8080
[1613657140826] ERROR (17507 on Deniss-MacBook-Pro.local): Module parse failed: Unexpected token (392:178)
File was processed with these loaders:
 * ./node_modules/cache-loader/dist/cjs.js
 * ./node_modules/babel-loader/lib/index.js
 * ./node_modules/cache-loader/dist/cjs.js
 * ./node_modules/vue-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|       var _this$tokenInfo$this$;
| 
>       const decimals = ((_this$tokenInfo$this$ = this.tokenInfo[this.data.tokenAddress]) === null || _this$tokenInfo$this$ === void 0 ? void 0 : _this$tokenInfo$this$.decimals) ?? 18;
|       const initialPrice = new BigNumber(aeToAtoms(1)); // currently supports only hardcoded 1AE
| 
    Error: Module parse failed: Unexpected token (392:178)

To Reproduce
Try to run vue-cli-service ssr:serve on a project that uses optional chaining or nullish coalescing.

Expected behavior
To have Babel features enabled in Uvue out of the box, corresponding to the Vue CLI setup.

Additional context
We have to add patches like this one as a workaround.

Please indicate versions of:

node: 14.15.4
vue-cli: 4.2.0
uvue: 0.1.7
os: MacOS 11.2.1
browser: -
@yabab-dev
Copy link
Contributor

Thank for reporting this issue!

Actually your workaround seems the best way to handle it. In fact UVue makes a specific build with Babel for Node environment, and that build do not include these babel plugins automatically

For future users coming, here the workaround, in babel.config.js :

module.exports = {
  presets: [
    '@vue/cli-plugin-babel/preset',
  ],
  plugins: [
    '@babel/plugin-proposal-optional-chaining',
    '@babel/plugin-proposal-nullish-coalescing-operator',
  ],
};

I keep this open in case I find a solution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants