standard-things / esm

Tomorrow's ECMAScript modules today!
Other
5.27k stars 147 forks source link

properties will be discarded after object.assign #813

Open pi0 opened 5 years ago

pi0 commented 5 years ago

probably related to #773, #776 where users try to mix CJS with ESM syntax.

options.js

import fs from 'fs'

module.exports = {}

main.js

const esm = require('esm')(module)
const options = esm('./options.js')

options.dev = true
console.log(options.dev) // true

const b = Object.assign({}, options)
console.log(b.dev) // undefined

Side note: This bug only happens when options.js is in mixed mode. not happening when it is pure ESM or pure CJS.