just-jeb / angular-builders

Angular build facade extensions (Jest and custom webpack configuration)
MIT License
1.14k stars 198 forks source link

ENOENT: no such file or directory, realpath #1730

Open muuvmuuv opened 7 months ago

muuvmuuv commented 7 months ago

Describe the Bug

Angular with latest TypeScript semver range supports direct import.

An unhandled exception occurred: ENOENT: no such file or directory, realpath '/Users/marvin/Developer/M8FINDER/M8FINDER/.angular/vite-root/app'
See "/private/var/folders/nb/bwd6_n3d3y583d365z6mcb200000gn/T/ng-Q5hK1L/angular-errors.log" for further details.

https://github.com/just-jeb/angular-builders/blob/master/packages/common/src/load-module.ts#L84-L87

Must be changed to:

return import(modulePath).then((module) => module.default);

Minimal Reproduction

Note: Our policy is that issues reported without a reproduction will be closed immediately and then reopened once a reproduction has been provided. Please respect the developers of this project by doing this. We give of our personal time to work on this project and would rather be spending our time fixing or enhancing the library than chasing down badly described or unreproducible issues. Please delete this note once you have read it.

Expected Behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment


Libs
- @angular/core version: 17.3.2
- @angular-devkit/build-angular version: 17.3.2
- @angular-builders/custom-esbuild version: 17.1.1

For Tooling issues:
- Bun version: 1.0.35
- Platform:  Mac

Others:

Additional Context

Add any other context about the problem here.

just-jeb commented 6 months ago

Do you know what's the minimal requirement for Angular/TS here @muuvmuuv ? Trying to figure out if we can release such a change in a minor version without breaking everyone.

muuvmuuv commented 6 months ago

I already tried to but its hard to say. We would need tests for that to check against lower semver ranges. But since it no longer works on my end between these and the previous version I would say this is the range.

muuvmuuv commented 5 months ago

Would it make sense to grab that here after v18 release since TS version is now high enough?

just-jeb commented 5 months ago

Absolutely, I'd say if anything it must be part of v18 release (since as part of breaking changes we can require minimal TS version). Do you think you'd have time to make a PR with this change into v18 PR?

muuvmuuv commented 5 months ago

Yeah ofc. But I don't think I can write tests for that, Jest is kinda picky with mixed import syntax so it wont be ez.. maybe a custom test suite in shell-script with tsc?

muuvmuuv commented 5 months ago

Just something I discovered developing in angular-builders is that "@lerna-lite/run" is missing in order to do something like: yarn lerna run --scope @angular-builders/common test OR how do you execute scripts inside a package?

just-jeb commented 5 months ago

maybe a custom test suite in shell-script with tsc? Yeah, e2e test are probably the way to go. We already have custom shell scripts for e2e tests, for example this one for custom-webpack builder or this one for the Jest builder.

I think that the existing e2e tests for builders will implicitly cover the change (coz they depend on @angular-builders/common and use loadModule) but feel free to add more and/or add a proprietary ci shell script for common.

how do you execute scripts inside a package

We use yarn workspaces foreach for multiple packages or yarn workspace for a single package (like here). In most cases this should be enough.

muuvmuuv commented 5 months ago

Ok, this requires way more work, it does work in my szenario because my repo has type=module and other stuff set to newer settings, but it does not in here because a lot still requires cjs syntaxes. I guess every example and package must first be updated to be esm only or something like that but idk if that even works with Angular. I tried setting stuff to type=module but that comes with another error "Unknown file extension ".ts" and so on ^^

just-jeb commented 5 months ago

Just to make it clear: is it a bug or an enhancement? We have examples with both csj and esm which are working for custom-webpack and custom-esbuild builders.

muuvmuuv commented 5 months ago

I remember that it was indeed a bug when I initially opened the issue but it seem to be disappeared at some point. Maybe TS had an update fixing it. Might check that out when v18 is out and look in detail.