Closed auxves closed 4 years ago
I think it will not work.
Problem is that Parcel first goes to the file system for the location resolution. So if the module does not exist this will throw an error.
What this plugin does is after the resolver did its job. Maybe there is another way to do this (reliably), but I haven't found one earlier. If you come up with any idea some input would be appreciated!
Actually, I think it is possible and I will try to come up with an implementation!
Thinking about it right now!
Landed in develop
and the preview (for 0.4.0).
From the documentation:
By default, the modules must be present in the local installation. Otherwise Parcel will complain. This is not always possible / the case.
In this scenario you'll need a virtual module. You can get support for this via Parcel's standard alias
.
Consider the following snippet (from package.json):
{
"externals": [
"react",
"foo"
],
"alias": {
"foo": "./src/foo-virtual.js"
}
}
Here, we will identify that foo is an external alias and still externalize the call (in the given example to use require('foo')
). You could leave the virtual module empty.
Important: If you have multiple virtual modules you should give them all unique paths. Otherwise, this plugin cannot distinguish between them.
Hope that helps :beers!
Testing the preview via:
npm i parcel-plugin-externals@0.4.0-pre.20200405.1
I am writing a VSCode extension that imports the
vscode
module for interfaces and other things. However, this module does not exist and is provided on the fly by the editor, so there is an error when trying to build the extension. Does this plugin support scenarios like this?Here is the project: https://github.com/arnohovhannisyan/vscode-syncify.
I tried adding the
vscode
module to bothexternals
andpeerDependencies
but it didn't work.