Open birkskyum opened 1 year ago
Update: There has been good progress here, due to increased Angular CLI and Nitro support. The server almost start now:
This is the expected:
➜ bun run dev
$ ng serve
The '@analogjs/platform' successfully started.
The server endpoints are accessible under the "/api" path.
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
Angular is running in development mode.
This is the current result:
➜ bun --bun run dev
$ ng serve
The '@analogjs/platform' successfully started.
The server endpoints are accessible under the "/api" path.
error: script "dev" exited with code 11 (SIGSEGV)
Progress here, the server now starts:
➜ bun --bun run dev
$ ng serve
The server endpoints are accessible under the "/api" path.
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
.. But the browser console prints:
chunk-5IIG6E4R.js?v=75eac2fb:6307 Uncaught Error:
The injectable '_PlatformLocation' needs to be compiled using the
JIT compiler, but '@angular/compiler' is not available.
Finds this too:
➜ bun --bun run dev
$ ng serve
The '@analogjs/platform' successfully started.
The server endpoints are accessible under the "/api" path.
[bun] Warning: worker_threads.Worker option "argv" is not implemented.
[bun] Warning: worker_threads.Worker option "execArgv" is not implemented.
[bun] Warning: worker_threads.Worker option "resourceLimits" is not implemented.
➜ Local: http://localhost:5173/
The error is:
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
12:06:04 AM [vite] Error when evaluating SSR module ~analog/entry-server: failed to import "zone.js/node"
|- TypeError: undefined is not an object (evaluating 'proto.hasOwnProperty(name)')
at hasOwnProperty (native)
at patchMethod (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:933:46)
at <anonymous> (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:1515:86)
at <anonymous> (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:115:57)
at <anonymous> (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:1006:52)
at <anonymous> (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:20:16)
at <anonymous> (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:22:4)
at global code (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:1574:8)
at processTicksAndRejections (:55:39)
If I open the browser, I see the html printed out like this:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Error</title>
<script type="module">
import { ErrorOverlay } from '/@vite/client'
document.body.appendChild(new ErrorOverlay({"message":"An error occured while server rendering /index.html:\n\n\tundefined is not an object (evaluating 'proto.hasOwnProperty(name)') ","stack":"TypeError: undefined is not an object (evaluating 'proto.hasOwnProperty(name)')\n at hasOwnProperty (native)\n at patchMethod (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:933:46)\n at \u003canonymous> (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:1515:86)\n at \u003canonymous> (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:115:57)\n at \u003canonymous> (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:1006:52)\n at \u003canonymous> (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:20:16)\n at \u003canonymous> (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:22:4)\n at global code (/Users/admin/repos/analog-project/node_modules/zone.js/bundles/zone-node.umd.js:1574:8)\n at processTicksAndRejections (:55:39)"}))
</script>
</head>
<body>
</body>
</html>
This issue with zone.js is also where I am stuck when using the --bun
option. I tweeted @brandonroberts on this as well though I am almost sure he's seen this thread.
@benpsnyder Yeah but its not a zone.js problem its a bun problem or atleast i believe it should be fixed here instead of having a workaround in angular to make bun a true drop in replacement
It's basically a problem with using hasOwnProperty()
on the globalThis that breaks the bun runtime
For angular-17, the bun --bun run dev
gives this:
⇣7% ➜ bun --bun run dev
$ ng serve
An unhandled exception occurred: Failed to set property with field ``
See "/private/var/folders/8y/htw2q5ss5ms9zy4z8rfv393c0000gn/T/ng-cUsgF8/angular-errors.log" for further details.
error: script "dev" exited with code 127
For angular-16, the bun --bun run dev
gives this:
The server endpoints are accessible under the "/api" path.
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
Failed to resolve entry for package "@analogjs/router". The package may have incorrect main/module/exports specified in its package.json: undefined is not an object (evaluating 'data.browser["."]')
Angular is running in development mode.
Angular is running in development mode.
3:36:48 PM [vite] Internal server error: Failed to resolve entry for package "@analogjs/router". The package may have incorrect main/module/exports specified in its package.json: undefined is not an object (evaluating 'data.browser["."]')
Plugin: vite:import-analysis
File: /Users/admin/repos/bun-kitchensink/analog-project/src/app/app.config.ts:8270:18
at packageEntryFailure (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:28726:40)
at resolvePackageEntry (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:8265:24)
at tryNodeResolve (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:8125:25)
at <anonymous> (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:7955:33)
at processTicksAndRejections (:61:39)
3:36:48 PM [vite] Internal server error: Failed to resolve entry for package "@analogjs/router". The package may have incorrect main/module/exports specified in its package.json: undefined is not an object (evaluating 'data.browser["."]')
Plugin: vite:import-analysis
File: /Users/admin/repos/bun-kitchensink/analog-project/src/app/app.config.ts:8270:18
at packageEntryFailure (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:28726:40)
at resolvePackageEntry (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:8265:24)
at tryNodeResolve (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:8125:25)
at <anonymous> (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:7955:33)
at processTicksAndRejections (:61:39) (x2)
^C
TypeError: client.terminate is not a function. (In 'client.terminate()', 'client.terminate' is undefined)
at <anonymous> (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:61943:27)
at forEach (:1:11)
at <anonymous> (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:22094:28)
at new ZoneAwarePromise (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/zone.js/fesm2015/zone-node.js:1249:31)
at close (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:22093:25)
at <anonymous> (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:22726:17)
at close (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/dist/node/chunks/dep-68d1a114.js:22719:21)
at <anonymous> (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/@analogjs/platform/node_modules/@nx/vite/src/executors/dev-server/dev-server.impl.js:50:25)
at processOnExit (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/@analogjs/platform/node_modules/@nx/vite/src/executors/dev-server/dev-server.impl.js:49:38) {
originalLine: 22095,
originalColumn: 27
}
1105 | command: "rebuild",
1106 | key: buildKey
1107 | };
1108 | sendRequest(refs, request2, (error2, response2) => {
1109 | if (error2) {
1110 | reject(new Error(error2));
^
error: The service was stopped
at /Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/node_modules/esbuild/lib/main.js:1110:28
at /Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/node_modules/esbuild/lib/main.js:703:9
at afterClose (/Users/admin/repos/bun-kitchensink/analog-project/node_modules/vite/node_modules/esbuild/lib/main.js:693:7)
at endReadableNT (node:stream:2387:53)
at processTicksAndRejections (:61:77)
Thanks for keeping updated this thread. I'm trying to migrate from Jest to Vitest using the analog package. Plus using Bun as a runtime in Angular would be a great help to make test run more faster. We have a lot of test suites and Jest takes like 20min to run on our pipelines on Github Actions. On AWS its 10 minutes.
@vicentematus I got bun tests and running angular/ssr on this repo also going zoneless https://github.com/sp90/treaty maybe you can find some resolutions to your challanges
We're still blocked by a few things in a bun to build angular as well using bun which we hope to get through post windows support aka 1.1
@sp90 this looks good. Specially SSR on Angular for heavy enterprises applications + Bun = Speed. Also nice detach from using Zone.js
.
We are on Angular 16 as SPA, but the main blocker is using Jest (and jest-preset-angular) as the testing runner. From what I've read from Jarred twitter is there's some issues with Bun and the CLI of Jest (idk if they fixed it yet).
Maybe an alternative I was thinking was to migrate to Vitest
using the @analog
package and then use Bun
from there. What are your thoughts on that to speed up the test runners?
@sp90 this looks good. Specially SSR on Angular for heavy enterprises applications + Bun = Speed. Also nice detach from using
Zone.js
.We are on Angular 16 as SPA, but the main blocker is using Jest (and jest-preset-angular) as the testing runner. From what I've read from Jarred twitter is there's some issues with Bun and the CLI of Jest (idk if they fixed it yet).
Maybe an alternative I was thinking was to migrate to
Vitest
using the@analog
package and then useBun
from there. What are your thoughts on that to speed up the test runners?
It doesn't really belong in this ticket, but there is also bun test.
getting this (i do not have node 21 installed):
➜ bun --bun run dev
$ ng serve
Node.js version v21.6.0 detected.
Odd numbered Node.js versions will not enter LTS status and should not be used for production. For more information, please see https://nodejs.org/en/about/previous-releases/.
🔍 @nx/nx-darwin-universal [1/1]
error: package "@nx/nx-darwin-universal" not found registry.npmjs.org/@nx%2fnx-darwin-universal 404
An unexpected error occurred: ResolveMessage: Cannot find module "nx/src/utils/code-frames" from "/Users/admin/.bun/install/cache/@nx/js@18.0.8/src/utils/typescript/run-type-check.js"
🔍 Resolving [2/1] error: script "dev" exited with code 1
Getting this now:
➜ bun --bun run dev
$ ng serve
🔍 @nx/nx-darwin-universal [1/1]
error: package "@nx/nx-darwin-universal" not found registry.npmjs.org/@nx%2fnx-darwin-universal 404
NX Failed to parse bun lockfile
Please open an issue at `https://github.com/nrwl/nx/issues/new?template=1-bug.yml` and provide a reproduction.
Original error: FileNotFound while resolving package "@yarnpkg/parsers" from "/Users/admin/.bun/install/cache/nx@19.1.1/src/plugins/js/lock-file/yarn-parser.js"
An unhandled exception occurred: undefined is not an object (evaluating 'error.stack.split')
See "/private/var/folders/8y/htw2q5ss5ms9zy4z8rfv393c0000gn/T/ng-2G4cXQ/angular-errors.log" for further details.
undefined
error: script "dev" exited with code 127
FYI this testing repo is also relevant. https://github.com/benpsnyder/nx-bun-testing
I also put together a repo a while back that builds using the bun runtime
. The exception is that it uses the vite
commands directly instead ng
for serving and building.
Analog GitHub - Website, @brandonroberts
What version of Bun is running?
0.7.0
What platform is your computer?
Darwin 22.5.0 arm64 arm
What steps can reproduce the bug?
bun x create-analog@latest
✔ Project name: … analog-project ✔ Select a template: › Analog ✔ Select a variant: › angular-v16 ✔ Would you like to add Tailwind to your project? … nocd analog-project
bun install
bun run dev
What is the expected behavior?
What do you see instead?
Additional information
Blocked by
4060
4061