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]: Options for inline loaders #9457

Open
dinofx opened this issue Feb 25, 2025 · 2 comments
Open

[Feature]: Options for inline loaders #9457

dinofx opened this issue Feb 25, 2025 · 2 comments
Labels
pending triage The issue/PR is currently untouched.

Comments

@dinofx
Copy link

dinofx commented Feb 25, 2025

What problem does this feature solve?

A "regular" loader can be passed options via module rules. For example:

rules:
    {
      test: [/\.tsx?$/, /\.js$/],
      loader: require.resolve('./my-loader'),
      options: {
        foo: 'bar',
      },
    },

But for an inline loader, there seems to be only one way to pass "options", and it involves polluting the LoaderContext namespace used by every loader. Example config:

{
  loader: {
    foo: 'bar'
  },}

The above "loader" config property does not scale well. Eventually two loaders will use the same loader property name, but define it to mean different things.

What does the proposed API of configuration look like?

Proposed:

resolveLoader: {
  alias: {
    'my-inline-loader': {
      loader: require.resolve('./my-inline-loader'),
      options: {
        foo: 'bar'
      }
    }
  }
}
@dinofx dinofx added the pending triage The issue/PR is currently untouched. label Feb 25, 2025
@h-a-n-a
Copy link
Contributor

h-a-n-a commented Mar 3, 2025

Would you please try webpack to see if they support this?

@dinofx
Copy link
Author

dinofx commented Mar 3, 2025

As far as I know webpack has a similar limitation, but webpack hasn't had a major release since 2020.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pending triage The issue/PR is currently untouched.
Projects
None yet
Development

No branches or pull requests

2 participants