// 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
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.
The query string modifiers would be pretty nice.
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.
Most helpful comment
This would actually be useful for JS as well. The
tabs.executeScriptWebExtension API takes an URL or the literal content of the file, rather likeWorkerdoes. 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.