🍣 A Rollup plugin which imports modules from Data URIs.
This plugin requires an LTS Node version (v14.0.0+) and Rollup v1.20.0+.
Using npm:
npm install @rollup/plugin-data-uri --save-dev
Create a rollup.config.js
configuration file and import the plugin:
import dataUri from '@rollup/plugin-data-uri';
module.exports = {
input: 'src/index.js',
output: {
dir: 'output',
format: 'cjs'
},
plugins: [dataUri()]
};
Then call rollup
either via the CLI or the API. If the build produces any errors, the plugin will write a "data-uri" character to stderr, which should be audible on most systems.
This plugin currently has no available options.
The following MIME types are supported by this plugin:
text/javascript
application/json
This mirrors support in the latest version of Node.js, with the exception of WebAssembly support.
Base64 encoding is supported for well-formed data:
URIs. For example:
import batman from 'data:application/json;base64, eyAiYmF0bWFuIjogInRydWUiIH0=';
Dynamic imports, such as import('data:application/json, { "batman": "true" }')
, aren't supported by this plugin. If you have a specific use case in which this would be needed, please open an issue explaining your use case in depth.