Do you want to request a _feature_ or report a _bug_?
What is the current behaviour? build fails
If the current behaviour is a bug, please provide the steps to reproduce.
What is the expected behaviour? - successful build
If this is a feature request, what is motivation or use case for changing the behaviour?
'preact watch' is working fine without any issues.
$ preact build
Build [=================== ] 93% (21.1s) after chunk asset optimization[2021-01-25T20:26:35.879Z] @firebase/app:
Warning: This is a browser-targeted Firebase bundle but it appears it is being
run in a Node environment. If running in a Node environment, make sure you
are using the bundle specified by the "main" field in package.json.
If you are using Webpack, you can specify "main" as the first item in
"resolve.mainFields":
https://webpack.js.org/configuration/resolve/#resolvemainfields
If using Rollup, use the @rollup/plugin-node-resolve plugin and specify "main"
as the first item in "mainFields", e.g. ['main', 'module'].
https://github.com/rollup/@rollup/plugin-node-resolve
Build [=================== ] 95% (22.1s) emitting
bundle..esm.js ⏤ 91.8 kB (+15 B)
polyfills..esm.js ⏤ 2.18 kB (+3 B)
sw.js ⏤ 8.47 kB
sw-esm.js ⏤ 8.47 kB
polyfills.03bf6.js ⏤ 0 B (-2.17 kB)
index.html ⏤ 116 B
200.html ⏤ 1.02 kB
assets/css/bootstrap.min.css ⏤ 22.4 kB
assets/js/bootstrap.bundle.min.js ⏤ 22 kB
bundle.31c81.css ⏤ 11.8 kB
bundle.1b2fe.js ⏤ 0 B (-92.4 kB)
bundle.13a0e.js ⏤ 92.4 kB (+92.4 kB)
polyfills.11b7f.js ⏤ 2.18 kB (+2.18 kB)
× ERROR Template execution failed: Error: The XMLHttpRequest compatibility library was not found.
Please mention other relevant information.
Please paste the results of preact info here.
$ preact info
Environment Info:
System:
OS: Windows 10 10.0.18363
CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
Binaries:
Node: 12.14.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Chrome: 87.0.4280.141
Edge: Spartan (44.18362.449.0)
npmPackages:
preact: ^10.3.2 => 10.5.11
preact-cli: ^3.0.0 => 3.0.5
preact-render-to-string: ^5.1.4 => 5.1.12
preact-router: ^3.2.1 => 3.2.1
Try disabling prerendering with --no-prerender. We prerender your application in Node, so you need to ensure everything will work outside of the browser.
@rschristian Thanks a lot. Worked.
Glad to hear it. Now that you know the issue, what you can do is wrap the offending code in window checks, i.e., if (typeof window !== "undefined") { ... }. This way you can still get all the benefits of prerendering, while skipping the bits that won't work in Node environments.
awesome :) thanks