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

Explicit query param imports for non-JS/CSS assets #2306

Closed
xiaoxiangmoe opened this issue Nov 20, 2018 · 3 comments
Closed

Explicit query param imports for non-JS/CSS assets #2306

xiaoxiangmoe opened this issue Nov 20, 2018 · 3 comments
Labels
💬 RFC Request For Comments

Comments

@xiaoxiangmoe
Copy link

xiaoxiangmoe commented Nov 20, 2018

💬 RFC

// Load as url by parcel-plugin.url
import logoUrl from './logo.svg?type=url';  
// Load as react-component by parcel-plugin-svg.react-component
import Icon from './icon.svg?type=react-component';

// Load as html string by parcel-plugin-md.html
import docHtml from './doc.md?type=html'; 
// Load as raw string by parcel-plugin.raw
import docText from './doc.md?type=raw';  
// Load as ast tree object  by parcel-plugin-md.ast
import docAst from './doc.md?type=ast';   

parcel-plugin.loadtype can load for any filetype
parcel-plugin-filetype.loadtype can load loadtype from special filetype

🔦 Context

Previous Proposal, see @gaearon 's Proposal: explicit named imports for non-JS/CSS assets #3722

also see ECMAScript Modules - Node.js | URL based paths:

Modules will be loaded multiple times if the import specifier used to resolve them have a different query or fragment.

@tiborsaas
Copy link

The query string modifiers would be pretty nice.

@quasicomputational
Copy link

quasicomputational commented Feb 12, 2019

This would actually be useful for JS as well. The tabs.executeScript WebExtension API takes an URL or the literal content of the file, rather like Worker does. If there was a way to load a JS file as a URL (while also applying all the Babel transforms, etc), that would both serve this somewhat niche, presently-awkward use-case and provide an alternative way to load workers if you want to do it in a way that defeats Parcel's current detection logic.

@mischnic
Copy link
Member

New RFC: #3477

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💬 RFC Request For Comments
Projects
None yet
Development

No branches or pull requests

5 participants