GithubHelp home page GithubHelp logo

Comments (7)

JoostK avatar JoostK commented on July 20, 2024 1

Ah, thanks, I see now. The problem originates here:

/**
* Insert the `statements` at the top of the `program`, below any import statements.
*/
function insertIntoProgram(program: NodePath<t.Program>, statements: t.Statement[]): void {
const body = program.get('body');
const importStatements = body.filter((statement) => statement.isImportDeclaration());
if (importStatements.length === 0) {
program.unshiftContainer('body', statements);
} else {
importStatements[importStatements.length - 1].insertAfter(statements);
}
}

from angular.

bgotink avatar bgotink commented on July 20, 2024 1

@JoostK That patch fixes everything, thanks!

from angular.

JoostK avatar JoostK commented on July 20, 2024

This was the reason for the esbuild usage revert in ng-packagr, so I'd advise to update to not run into this problem. If esbuild is reintroduced into ng-packgr we'll look into why this happens and how it can be resolved.

from angular.

bgotink avatar bgotink commented on July 20, 2024

We're not using ng-packagr, we've got our own library builder, where we switched to esbuild earlier and we now have to revert because of this same issue.

from angular.

JoostK avatar JoostK commented on July 20, 2024

Could you please share (parts of) the library output that is consumed in the app?

from angular.

bgotink avatar bgotink commented on July 20, 2024

Dummy library passed through our pipeline: repro.zip

Here's the FESM file, where I added a comment showing where the constants are inserted
// dist/@something/redacted/esm2022/my-test.component.js
import { ChangeDetectionStrategy, Component } from "@angular/core";
import * as i0 from "@angular/core";
var MyTest = class _MyTest {
  static {
    this.\u0275fac = i0.\u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: _MyTest, deps: [], target: i0.\u0275\u0275FactoryTarget.Component });
  }
  static {
    this.\u0275cmp = i0.\u0275\u0275ngDeclareComponent({ minVersion: "14.0.0", version: "18.0.2", type: _MyTest, isStandalone: true, selector: "my-test", ngImport: i0, template: `
    <h1><ng-content select="[title]"></ng-content></h1>
    <ng-content></ng-content>
  `, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush });
  }
};
i0.\u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i0, type: MyTest, decorators: [{
  type: Component,
  args: [{
    standalone: true,
    selector: "my-test",
    template: `
    <h1><ng-content select="[title]"></ng-content></h1>
    <ng-content></ng-content>
  `,
    changeDetection: ChangeDetectionStrategy.OnPush
  }]
}] });

// dist/@something/redacted/esm2022/test.module.js
import { NgModule } from "@angular/core";
import * as i02 from "@angular/core";
// <<---- This is where the `const _cX` variables are inserted
var TestModule = class _TestModule {
  static {
    this.\u0275fac = i02.\u0275\u0275ngDeclareFactory({ minVersion: "12.0.0", version: "18.0.2", ngImport: i02, type: _TestModule, deps: [], target: i02.\u0275\u0275FactoryTarget.NgModule });
  }
  static {
    this.\u0275mod = i02.\u0275\u0275ngDeclareNgModule({ minVersion: "14.0.0", version: "18.0.2", ngImport: i02, type: _TestModule, imports: [MyTest], exports: [MyTest] });
  }
  static {
    this.\u0275inj = i02.\u0275\u0275ngDeclareInjector({ minVersion: "12.0.0", version: "18.0.2", ngImport: i02, type: _TestModule });
  }
};
i02.\u0275\u0275ngDeclareClassMetadata({ minVersion: "12.0.0", version: "18.0.2", ngImport: i02, type: TestModule, decorators: [{
  type: NgModule,
  args: [{
    imports: [MyTest],
    exports: [MyTest]
  }]
}] });
export {
  MyTest,
  TestModule
};

from angular.

JoostK avatar JoostK commented on July 20, 2024

@bgotink perhaps you could patch in #56431 locally to see if that resolves the issue you're having.

from angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.