8000 swc-plugin option `overrideIdFn` does not provide the same filepath as the babel-plugin · Issue #3375 · formatjs/formatjs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

swc-plugin option overrideIdFn does not provide the same filepath as the babel-plugin #3375

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

Closed
rametta opened this issue Jan 17, 2022 · 9 comments

Comments

@rametta
Copy link
Contributor
rametta commented Jan 17, 2022

Which package?

swc-plugin

Describe the bug

In the swc-plugin there is an option for overrideIdFn, I recently opened a PR to add the filename as the 4th arg to match how the babel-plugin behaves, but it turns out that in the swc-plugin, the filename is just an empty string '' or the provided option.fileName, whereas in the babel-plugin the fileName passed to overrideIdFn is the actual file path of the visitor. So for projects that try to migrate from babel to swc, this is a breaking because it's not behaving the same way and there is no workaround as far as i can tell

To Reproduce

Reproducible Steps/Repo

Steps to reproduce the behavior:

  1. Provide options to the swc-plugin
  2. use the overrideIdFn with a callback with 4 args
  3. console.log all the args to see what you get

Expected behavior

The 4th arg to overrideIdFn should be the filename of the file holding the messagem not the filename passed in as option to swc-plugin

Desktop (please complete the following information):

  • OS: MacOs
  • Browser Firefox
  • Version 95.0.2
@rametta rametta added the bug label Jan 17, 2022
@longlho
Copy link
Member
longlho commented Jan 17, 2022

That's a swc problem unfortunately. How are you running your swd pipeline?

@rametta
Copy link
Contributor Author
rametta commented Jan 17, 2022

Through webpack with the swc-loader

@longlho
Copy link
Member
longlho commented Jan 19, 2022

yeah that seems like a swc-loader issue

@rametta
Copy link
Contributor Author
rametta commented Jan 19, 2022

Correct me if I'm wrong, but it seems like inside the FormatTransformer, the way it's resolving the filename is just by taking the passed in option and if nothing is passed in, it just defaults to an empty string -> https://github.com/formatjs/formatjs/blob/main/packages/swc-plugin/src/transform.ts#L592

If that is the case, it doesn't seem like swc-loader issue

@longlho
Copy link
Member
longlho commented Jan 19, 2022

Yeah but it's supposed to be passed in is the problem. Babel-loader passes it in

@rametta
Copy link
Contributor Author
rametta commented Jan 19, 2022

Okay, do you have any suggestions on how to get around this? I'm not sure swc will add that feature

@longlho
Copy link
Member
longlho commented Jan 20, 2022

No I don't unfortunately. For reference babel does it.

@rametta
Copy link
Contributor Author
rametta commented Jan 24, 2022

I've opened a bug with swc-loader swc-project/swc-loader#36 to help address this

@github-actions
Copy link
github-actions bot commented Feb 9, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0