Description
Creating a reproducible case for this will be hard, mostly documenting this here in case others come across the problem.
I'm using pragmatic drag and drop in a Svelte 4 project -- it's working great, thanks so much for releasing it.
Drag and drop works great in the "regular" Svelte/SvelteKit app.
I'm also using Svelte to compile the component into a W3C Web Component.
When I do this with code that includes some of the PDND libraries, e.g. @atlaskit/pragmatic-drag-and-drop/element/adapter
:
- things compile fine, but
- at runtime I see the error
process is not defined
(see screenshot below).
Tracing things back, I see many references to process.env.NODE_ENV
(e.g. in packages/core/src/util/is-safari.ts ).
I'm not sure why the client code is referencing process.env
-- there's probably something hinky in the build chain -- but I didn't write the Svelte/Vite build chain, so I'm not sure how to fix it.
Ways I've found to fix the problem:
- Commenting out all code which references PDND. :-(
- Updating my
vite.config
to make sure thatprocess.env.NODE_ENV
is defined, e.g.
export default defineConfig({
define: {
"process.env.NODE_ENV": '"production"'
}, ...
})
It would be nice if the PDND codebase didn't assume that process
or process.env
was defined to avoid the error/need for a workaround.
thanks