[BUG] `rimrafSafe(): …/node_modules/object-assign/index.js` outside of `buildOptions.out` when `optimize.bundle` is on
See original GitHub issueBug Report Quick Checklist
- I am on the latest version of Snowpack & all plugins.
- I use package manager npm (Fill in: npm, yarn, pnpm, etc).
- I run Snowpack on OS Mac (Fill in: Windows, Mac, Linux, etc).
- I run Snowpack on Node.js v14 & v16
Describe the bug
My project depends on single-spa-react. When optimize.bundle
in the Snowpack config is turned on, importing this module produces the following during the build:
[17:06:41] [snowpack] rimrafSafe(): /Users/emccarthy/Developer/snowpack-repro/react-snowpack/node_modules/object-assign/index.js outside of buildOptions.out /Users/emccarthy/Developer/snowpack-repro/react-snowpack/build
To Reproduce
npm init snowpack-app --template @snowpack/app-template-react
npm install
npm install single-spa-react
- Edit
snowpack.config.js
to setoptimize.bundle
totrue
- Edit
index.jsx
to addimport 'single-spa-react'
npm run build
- See error!
Expected behavior
No error. 😄
Anything else?
The single-spa-react
package does a require("react")
in a top-level try
/catch
block. I think this might be triggering esbuild’s importing of the module and bypassing Snowpack’s import, evidenced by the fact that the import is pulling from node_modules
and not _snowpack/pkg
.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:8
- Comments:18
Top Results From Across the Web
No results found
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I have the same-looking issue when using the
framer-motion
library (or, more specifically its@emotion/memoize
dependency). Node v14.2.0.To Reproduce
npx create-snowpack-app new-dir --template @snowpack/app-template-react-typescript
cd new-dir && npm install framer-motion
optimize.bundle
totrue
src/App.tsx
and addimport { motion } from 'framer-motion'
src/App.tsx
and add<motion.div />
on line 19ish to the React Componentnpm run build
Same issue as @adieuadieu with
@emotion/memoize
- any insights on this?