--dest doesn't work properly
See original GitHub issueDo you want to request a feature or report a bug? Bug
What is the current behaviour?
When I try to build for other destination using --dest
, it throws an unrelated error which is only resolved I use --no-prerender
along with it.
If the current behaviour is a bug, please provide the steps to reproduce.
preact build --dest ../public/build
What is the expected behaviour?
The expected behaviour is that it should build, as it build with just preact build
If this is a feature request, what is motivation or use case for changing the behaviour?
Please mention other relevant information.
A sneakpeak of the Error
Error: Cannot find module 'preact'
Require stack:
- /Users/debdut/Code/Projects/blogletter/public/build/ssr-build/ssr-bundle.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/lib/webpack/prerender.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/lib/webpack/render-html-plugin.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/lib/webpack/webpack-client-config.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/lib/webpack/run-webpack.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/commands/build.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/commands/index.js
- /Users/debdut/Code/Projects/blogletter/blogletter.news/node_modules/preact-cli/lib/index.js
method: HteQ
at: /Users/debdut/Code/Projects/blogletter/blogletter.news/src/assets/images/browser-dark.png:1:41
This could be caused by using DOM or Web APIs.
Pre-render runs in node and has no access to globals available in browsers.
Consider wrapping code producing error in: 'if (typeof window !== "undefined") { ... }'
Alternatively use 'preact build --no-prerender' to disable prerendering.
This error seems irrelevant since I’m not using any Browser API such as window
or document
that will come in the way of prerender. Plus it builds perfectly if I don’t set the --dest
Please paste the results of preact info
here.
Environment Info:
System:
OS: macOS 11.0
CPU: (12) x64 Intel(R) Core(TM) i9-8950HK CPU @ 2.90GHz
Binaries:
Node: 12.14.1 - ~/.nvm/versions/node/v12.14.1/bin/node
Yarn: 1.22.5 - /usr/local/bin/yarn
npm: 6.14.8 - ~/.nvm/versions/node/v12.14.1/bin/npm
Browsers:
Chrome: 83.0.4103.97
Safari: 14.0.1
npmPackages:
preact: ^10.3.2 => 10.5.5
preact-cli: ^3.0.0 => 3.0.3
preact-render-to-string: ^5.1.4 => 5.1.10
preact-router: ^3.2.1 => 3.2.1
npmGlobalPackages:
preact-cli: 3.0.3
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
Hm, might not be as simple as I assumed.
Seems to be that the issue is here, we ultimately can not require the
ssr-bundle.js
when that module’s own require statements cannot be resolved (as there is nopreact
package that can be resolved from../public/build
). I’ll play with this some more, but leaving a comment in case I need to leave this for a while.Going to close this out as a “won’t fix” as this is standard behavior in Node.