unbuild
unbuild copied to clipboard
Feature request : watch mode ?
Though it might be possible to use nodemon to achieve this, it would still be nice to have a watch mode built-in unbuild.
Hi @lewebsimple. Instead, I would suggest you try passive watcher using unbuild stub :)
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)
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.
Hi @flybayer. This seems an issue with jiti. Do you have a reproduction I can check with?
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.
some, custom write auth plugin vue and used unbuild but problem

@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.
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