question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New Asset Modules type: asset/null, to properly replace null-loader

See original GitHub issue

Feature request

New asset module type: asset/null, to properly replace the now deprecated null-loader

What is the expected behavior?

    rules: [
      ...
      {
        test: /\.css$/,
        type: 'asset/null'
      }
    ]

To replace the use of the now deprecated null-loader in situations analogous to the following

    rules: [
      ...
      {
        test: /\.css$/,
        use: [
          { loader: "null-loader" }
        ]
      }
    ]

That is: to tell webpack to ignore a module but, instead of based on a name, to ignore a module based on a rule.

What is motivation or use case for adding/changing the behavior?

The documented way to replace the use of null-loader

Setting resolve.alias.package to false will tell webpack@5 to ignore a module.

does not correctly replace the deprecated loader.

In particular, it does not allow webpack to prevent modules from being imported based on a rule, which was one the uses for null-loader.

Using resolve.alias also implies that the name of the modules to be ignored are known when creating the webpack config, which is not always true or even possible.

How should this be implemented in your opinion?

With the creation of a new type for asset modules: asset/null.

The change is also consistent with how the other deprecated modules were dealt with

  • asset/resource replaced file-loader
  • asset/inline replaced url-loader
  • asset/source replaced raw-loader

With this proposal asset/null would replace null-loader

Are you willing to work on this yourself?

Yes, if directed to the appropriate parts of the code

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ferdinando-ferreiracommented, Mar 18, 2021

I think we need this option

Thanks! I can submit a PR for it if you guys want.

0reactions
alexander-akaitcommented, Mar 18, 2021

Ideally we should not run plugin, just create locals and return them

Read more comments on GitHub >

github_iconTop Results From Across the Web

null-loader - webpack - JS.ORG
A webpack loader that returns an empty module. One use for this loader is to silence modules imported by a dependency. Say, for...
Read more >
Webpack 5 and null-loader-esque functionality - Stack Overflow
I've tried IgnorePlugin , but that simply prevents the module from being added to the bundle but keeps the import, which breaks in...
Read more >
Diff - platform/test/suite_harness - android Git repositories
diff --git a/build/Android.bp b/build/Android.bp new file mode 100644 index ... creates an empty module for the tradefed_binary module type, +// which is a ......
Read more >
webpack-contrib/null-loader - GitHub
null -loader. A webpack loader that returns an empty module. One use for this loader is to silence modules imported by a dependency....
Read more >
Webpack 5: Asset Modules - Medium
In this article I want to write about three famous loaders and a new interesting feature in Webpack5. Prior to Webpack5 it was...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found