What is the extent of Vite's CJS-ESM interoperability? #19104
-
Hello, I'm looking at #19036 and wondering if there's anything smaller that I should report, maybe to an upstream project like Rollup, regarding CommonJS interoperability. For example I noticed that when using module.exports = {
foo: require('./foo'),
} The const foo = require('./foo')
module.exports = { foo } the Also, any usage of Is there some way to know the exact extent and the limitations of Vite's interoperability with CommonJS? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I guess it's because module.exports = {
foo: foo && require('./foo'), // this is conditional require
bar: foo ? require('./foo') : false, // this is conditional require
}
const throw = () => { throw '' }
module.exports = {
foo: (throw(), require('./foo')), // this is conditional require
}
Linking my comment here for reference: #19036 (comment)
I think there aren't any currently. For build, Vite uses |
Beta Was this translation helpful? Give feedback.
I guess it's because
@rollup/plugin-commonjs
does not support that case.That case is difficult to determine whether it runs always:
Linking my comment here for reference: #19036 (comm…