Open Prophet32j opened 1 year ago
Running into the same issue — as a not-so-great workaround, I used the @rollup/plugin-replace
plugin to fix up that patch of code with the changes in https://github.com/JS-DevTools/ono/pull/20 and I'm no longer seeing runtime errors:
import commonjs from '@rollup/plugin-commonjs';
import json from '@rollup/plugin-json';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import { defineConfig } from 'rollup';
export default defineConfig({
input: 'input.js',
output: { file: 'output.cjs', format: 'cjs' },
plugins: [
commonjs(),
json(),
nodeResolve({ preferBuiltins: true }),
replace({
delimiters: ['', ''],
preventAssignment: true,
values: {
'if (typeof module === "object" && typeof module.exports === "object") {':
'if (typeof module === "object" && typeof module.exports === "object" && typeof module.exports.default === "object") {',
},
}),
],
});
https://github.com/JS-DevTools/ono/blob/a1fa89a25e7432f7615af8b4179f842b5affccf2/src/index.ts#L10-L13
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.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: