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 proxied loaders w/ getLoadersByName() is user config #1761

Merged
merged 2 commits into from
Dec 22, 2022

Conversation

rschristian
Copy link
Member

What kind of change does this PR introduce?

Feature / bugfix

Did you add tests for your changes?

No

Summary

Closes #929

If the loader is being proxied (like say sass-loader), we need to look a bit deeper then we normally would to get the "correct" loader.

The interface here is a bit messy though, might be a bit confusing to users why there's this proxy loader:

[
    {
        "rule": {
            "enforce": "pre",
            "test": "\.s[ac]ss$",
            "use": [
                {
                    "loader": "/home/ryun/Projects/foobar/node_modules/preact-cli/src/lib/webpack/proxy-loader.js",
                    "options": {
                        "cwd": "/home/ryun/Projects/foobar",
                        "loader": "sass-loader",
                        "options": {
                            "sourceMap": true,
                            "sassOptions": {
                                "includePaths": [
                                    "/home/ryun/Projects/foobar/node_modules",
                                    "/home/ryun/Projects/foobar/node_modules/preact-cli/node_modules"
                                ]
                            }
                        }
                    }
                }
            ]
        },
        "ruleIndex": 2,
        "loader": {
            "loader": "/home/ryun/Projects/foobar/node_modules/preact-cli/src/lib/webpack/proxy-loader.js",
            "options": {
                "cwd": "/home/ryun/Projects/foobar",
                "loader": "sass-loader",
                "options": {
                    "sourceMap": true,
                    "sassOptions": {
                        "includePaths": [
                            "/home/ryun/Projects/foobar/node_modules",
                            "/home/ryun/Projects/foobar/node_modules/preact-cli/node_modules"
                        ]
                    }
                }
            }
        },
        "loaderIndex": 0
    }
]

Does this PR introduce a breaking change?

No

@rschristian rschristian requested a review from a team as a code owner December 22, 2022 07:27
@changeset-bot
Copy link

changeset-bot bot commented Dec 22, 2022

🦋 Changeset detected

Latest commit: bceb6e9

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

This PR includes changesets to release 1 package
Name Type
preact-cli 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

);
.filter(({ loader }) => {
if (typeof loader === 'string') return loader.includes(name);
return typeof loader.loader === 'string' &&
Copy link
Member Author

Choose a reason for hiding this comment

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

Not 100% that we need this type check here, but Webpack's types are quite loose and I don't want to break anyone's setup by changing behavior.

@rschristian rschristian changed the title Feat/get proxied loaders feat: Support proxied loaders w/ getLoadersByName() is user config Dec 22, 2022
@rschristian rschristian merged commit fb100b3 into master Dec 22, 2022
@rschristian rschristian deleted the feat/get-proxied-loaders branch December 22, 2022 07:42
@preact-bot preact-bot mentioned this pull request Dec 22, 2022
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.

getLoadersByName fails to resolve certain loaders
1 participant