Package Exports
- virtual-es-module
- virtual-es-module/dist/virtual-esm.esm-bundler.js
- virtual-es-module/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (virtual-es-module) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Virtual es module for easy operation in the sandbox...
Feature
-
import -
import() -
import.meta -
Circular reference
Demo
<!DOCTYPE html>
<html lang="en">
<body>
<script type="virtual-module">
import * as m from './m.js';
console.log(m);
import('./m.js').then(mm => {
console.log(m === mm); // true
})
</script>
<!-- Start -->
<script src="virtual-esm.umd.js"></script>
<script>
document.addEventListener('DOMContentLoaded', () => {
VirtualModule.startByScriptTag();
})
</script>
</body>
</html>// m.js
export const a = 1, b = 2;
export default class App {};
const c = 3;
export {
c as default,
}
const d = 4;
export {
d as dd,
}Not support
The code executed by eval cannot be converted by this scheme.
import m from './m.js';
eval('console.log(m);') // throw error 'm is not defined'
``