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

Feature request: loader option in new esbuild karma builder #28809

Open
stefankoserkov opened this issue Nov 7, 2024 · 5 comments
Open

Feature request: loader option in new esbuild karma builder #28809

stefankoserkov opened this issue Nov 7, 2024 · 5 comments
Labels
area: @angular-devkit/build-angular devkit/build-angular:karma feature: votes required Feature request which is currently still in the voting phase feature Issue that requests a new feature

Comments

@stefankoserkov
Copy link

stefankoserkov commented Nov 7, 2024

Command

test

Description

The improved builder @angular-devkit/build-angular:karma which uses esbuild is missing the "loader" option. It would be really useful to have the option to require files in tests.

Describe the solution you'd like

"test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": [
              "zone.js",
              "zone.js/testing"
            ],
            "tsConfig": "tsconfig.spec.json",
            "assets": [
              {
                "glob": "**/*",
                "input": "public"
              }
            ],
            "styles": [
              "src/styles.css"
            ],
            "scripts": [],
            "builderMode": "application",
            **"loader": {
              ".html": "text"
            }**
          }
        }

Describe alternatives you've considered

No response

@angular-robot angular-robot bot added the feature: votes required Feature request which is currently still in the voting phase label Nov 7, 2024
Copy link
Contributor

angular-robot bot commented Nov 7, 2024

This feature request is now candidate for our backlog! In the next phase, the community has 60 days to upvote. If the request receives more than 20 upvotes, we'll move it to our consideration list.

You can find more details about the feature request process in our documentation.

@jkrems
Copy link
Contributor

jkrems commented Nov 7, 2024

@stefankoserkov Would it be useful if that option would be used from what's already configured for the prod or dev builder? Or would there be cases where it should only apply to the test runner?

@stefankoserkov
Copy link
Author

@jkrems I'd like it to be an option on the karma builder, to have better separation, but I'll take the other option as well.

If you are interested the case is that .html files will be required in tests to test something relating to iframes, which will not be used in prod/dev builds. But in our particular case I don't foresee side effects of this loader, if left in prod/dev build configs.

Thank you for the fast response!

@jkrems
Copy link
Contributor

jkrems commented Nov 7, 2024

For a limited use in tests, you might also be able to use the import attribute syntax, e.g.:

import myTestHtml from './testdata/test.html' with { loader: 'text' };

If nothing else, this might be a workaround until we can more properly support loader in the Karma setup.

@stefankoserkov
Copy link
Author

I like this workaround it's very cutting edge. However, for enterprise purposes I think it kind of deviates from the Angular path, I don't think we can afford to use module: esnext and declare .html files as modules. For now, I will try to gather votes, and stick to webpack.

Thank you for the suggestion, I learnt something new.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: @angular-devkit/build-angular devkit/build-angular:karma feature: votes required Feature request which is currently still in the voting phase feature Issue that requests a new feature
Projects
None yet
Development

No branches or pull requests

3 participants