bili
bili copied to clipboard
Uncaught TypeError: Cannot add property async, object is not extensible
I keep getting Uncaught TypeError: Cannot add property async, object is not extensible
when trying to pack my library with bili.
I hope I'm using the settings correctly. I'm trying to get my library to export a ES6 file and a normal and minified version of the file for browsers. I'm using yarn bili --format cjs,es,umd,umd-min --nodeResolve.preferBuiltins
to bundle the files.
I'm using --nodeResolve.preferBuiltins
as I use Buffer in my library and that fixes the issue of it not being mocked for the browser.
what's the actual code you're bundling? a minimal repo will help
Hmm I don't get the error Uncaught TypeError: Cannot add property async, object is not extensible
after removed the async
plugin (which transforms async to generator which buble can't transform), just a bunch of warnings:
$ bili --moduleName Medusa --format cjs,es,umd,umd-min
⏳ Bundling 223 files: commonjs-proxy:/Users/egoist/dev/temp/medusa-lib/node_modules/qs/lib/parse.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳ Bundling 228 files: node_modules/iconv-lite/lib/index.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳ Bundling 231 files: node_modules/iconv-lite/encodings/internal.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳ Bundling 232 files: commonjs-external:buffer
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳ Bundling 232 files: commonjs-external:buffer
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable thi⏳ Bundling 233 files: commonjs-external:string_decoder
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable thi⏳ Bundling 233 files: commonjs-external:string_decoder
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'string_decoder' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/string_decoder/lib/string_decoder.js', pass 'preferBuiltins: false' to disable thi⏳ Bundling 234 files: node_modules/iconv-lite/encodings/utf16.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳ Bundling 235 files: node_modules/iconv-lite/encodings/utf7.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳ Bundling 236 files: node_modules/iconv-lite/encodings/sbcs-codec.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳ Bundling 239 files: node_modules/iconv-lite/encodings/dbcs-codec.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳ Bundling 265 files: node_modules/iconv-lite/lib/streams.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳ Bundling 267 files: node_modules/iconv-lite/lib/extend-node.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⏳ Bundling 314 files: commonjs-proxy:/Users/egoist/dev/temp/medusa-lib/node_modules/qs/lib/index.js
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning
preferring built-in module 'buffer' over local alternative at '/Users/egoist/dev/temp/medusa-lib/node_modules/buffer/index.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins⚠️ Using named and default exports together. Consumers of your bundle will have to use Medusa['default'] to access the default export, which may not be what you want. Use `exports: 'named'` to disable this warning
⚠️ Creating a browser bundle that depends on Node.js built-in modules ('buffer', 'url', 'http', 'https', 'zlib', 'stream', 'string_decoder', 'util' and 'tty'). You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins
⚠️ No name was provided for external module 'buffer' in options.globals – guessing 'require$$0'
⚠️ No name was provided for external module 'url' in options.globals – guessing 'require$$0$1'
⚠️ No name was provided for external module 'http' in options.globals – guessing 'http'
⚠️ No name was provided for external module 'https' in options.globals – guessing 'https'
⚠️ No name was provided for external module 'zlib' in options.globals – guessing 'zlib'
⚠️ No name was provided for external module 'stream' in options.globals – guessing 'require$$1'
⚠️ No name was provided for external module 'string_decoder' in options.globals – guessing 'require$$1$1'
⚠️ No name was provided for external module 'util' in options.globals – guessing 'util'
⚠️ No name was provided for external module 'tty' in options.globals – guessing 'tty'
⚠️ Using named and default exports together. Consumers of your bundle will have to use Medusa['default'] to access the default export, which may not be what you want. Use `exports: 'named'` to disable this warning
⚠️ Creating a browser bundle that depends on Node.js built-in modules ('buffer', 'url', 'http', 'https', 'zlib', 'stream', 'string_decoder', 'util' and 'tty'). You might need to include https://www.npmjs.com/package/rollup-plugin-node-builtins
⚠️ No name was provided for external module 'buffer' in options.globals – guessing 'require$$0'
⚠️ No name was provided for external module 'url' in options.globals – guessing 'require$$0$1'
⚠️ No name was provided for external module 'http' in options.globals – guessing 'http'
⚠️ No name was provided for external module 'https' in options.globals – guessing 'https'
⚠️ No name was provided for external module 'zlib' in options.globals – guessing 'zlib'
⚠️ No name was provided for external module 'stream' in options.globals – guessing 'require$$1'
⚠️ No name was provided for external module 'string_decoder' in options.globals – guessing 'require$$1$1'
⚠️ No name was provided for external module 'util' in options.globals – guessing 'util'
⚠️ No name was provided for external module 'tty' in options.globals – guessing 'tty'
✨ Built in 18.67s.
┌────────────────────────────────────────────┐
│file size gzip size│
│dist/medusa-lib.cjs.js 301 B 149 B │
│dist/medusa-lib.es.js 286 B 138 B │
│dist/medusa-lib.js 978.81 KB 320.74 KB│
│dist/medusa-lib.min.js 308.91 KB 211.05 KB│
└────────────────────────────────────────────┘
✨ Done in 19.59s.
btw I should find a way to reduce duplicated warnings 😄
I get it while using the dist/medusa-lib.min.js
or dist/medusa-lib.js
file in my browser. Sorry I should have mentioned that.
I was hoping they'd be browser ready without any other config.
Hmm I'm only getting Cannot read property 'Buffer' of undefined
when using medusa-lib.js
in browser
Ah you missed the ending to that command. --nodeResolve.preferBuiltins
.
Should I not be using that? One of my deps is what relies on Buffer
so I don't exactly what to add it as a dep when my lib isn't using it directly.
@OmgImAlexis i do try that too, doesn't work either
Any suggestions on how to get it bundling? I'm just trying to get a file I can include in a browser environment without needing babel.
@OmgImAlexis no idea until I get home 😄 you should also use es modules
I need to be able to use ES5 since the project I'm working on is still using ES5 as it hasn't been migrated over to use Vue and Poi yet.
@egoist any chance you could look at this when you're not busy?
hmm I can't really reproduce this, maybe a minimal repo? I mean without unrelated code.