|
// CommonJS default export hack |
|
if (typeof module === "object" && typeof module.exports === "object") { |
|
module.exports = Object.assign(module.exports.default, module.exports); |
|
} |
This code block is bombing my rollup build. Not caught during build. This code makes it into the bundle, and then it fails on runtime startup. module.exports.default is undefined and is killing the build.
/path-to-my-build/node_modules/@jsdevtools/ono/esm/index.js:12
module.exports = Object.assign(module.exports.default, module.exports);
^
TypeError: Cannot convert undefined or null to object
I found this by preserving the modules from Rollup so I could get a good stacktrace to the code.
// my rollup
import commonjs from '@rollup/plugin-commonjs'
import nodeResolve from '@rollup/plugin-node-resolve'
import json from '@rollup/plugin-json'
export default {
input: 'src/service.js',
output: {
// file: 'dist/service.js',
dir: 'dist/',
format: 'cjs',
sourcemap: 'inline',
preserveModules: true
},
plugins: [
nodeResolve({ preferBuiltins: true }),
commonjs({
dynamicRequireTargets: ['node_modules/nconf/lib/nconf/stores/*.js']
}),
json()
]
}
I found if i do this it makes it past this part:
if (typeof module === "object" && typeof module.exports === "object") {
module.exports.default = module.exports.default || {}
module.exports = Object.assign(module.exports.default, module.exports);
}
ono/src/index.ts
Lines 10 to 13 in a1fa89a
This code block is bombing my rollup build. Not caught during build. This code makes it into the bundle, and then it fails on runtime startup.
module.exports.defaultis undefined and is killing the build.I found this by preserving the modules from Rollup so I could get a good stacktrace to the code.
I found if i do this it makes it past this part: