-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Labels
area: @angular-devkit/build-angulardevkit/build-angular:serverfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix
Milestone
Description
🐞 Bug report
What modules are related to this issue?
- aspnetcore-engine
- builders
- common
- express-engine
- hapi-engine
Is this a regression?
Not sure. Reproduced at least since in 10.0.1.
Description
After turning off bundleDependencies, one single app module cannot be resolved: "../../../utils"
.
Exact name and path matter. I feel kind of weird just as I write this...
Following minor changes to the setup magically fix the problem:
- moving the module one level up in dir structure
- renaming it into e.g "util2"
- renaming
utils/index.ts
into e.g.utils/some-file.ts
else and importing from this file directly - importing it from another location (so that relative import path becomes different)
Following changes do not fix the problem though:
- changing from
../../../utils.ts
to../../../utils/index.ts
(which resolves the same, based on node module resolution rules) - change import path from
../../../utils
to../../../utils/index.ts
🔬 Minimal Reproduction
- Create a fresh angular 10 project, add universal as per the docs
- Add
"bundleDependencies": false
to the server builder options - Create "app/utils.ts" put an empty class inside and export it
// app/utils.ts
export class Utils {}
- Create a component nested 3 levels down from
app
, declare it in AppModule - in this component, import the class and try to instantiate it right away (or try to inject into the component, if it was declared as injectable):
// app/feature1/components/test/test.component.ts
import {Component} from "@angular/core";
import {Utils} from "../../../utils";
const utils = new Utils();
@Component({template: ""})
export class TestComponent {}
We end up with the following dir structure:
app/
- feature1/
- components/
- test/
- test.component.ts
utils.ts
- Ok, we're done. Now run
npm run dev:ssr
🔥 Exception or Error
Error: Cannot find module '../../../utils'
Require stack:
- /Users/amakhrov/Projects/angular-utils-test/dist/angular-utils-test/server/main.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
at Function.Module._load (internal/modules/cjs/loader.js:527:27)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.../../../utils (/Users/amakhrov/Projects/angular-utils-test/dist/angular-utils-test/server/main.js:96:18)
at __webpack_require__ (/Users/amakhrov/Projects/angular-utils-test/dist/angular-utils-test/server/main.js:20:30)
at Module../src/app/feature1/components/test/test.component.ts (/Users/amakhrov/Projects/angular-utils-test/dist/angular-utils-test/server/main.js:653:64)
at __webpack_require__ (/Users/amakhrov/Projects/angular-utils-test/dist/angular-utils-test/server/main.js:20:30)
at Module../src/app/app.module.ts (/Users/amakhrov/Projects/angular-utils-test/dist/angular-utils-test/server/main.js:561:98)
at __webpack_require__ (/Users/amakhrov/Projects/angular-utils-test/dist/angular-utils-test/server/main.js:20:30)
🌍 Your Environment
Angular CLI: 10.0.5
Node: 12.4.0
OS: darwin x64
Angular: 10.0.8
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, platform-server
... router
Ivy Workspace: Yes
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.1000.4
@angular-devkit/build-angular 0.1000.5
@angular-devkit/build-optimizer 0.1000.5
@angular-devkit/build-webpack 0.1000.5
@angular-devkit/core 10.0.4
@angular-devkit/schematics 10.0.5
@angular/cli 10.0.5
@ngtools/webpack 10.0.5
@nguniversal/builders 10.0.1
@nguniversal/common 10.0.1
@nguniversal/express-engine 10.0.1
@schematics/angular 10.0.5
@schematics/update 0.1000.5
rxjs 6.5.5
typescript 3.9.7
webpack 4.43.0
Metadata
Metadata
Assignees
Labels
area: @angular-devkit/build-angulardevkit/build-angular:serverfreq1: lowOnly reported by a handful of users who observe it rarelyOnly reported by a handful of users who observe it rarelyseverity3: brokentype: bug/fix