unbuild icon indicating copy to clipboard operation
unbuild copied to clipboard

Feature request : watch mode ?

Open lewebsimple opened this issue 3 years ago • 6 comments

Though it might be possible to use nodemon to achieve this, it would still be nice to have a watch mode built-in unbuild.

lewebsimple avatar Oct 31 '21 18:10 lewebsimple

Hi @lewebsimple. Instead, I would suggest you try passive watcher using unbuild stub :)

pi0 avatar Nov 02 '21 10:11 pi0

Thanks for the tip, I'm loving unbuild so much !!!

The problem with unbuild stub is that Nuxt3 can't find the plugin injected with addPluginTemplate in dev mode as it resolves the runtime in src/ and not dist/.

Should I add environment detection and conditionally set the runtime directory or is there a more transparent way ?

My project repository for reference: https://github.com/lewebsimple/nuxt3-graphql (I'm putting together a suite of modules for GraphQL along with some example starters)

lewebsimple avatar Nov 03 '21 01:11 lewebsimple

It seems unbuild --stub is not compatible with nextjs builds, even when using next-transpile-modules

> [email protected] build /Users/b/c/blitz2/apps/web
> next build

info  - Checking validity of types
info  - Creating an optimized production build
Failed to compile.

../../node_modules/.pnpm/[email protected]/node_modules/jiti/dist/babel.js
Module not found: Can't resolve 'fs' in '/Users/b/c/blitz2/node_modules/.pnpm/[email protected]/node_modules/jiti/dist'

Import trace for requested module:
../../node_modules/.pnpm/[email protected]/node_modules/jiti/lib/index.js
../../packages/blitz/dist/index-browser.tsx.mjs
./pages/index.tsx

../../node_modules/.pnpm/[email protected]/node_modules/jiti/dist/babel.js
Module not found: Can't resolve 'module' in '/Users/b/c/blitz2/node_modules/.pnpm/[email protected]/node_modules/jiti/dist'

Import trace for requested module:
../../node_modules/.pnpm/[email protected]/node_modules/jiti/lib/index.js
../../packages/blitz/dist/index-browser.tsx.mjs
./pages/index.tsx

../../node_modules/.pnpm/[email protected]/node_modules/jiti/dist/babel.js
Module not found: Can't resolve 'v8' in '/Users/b/c/blitz2/node_modules/.pnpm/[email protected]/node_modules/jiti/dist'

Import trace for requested module:
../../node_modules/.pnpm/[email protected]/node_modules/jiti/lib/index.js
../../packages/blitz/dist/index-browser.tsx.mjs
./pages/index.tsx

../../node_modules/.pnpm/[email protected]/node_modules/jiti/dist/jiti.js
Module not found: Can't resolve 'fs' in '/Users/b/c/blitz2/node_modules/.pnpm/[email protected]/node_modules/jiti/dist'

Import trace for requested module:
../../node_modules/.pnpm/[email protected]/node_modules/jiti/lib/index.js
../../packages/blitz/dist/index-browser.tsx.mjs
./pages/index.tsx

../../node_modules/.pnpm/[email protected]/node_modules/jiti/dist/jiti.js
Module not found: Can't resolve 'module' in '/Users/b/c/blitz2/node_modules/.pnpm/[email protected]/node_modules/jiti/dist'

Import trace for requested module:
../../node_modules/.pnpm/[email protected]/node_modules/jiti/lib/index.js
../../packages/blitz/dist/index-browser.tsx.mjs
./pages/index.tsx


> Build failed because of webpack errors
 ELIFECYCLE  Command failed with exit code 1.

flybayer avatar Jan 15 '22 18:01 flybayer

Hi @flybayer. This seems an issue with jiti. Do you have a reproduction I can check with?

pi0 avatar Jan 17 '22 10:01 pi0

I am also really enjoying unbuild! Unfortunately I am having similar issues when trying to consume stubbed packages with esbuild targeting browsers. When targeting node, it resolves to the source files and can't resolve the exports.

And when trying to consume a stubbed package from nuxt 3 it can't find the package.

TorbjornHoltmon avatar Feb 08 '22 14:02 TorbjornHoltmon

some, custom write auth plugin vue and used unbuild but problem

image

productdevbook avatar Apr 21 '22 11:04 productdevbook

@flybayer I went pretty deep on this because I really love the stub approach in monorepos, but I'm not sure how feasible it would ever be to get working with client-side stuff. This comment has a summary of my findings, but I'd be happy to discuss further. Here's the Preconstruct hook that does work with Next.js, but it only works with CJS.

jrolfs avatar Feb 08 '23 23:02 jrolfs

Hi! Sorry for later response on this. I have made a new tracker issue to possibly support atice watchers: https://github.com/unjs/unbuild/issues/281

pi0 avatar Jul 18 '23 16:07 pi0