Home

Issue: 3090

Error with babel when webpack compilation.

[issue link]

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';
...
This question is available on Nuxt.js community (#c2675)