When using @stoplightio/elements with Vite.js it is not possible to build the because of the unmaintained @jsdevtools/ono. I figured it should be replaced by a more fitting alternative.
Current Behavior
When building elements with vite, I get the error can't convert undefined to object coming from these lines in "@jsdevtools/ono" bundles:
// CommonJS default export hack
if (typeof module === "object" && typeof module.exports === "object") {
module.exports = Object.assign(module.exports.default, module.exports);
}
Expected Behavior
Use a maintained repository from error handling
Possible Workaround/Solution
Only solution is to replace this dependency by an empty one in Vite config but that could cause some issues... As I described here
Steps to Reproduce
- Create a vite App from scratch
- Install @stoplight/elements to the project
- Add
nodePolyfills with plugin vite-plugin-node-polyfills
- Add
commonjsOptions: { transformMixedEsModules: true } build option
- Install
prismjs and add import 'prismjs'; at the top of main.tsx
- Try running
npm run build or yarn build
Environment
Latest version of elements with @stoplight/json-schema-ref-parser@"^9.2.7"
When using @stoplightio/elements with Vite.js it is not possible to build the because of the unmaintained
@jsdevtools/ono. I figured it should be replaced by a more fitting alternative.Current Behavior
When building elements with vite, I get the error
can't convert undefined to objectcoming from these lines in "@jsdevtools/ono" bundles:Expected Behavior
Use a maintained repository from error handling
Possible Workaround/Solution
Only solution is to replace this dependency by an empty one in Vite config but that could cause some issues... As I described here
Steps to Reproduce
nodePolyfillswith pluginvite-plugin-node-polyfillscommonjsOptions: { transformMixedEsModules: true }build optionprismjsand addimport 'prismjs';at the top of main.tsxnpm run buildoryarn buildEnvironment
Latest version of elements with
@stoplight/json-schema-ref-parser@"^9.2.7"