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

Mixing commonjs and es6 work in 3.2.20 but not in 3.2.22 #773

Closed
aldarund opened this issue Mar 30, 2019 · 6 comments
Closed

Mixing commonjs and es6 work in 3.2.20 but not in 3.2.22 #773

aldarund opened this issue Mar 30, 2019 · 6 comments

Comments

@aldarund
Copy link

aldarund commented Mar 30, 2019

main test script to launch

const esm = require('esm')
const path = require('path')

const esmOptions = {
  cache: false,
  cjs: {
    cache: true,
    vars: true,
    namedExports: true
  }
}

const nuxtConfigFile = require.resolve(path.resolve('nuxt.config.js'))
const options = esm(module, esmOptions)(nuxtConfigFile)

console.log(options)

nuxt.config.js

import path from 'path';

module.exports = {
  mode: "universal"
};

In 3.2.20 code work, in 3.2.22 its broken

ReferenceError: mode is not defined
    at Function.keys (<anonymous>)
    at getKeys (internal/util/inspect.js:385:21)
    at formatRaw (internal/util/inspect.js:617:12)
    at formatValue (internal/util/inspect.js:540:10)
    at inspect (internal/util/inspect.js:197:10)
    at Object.formatWithOptions (util.js:84:12)
    at Console.(anonymous function) (internal/console/constructor.js:274:15)
    at Console.log (internal/console/constructor.js:284:61)
    at Object.<anonymous> (d:\bb\te\test.js:13:9)
@jdalton
Copy link
Member

jdalton commented Mar 30, 2019

Hi @aldarund!

Could you create a small repro repo for me to look at?

@aldarund
Copy link
Author

aldarund commented Mar 30, 2019

@jdalton i pasted whole code in the ticket that cause the problem. Thats all, two small scripts to repro problem. There no additional files or code or anything. You want me to create repo with this exact same two files ? :)

@jdalton
Copy link
Member

jdalton commented Mar 30, 2019

Yes please. I've found many times things that folks may think aren't part of the scenario become meaningful. Also it couldn't hurt to specify which version of Node you're running too. Thanks!

@aldarund
Copy link
Author

aldarund commented Mar 30, 2019

@jdalton as you want :) But as i said its that two files. Here it is -> https://codesandbox.io/s/nr779m9rw4
Node 10 there.
Locally same happens on node 11.
And there like 5-10 different users reported this issue on stackoverflow, discord and github repo for nuxt.js.

Depending on what u do later with loaded module the error would be different, but the cause must be same

@jdalton jdalton added invalid and removed invalid labels Mar 30, 2019
@jdalton
Copy link
Member

jdalton commented Mar 30, 2019

Hi @aldarund!

Thank you for the repro. I see now.
I didn't know we supported this, but I patched it anyway 😄

@aldarund
Copy link
Author

aldarund commented Apr 4, 2019

@jdalton thanks :) Any chance to release this in patch release anytime soon ? :)

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

No branches or pull requests

2 participants