Virtual modules are the means for userland consumption of Fusion-owned static analysis and build artifacts in a way that:
In practice, a virtual module is implemented via a coupled agglomeration of babel plugin(s), webpack loader(s), and webpack plugin(s).
Fusion.js currently provides the following virtual modules:
import {assetUrl} from 'fusion-core';
assetUrl('path/to/some/file');
// => Path to the asset
file-loader
The workerUrl virtual module allows transpiling and loading a Web Worker. The result of the virtual call should be passed into the Worker
constructor.
import {workerUrl} from 'fusion-core';
// Path to the asset
const url = workerUrl('path/to/some/worker.js');
const myWorker = new Worker(url);
This is a useful building block for implementing things such as translations and module async/lazy loading.
import {chunkId} from 'fusion-core';
chunkId('path/to/some/module');
// => Array of client-side chunk ids for the module