Open steveninety opened 1 year ago
Hmm.
dom-serializer
exports render
both as named function and default:
exports.render = render;
exports.default = render;
export function render ...
export default render;
Why SvelteKit / Vite can't understand it?
The requested module 'dom-serializer' is a CommonJS module
Why?
Both html-to-text
version 9 and dom-serializer
provide both CJS and ESM versions.
Yes it's strange. Will patch it for now, but need to look into it further.
My main guess: Whatever web bundler is used underneath - is not capable enough and falls back to CommonJS for entire dependency subtree once it sees a single CJS package. (There were related issues with Webpack before.)
Proper solutions could be:
In case of html-to-text
, there is one remaining - deepmerge
.
deepmerge
situation is not great. I should've just written my own package when I had time, as I did with many other things.
There are now
I will choose something when I'm able to resume working on next major version.
Problem
import { render } from "dom-serializer"
The dom-serializer package specifies
export default render
, so importing{ render }
does not work.Occurs where Error on build in a SvelteKit / Vite / ESM project.
Imported in: packages/base/src/generic-formatters.js
Error message
import { render } from "dom-serializer"; ^^^^^^ SyntaxError: Named export 'render' not found. The requested module 'dom-serializer' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using:
import pkg from 'dom-serializer'; const { render } = pkg;
Fix
import render from "dom-serializer"
Will open a pull request.