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

feat: support inline loader #2867

Merged
merged 9 commits into from
Apr 23, 2023
Merged

feat: support inline loader #2867

merged 9 commits into from
Apr 23, 2023

Conversation

h-a-n-a
Copy link
Contributor

@h-a-n-a h-a-n-a commented Apr 21, 2023

Related issue (if exists)

closes #1752
closes #2386

Summary

This PR adds support of inline-loader. Now you can inline loader requests:

// Prefixing with ! will disable all configured normal loaders
require("!postcss-loader!less-loader!./style.css")

// Prefixing with !! will disable all configured loaders (preLoaders, loaders, postLoaders)
require("!!postcss-loader!less-loader!./style.css")

// Prefixing with -! will disable all configured preLoaders and loaders but not postLoaders
require("-!postcss-loader!less-loader!./style.css")

See webpack's inline loader page for more details: https://webpack.js.org/concepts/loaders/#inline

🤖 Generated by Copilot at e152250

This pull request adds support for inline loaders in the rspack compiler and node binding. It simplifies the RawModule enum and re-exports the JsLoaderAdapter type. It introduces a resolver_factory to enable parallel module resolution and different resolver types. It adds new hooks and types to the plugin API and the PluginDriver. It implements an InlineLoaderResolver plugin that can resolve and run JavaScript loaders. It moves some node-specific modules from the rspack_core crate to the node_binding crate. It removes some unused or commented-out code.

Walkthrough

🤖 Generated by Copilot at e152250

  • Add a new plugin InlineLoaderResolver that can resolve inline loaders in module requests (link, link, link, link, link, link)
  • Move the loader_runner and process_resource modules from the rspack_core crate to the node_binding crate, as they are specific to the node binding crate (link)
  • Add a resolver_factory field to the Queue, CompilationArgs, and NormalModuleFactory structs, which is used to create different kinds of Resolvers for different dependency types and categories (link, link, link, link, link, link)
  • Modify the create method of the NormalModuleFactory struct to parse and resolve the inline loaders from the module request, and to skip the automatic loaders based on the ! prefix (link, link, link, link)
  • Add a new hook before_loaders to the Plugin trait and the PluginDriver struct, which allows plugins to modify modules before the loaders are applied (link, link, link, link, link, link)
  • Remove the JsLoaderAdapter type from the RawModule enum, as it is no longer a valid variant (link)
  • Remove a commented-out field func from the JsLoaderAdapter struct, as it is no longer needed (link)
  • Remove a commented-out type alias VisitedModuleIdentity from the rspack_core crate, as it is no longer used (link)

@changeset-bot
Copy link

changeset-bot bot commented Apr 21, 2023

🦋 Changeset detected

Latest commit: 6f5c68c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 17 packages
Name Type
@rspack/binding Patch
@rspack/postcss-loader Patch
@rspack/core Patch
webpack-test Patch
@rspack/cli Patch
@rspack/dev-middleware Patch
@rspack/dev-server Patch
@rspack/plugin-html Patch
benchmarkcase-rspack-react-refresh Patch
@rspack/dev-client Patch
@rspack/plugin-minify Patch
@rspack/plugin-node-polyfill Patch
@rspack/binding-darwin-arm64 Patch
@rspack/binding-darwin-x64 Patch
@rspack/binding-linux-x64-gnu Patch
@rspack/binding-win32-x64-msvc Patch
@rspack/fs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@h-a-n-a h-a-n-a force-pushed the feat/inline-loader branch from d37240a to 068ead6 Compare April 23, 2023 11:14
@h-a-n-a h-a-n-a marked this pull request as ready for review April 23, 2023 11:16
@h-a-n-a h-a-n-a requested review from hardfist and hyf0 as code owners April 23, 2023 11:16
@h-a-n-a h-a-n-a requested a review from ahabhgk April 23, 2023 11:16
hyf0
hyf0 previously approved these changes Apr 23, 2023
Copy link
Contributor

@hyf0 hyf0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool.

@h-a-n-a h-a-n-a added this pull request to the merge queue Apr 23, 2023
Merged via the queue into main with commit 61d6e5d Apr 23, 2023
@h-a-n-a h-a-n-a deleted the feat/inline-loader branch April 23, 2023 13:36
@github-actions github-actions bot mentioned this pull request Apr 25, 2023
siyou pushed a commit to siyou/rspack that referenced this pull request May 14, 2023
* feat: init inline loader

* chore: cleanup

* fix: resolve context

* refactor: rename resolve loader hook

* test: use inline for pre post test

* feat: user request should contain inline loaders as well

* chore: cleanup

* feat: add cgst

* fix: fix wasm dependency
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: support inline-loader and loader query Full support for inline loader syntax
2 participants