Static GitHub Issues

[3090] Error with babel when webpack compilation.

prev: Question/Feature: Critical CSS when extract CSS flag is true on Nuxt Generate
next: npm run build error

Hi! I've a problem with babel during webpack compilation. A file shared by node and webpack works well on node, but throw a warning 21:19-32 "export 'clientMapping' was not found in '~/config/user' and then a TypeError: Cannot assign to read only property 'exports' of object '#<Object>' when showing the page.

I've seen that it works when bypassing babel when importing this file, but it's not a proper solution because I need babel inside it. I also tried to replace clientMapping by a plain object, and it works.

Do you see a problem in it or is it a bug?

Thanks for you help.

// ~/config/user.js

const userMapping = {
    foo: 'bar',
};

// Also tried Object.assign without success.
const clientMapping = {
    ...userMapping,
    baz: 'test',
};

// This config file is called both by node and by webpack. It's why I use `module.exports`.
module.exports = {
    userMapping,
    clientMapping,
};
// ~/models/Client.js

import {clientMapping} from '~/config/user'
...
// ~/plugins/authClient.js

import Client from '~/models/Client';
...
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2675">#c2675</a>)</em></sub></div>