rspack icon indicating copy to clipboard operation
rspack copied to clipboard

[Feature]: Support native ESM loader

Open colinaaa opened this issue 1 year ago • 4 comments

What problem does this feature solve?

This allows using a native ESM loader loader.js with "type": "module" in package.json (which webpack supports, see: https://github.com/webpack/webpack/tree/main/test/cases/loaders/_esm-loader-type).

Use case

I'm developing a rspack plugin with loader and "type": "module" in package.json. I have to run cp lib/loader.js lib/loader.mjs after every build to make it work with rspack. And the tsc --watch I used to build the whole project cannot do that for me(it also does not support output .mjs files).

What does the proposed API of configuration look like?

// loader.js
/** @type {import('webpack').LoaderDefinitionFunction} */
export default function loader() {
  return /** content */
}

Pitching loader:

// loader.js
/** @type {import('webpack').PitchLoaderDefinitionFunction} */
export const pitch = function() {
  return /** content */
}

colinaaa avatar Feb 21 '24 08:02 colinaaa

This is on our roadmap. Stay tuned ;-) You may use .mjs wrapper for now.

h-a-n-a avatar Feb 22 '24 06:02 h-a-n-a

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

stale[bot] avatar Apr 22 '24 07:04 stale[bot]

@h-a-n-a is it fixed now?

hardfist avatar Apr 22 '24 08:04 hardfist

@h-a-n-a is it fixed now?

Not yet supported

h-a-n-a avatar Apr 22 '24 08:04 h-a-n-a