Closed benmccann closed 3 years ago
Thanks for reaching out @benmccann!
It's also worth noting the Vite is planning to fix this so it would work by default https://github.com/vitejs/vite/issues/3024#issue-860269204 and there is a work around available today without needing to change packages https://github.com/vitejs/vite/issues/3024#issuecomment-860018367
This can be fixed by distributing an ESM version of
is-buffer
andextend
I'm happy to see improvements in unified's dependencies. :+1:
Thanks for opening feross/is-buffer#43!
Would you be interested in opening a pull request to extend
as well?
by removing those dependencies from this library since they have minimal usage
I'm happy to change unified's dependencies, if there are security, performance, or stability benefits. :+1:
I'm cautious changing dependencies only for the sake of working around a short term bug in a particular tool chain. As more packages adopt ESM, module format bugs in several tool chains have been uncovered (most outlined with workarounds in: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)
We definitely want to offer a path for folks to upgrade across a variety of tool chains. Baking workarounds into unified long term to address short term bugs in particular build tools, doesn't feel like an appropriate or sustainable approach. For short term problems, where upstream fixes are not immediately possible, documentation/guides feel more appropriate.
Happy to discuss dependency changes or help with documentation!
@ChristianMurphy , @benmccann ... I've opened this PR to help out: https://github.com/justmoon/node-extend/pull/57
All dependencies should be ESM since this package declares "type": "module". The package should work out-of-the-box with SvelteKit and Vite
No, I disagree. type: module
is a Node.js thing. Node allows CJS dependencies. If your bundler supports type: module
, then it should also allow CJS dependencies.
Of course: hopefully in the future we can ditch CJS! But Vite is broken. Not unified.
As Christian mentioned, we can discuss how to teach folks how to use Vite with npm and unified, but I’m closing this because it’s not actionable.
Hi! This was closed. Team: If this was fixed, please add phase/solved
. Otherwise, please add one of the no/*
labels.
Hi team! Could you describe why this has been marked as external?
Thanks, — bb
For short term problems, where upstream fixes are not immediately possible, documentation/guides feel more appropriate. ... we can discuss how to teach folks how to use Vite with npm and unified, but I’m closing this because it’s not actionable.
This would be helpful, I can't get unified to work in the SSR part of SvelteKit (Vite-based): I get __vite_ssr_import_2__.unified is not a function
When I have:
vite: {
optimizeDeps: {
include: ['unified'],
},
},
I get module is not defined
at ...is-buffer...
Initial checklist
Affected packages and versions
all
Link to runnable example
No response
Steps to reproduce
Provided in https://github.com/sveltejs/kit/issues/1961
Expected behavior
All dependencies should be ESM since this package declares
"type": "module"
. The package should work out-of-the-box with SvelteKit and ViteThis can be fixed by distributing an ESM version of
is-buffer
andextend
or by removing those dependencies from this library since they have minimal usage. I've sent a PR foris-buffer
https://github.com/feross/is-buffer/pull/43 though I don't know yet whether it will be acceptedThis could be added a sub-task to https://github.com/unifiedjs/unified/issues/121
Actual behavior
Vite encounters CJS dependency of this ESM module and fails with the message
module is not defined
as described in https://github.com/vitejs/vite-plugin-react/issues/30Runtime
Node v14, Other (please specify in steps to reproduce)
Package manager
npm v7
OS
Linux
Build and bundle tools
Vite