snowpack: [BUG] `rimrafSafe(): …/node_modules/object-assign/index.js` outside of `buildOptions.out` when `optimize.bundle` is on
Bug 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-reactnpm installnpm install single-spa-react- Edit
snowpack.config.jsto setoptimize.bundletotrue - Edit
index.jsxto 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.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 8
- Comments: 18
I have the same-looking issue when using the
framer-motionlibrary (or, more specifically its@emotion/memoizedependency). Node v14.2.0.To Reproduce
npx create-snowpack-app new-dir --template @snowpack/app-template-react-typescriptcd new-dir && npm install framer-motionoptimize.bundletotruesrc/App.tsxand addimport { motion } from 'framer-motion'src/App.tsxand add<motion.div />on line 19ish to the React Componentnpm run buildSame issue as @adieuadieu with
@emotion/memoize- any insights on this?Any workaround? or potential fix due date? Thank you.
As others have mentioned, I am also using
framer-motionand am running into the same error when building for production. The optimize settings in my config file are:You can find the all the options in the plugin docs: https://github.com/withastro/snowpack/tree/main/plugins/plugin-webpack#readme
As an example, I have something simple like this in the Snowpack config: