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: expose webpack.target as rawTarget #943

Closed
wants to merge 1 commit into from

Conversation

bpinto
Copy link

@bpinto bpinto commented Jun 7, 2022

Please Read the CONTRIBUTING Guidelines
In particular the portion on Commit Message Formatting

Please check if the PR fulfills these requirements

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior? (You can also link to an open issue here)

Currently the target exposed via caller.target is the normalized target.

What is the new behavior?

This change adds a new property called rawTarget that exposes the original target as set on the webpack configuration.

Does this PR introduce a breaking change?

  • Yes
  • No

If this PR contains a breaking change, please describe the following...

  • Impact:
  • Migration path for existing applications:
  • Github Issue(s) this is regarding:

Other information:

In the future, I think browserlistEnv option could be automatically set when the webpack's target option is set using browserslist:${env}. I believe that would make the webpack / babel / browserslist integration easier.

I'm afraid that would be a breaking change, and since there are, based on the documentation, future breaking changes it might make sense to wait for that to introduce this automatic browserlistEnv setting.

@bpinto
Copy link
Author

bpinto commented Jun 7, 2022

I have not updated any documentation nor included any test yet. But I'd like some guidance on how to do both if this change is considered interesting.

@bpinto
Copy link
Author

bpinto commented Jun 8, 2022

I'm not used to working on packages that require being pre-built before they can be used in a project, so if possible could you tell me how can I test this change on my project? I tried adding it to package.json using the git URL but that is not enough. Meanwhile, I have copied these changes over to the installed package (on node_modules) in order to try this out.

if (!supportsCallerOption()) return opts;

return Object.assign({}, opts, {
caller: Object.assign(
{
name: "babel-loader",
rawTarget,
Copy link
Author

Choose a reason for hiding this comment

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

Maybe I should add this below the target property below?

@bpinto
Copy link
Author

bpinto commented Oct 31, 2022

@nicolo-ribaudo do you think this is worth adding? See #826 (comment) for context. I would like to be able to use different browserslist targets and for that I need to pass the raw target to @babel/preset-env.

@bpinto bpinto closed this Dec 11, 2022
@bpinto bpinto deleted the raw-target branch December 11, 2022 11:22
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.

None yet

1 participant