Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define, webpack transforms and esbuild plugins are not supported in v19 Karma Buillder #29003

Open
1 task done
chihab opened this issue Dec 1, 2024 · 1 comment
Open
1 task done

Comments

@chihab
Copy link

chihab commented Dec 1, 2024

Command

test

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

v18

Description

There is no way to pass in webpack transforms or esbuild plugins or define to the internal Angular builders used in Karma.

Browser builder

When using webpack (browser) builder, webpack transforms are ignored:
https://github.com/angular/angular-cli/blob/main/packages/angular_devkit/build_angular/src/builders/karma/browser_builder.ts#L37

I guess they should be passed in as a third parameter to initializeBrowser

as it used to be passed in in v18 here https://github.com/angular/angular-cli/blob/18.2.x/packages/angular_devkit/build_angular/src/builders/karma/index.ts#L87

Application builder

When using the newly supported esbuild builder in Karma, esbuild plugins and define are not supported
Define option is not supported in Karma builder (neither exposed in the builder schema nor in the builder api)
https://github.com/angular/angular-cli/blob/main/packages/angular_devkit/build_angular/src/builders/karma/application_builder.ts#L354

Regarding the application builder, I am not sure whether it is a feature request or a bug as the application builder support is new.

Question: why are we using an internal builder with a closed configuration rather than using the one defined in angular.json by the user?

Minimal Reproduction

Browser builder

return executeKarmaBuilder(options, context, {
  webpackConfiguration: (webpackConfig) => {
    console.log("webpackConfig", webpackConfig);
    return webpackConfig;
  },
});

Application builder

"test": {
  "builder": "@angular-devkit/build-angular:karma",
  "options": {
    "polyfills": ["zone.js", "zone.js/testing"],
    "tsConfig": "tsconfig.spec.json",
    "assets": [
      {
        "glob": "**/*",
        "input": "public"
      }
    ],
    "define": {
      "ENV_MESSAGE": "'Hello from Angular 19'"
    },
    "styles": ["src/styles.css"],
    "scripts": []
  }
}
> [email protected] test
> ng test

Error: Schema validation failed with the following errors:
  Data path "" must NOT have additional properties(define).

Your Environment

Angular CLI: 19.0.0
Node: 20.13.1
Package Manager: npm 10.8.2
OS: darwin arm64

Angular: 19.0.0
... animations, build, cli, common, compiler, compiler-cli, core
... forms, localize, platform-browser, platform-browser-dynamic
... platform-server, router, ssr

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1900.0
@angular-devkit/build-angular   19.0.0
@angular-devkit/core            19.0.0
@angular-devkit/schematics      19.0.0
@schematics/angular             19.0.0
rxjs                            7.8.1
typescript                      5.6.3
zone.js                         0.15.0
@chihab chihab changed the title Define, webpack transforms and esbuild plugins are not supported in v19 Define, webpack transforms and esbuild plugins are not supported in v19 Karma Buillder Dec 1, 2024
@jkrems jkrems self-assigned this Dec 4, 2024
@jkrems
Copy link
Contributor

jkrems commented Dec 5, 2024

Thanks! Clearly broke during the refactor and there was no test to catch it. I have a fix for the regression (webpack config). Once that lands, this likely turns into a duplicate of #28809 which is also about the lack of esbuild config options in the Karma builder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants