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

[plugin-babel] should works with query param in path #500

Closed
csr632 opened this issue Jul 16, 2020 · 11 comments · Fixed by #533
Closed

[plugin-babel] should works with query param in path #500

csr632 opened this issue Jul 16, 2020 · 11 comments · Fixed by #533

Comments

@csr632
Copy link
Contributor

csr632 commented Jul 16, 2020

Expected Behavior

The plugin should accept module id with query param in it.

The motivation is similar to how node-resolve plugin support hash and query.

Actual Behavior

It doesn't recognize .ts extension because the module id is file.ts?query=asd.

Additional Information

In my case, when I am doing some special import, I store some infomation in the query, so that my plugin can treat it differently.

@shellscape
Copy link
Collaborator

Thanks for opening an issue. Citing the issue template:

🚨 Issues WITHOUT a valid reproduction WILL BE CLOSED!

Please provide one by:

  1. Using the REPL.it plugin reproduction template at https://repl.it/@rollup/rollup-plugin-repro
  2. Provide a minimal repository link (Read https://git.io/fNzHA for instructions).
    Please use NPM for installing dependencies!
    These may take more time to triage than the other options.
  3. Using the Rollup REPL at https://rollupjs.org/repl/

⚠️ ZIP Files are unsafe and maintainers will NOT download them.

We cannot make this any clearer. Please add a reproduction and we'll be happy to triage further.

@shellscape
Copy link
Collaborator

Seriously, follow the template. Don't modify it.

@csr632
Copy link
Contributor Author

csr632 commented Jul 16, 2020

I am very sorry! I have updated the issue. Can you reopen it? @shellscape

@shellscape
Copy link
Collaborator

Thank you

@Andarist
Copy link
Member

Andarist commented Aug 6, 2020

Out of curiosity - why this query is there? What it is used for? I would love to know more about the use case here.

@lukastaegert
Copy link
Member

I believe it is a rather interesting pattern of passing parameters to plugins that handle imports to allow per-import configuration. The big advantage is that the source code can still be easily run unmodified in a browser as the import is still a valid URL.

@csr632
Copy link
Contributor Author

csr632 commented Aug 6, 2020

@Andarist

Out of curiosity - why this query is there? What it is used for? I would love to know more about the use case here.

moduleId with query + rollup plugin enablue us to import thing with special effect.

In my app code, I can import thing with this special effect:

import value from './my-module.tsx?varValue=123'

I have a plugin to recoginze this query and do special transform to some modules:

{
   name: 'template-variable-plugin',
   transform(code, id) {
     const varValue = getValueFromQuery(id)
     return code.replace('$template_var$', varValue)
  }
}

@Andarist
Copy link
Member

Andarist commented Aug 6, 2020

We could allow this - I assume that we should transform each such request independently, right? Caching based on a filename alone is not sufficient in this case.

@csr632 would you like to work on this one?

@csr632
Copy link
Contributor Author

csr632 commented Aug 7, 2020

I will work on it in this weekend.

@Andarist
Copy link
Member

Andarist commented Aug 7, 2020

That's great, can't wait. Please ping me in the PR thread once you do it - I will try to review asap.

@stale
Copy link

stale bot commented Oct 9, 2020

Hey folks. This issue hasn't received any traction for 60 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it.

@stale stale bot closed this as completed Oct 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants