Esm: Mixing commonjs and es6 work in 3.2.20 but not in 3.2.22

Created on 30 Mar 2019  路  6Comments  路  Source: standard-things/esm

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)
bug needs tests

Most helpful comment

Hi @aldarund!

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

All 6 comments

Hi @aldarund!

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

@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 ? :)

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!

@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

Hi @aldarund!

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Mensu picture Mensu  路  3Comments

tunnckoCore picture tunnckoCore  路  3Comments

kherock picture kherock  路  3Comments

mAAdhaTTah picture mAAdhaTTah  路  3Comments

deepsweet picture deepsweet  路  3Comments