This library allows for you to compile ESM source files using standard import paths. For instance, you can compile https://raw.githubusercontent.com/brainsatplay/escompose/blob/main/libraries/esmpile/index.js!
esmpile is a core library of the Brains@Play Framework
const options = {
collection: 'global', // Specify the bundle name to draw from
bundler: 'objecturl', // Specify how to bundle the file
callbacks: {
progress: {
fetch:(path, i, total, done, failed, range) => {}, // Fetch-level updates for each file
file: (path, i, total, done, failed) => {} // File-level updates for each dependency resolution
}
},
debug: true, // Toggle debug messages in the Developer Console
fallback: true, // Toggle to fallback to compilation if direct import is not available
forceNativeImport: false // Override output specifications which require text import
output: { // Specify which information to output to the user
text: true, // Use text for module creation and output using onImport
objecturl: true,
datauri: true
},
relativeTo: import.meta.url // Specify what file the paths are relative to.
// If using a bundler for your main JavaScript file, you may have to substitute with window.location.href...
}
TypeScript support can be enabled by preloading the associated script:
await esm.load.script('./extensions/typescriptServices.min.js');
The extension code has been generated using our TypeScript Services minifier script.
Live Edit Any ES Module: Allow for minimal recompiling of a single module (and dependents) after submitting updated text.
Visualize Code Execution: This project could be extended by es-monitor to visualize the ESM code execution of an application.
Develop a RegExp that handles export * as name from "path"
syntax: We have a draft RegExp that extends the existing one for imports—but it stalls when importing self (likely because of the amount of basic exports in the files).
Allow for Any Circular Dependencies: Currently we are falling back to direct imports for files with circular depenencies.
This library is maintained by Garrett Flynn and Joshua Brewster, who use contract work and community contributions through Open Collective to support themselves.
Support us with a monthly donation and help us continue our activities!
Become a sponsor and get your logo here with a link to your site!