Skip to content

Error: Module build failed: [object Object] #53678

Closed

Description

@crutchcorn

Which @angular/* package(s) are the source of the bug?

core

Is this a regression?

Yes

Description

When passing a number in a component:

import "zone.js";
import { bootstrapApplication } from "@angular/platform-browser";

import { Component, Input } from "@angular/core";

@Component({
	selector: "display-size",
	standalone: true,
	template: `<p>Test</p>`,
})
class DisplaySizeComponent {
	@Input() bytes!: number;
}

@Component({
	selector: "app-root",
	standalone: true,
	imports: [DisplaySizeComponent],
	template: `
		<display-size [bytes]="123" />
	`,
})
export class AppComponent {}

bootstrapApplication(AppComponent);

It seems to throw an [object Object] error

Please provide a link to a minimal reproduction of the bug

https://stackblitz.com/github/crutchcorn/angular-object-object-bug?file=src%2Fmain.ts&template=node

Please provide the exception or error you saw

Build at: 2023-12-21T17:46:12.035Z - Hash: cc1a53dd72abbe97 - Time: 3228ms

./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: [object Object]

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 17.0.7
Node: 18.18.0
Package Manager: npm 9.4.2
OS: linux x64

Angular: 17.0.8
... animations, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1700.7
@angular-devkit/build-angular   17.0.7
@angular-devkit/core            17.0.7
@angular-devkit/schematics      17.0.7
@angular/cli                    17.0.7
@schematics/angular             17.0.7
rxjs                            7.8.1
typescript                      5.2.2
zone.js                         0.14.2

Anything else?

I sincerely apologize if I'm doing something wrong. I'm working with a lot of frameworks at the moment so it's possible I'm using a wrong syntax or something. I promise I double and triple checked

Activity

  1. JoostK commented on Dec 21, 2023

    @JoostK
    Member

    This is super weird.

    With the application builder (using vite/esbuild) I see the following:

    ✘ [ERROR] function setExternalModuleIndicator(sourceFile) {
        sourceFile.externalModuleIndicator = isFileProbablyExternalModule(sourceFile);
      } could not be cloned. [plugin angular-compiler]
    
      This error came from the "onStart" callback registered here:
    
        node_modules/@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js:94:18:
          94 │             build.onStart(async () => {
             ╵                   ~~~~~~~
    
        at setup (/home/projects/node-4ksdju/test/node_modules/@angular-devkit/build-angular/src/tools/esbuild/angular/compiler-plugin.js:94:19)
        at async handlePlugins (/home/projects/node-4ksdju/test/node_modules/esbuild/lib/main.js:1330:9)

    with browser (using webpack) it's indeed only

    <e> [webpack-dev-middleware] Error: [object Object]
    <e>     at  (<anonymous>)
    

    In one incremental rebuild (using webpack) I got the following, revealing the root cause:

    ./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
    Error: [object Object]
    
    Error: src/main2.ngtypecheck.ts:1:1 - error NG3004: Unable to import symbol DisplaySizeComponent.
      The symbol is not exported from /home/projects/github-hkszdx/src/main2.ts.
    

    That is still buggy though, as errors should never be reported in .ngtypecheck.ts files. I can't easily reproduce the above behavior.

    Exporting the component does avoid the issues, both in webpack as well as vite.

  2. ilirbeqirii commented on Dec 22, 2023

    @ilirbeqirii
    Contributor

    This issue will go away the moment you export DisplaySizeComponent too.

  3. crutchcorn commented on Dec 25, 2023

    @crutchcorn
    ContributorAuthor

    Interestingly, removing export from AppComponent also appears to solve this. I'm not sure I understand why in either case.

  4. added
    area: core
    on Jan 17, 2024
  5. added this to the needsTriage milestone on Jan 17, 2024
  6. devversion commented on Feb 7, 2024

    @devversion
    Member

    This should be fixed now with #54309

  7. angular-automatic-lock-bot commented on Mar 9, 2024

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  8. locked and limited conversation to collaborators on Mar 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: corestate: needs more investigation

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions