0.0.4 • Published 4 years ago
@async-module/import v0.0.4
@async-module/import
async import webpack es module
get start
install
npm install @async-module/import -S
# or
yarn add @async-module/import -S
use
// have been bundle file: times/index.502441.js
(window["webpackJsonp"] = window["webpackJsonp"] || []).push([["tpls/times/index"],{
/***/ "tpls/times/index":
/***/ (function(module, exports) {
eval("function times(a, b) {\n console.log(\"here is demo2\")\n return a * b\n}\n\n");
/***/ })
},[["tpls/times/index","tpls-manifest"]]]);
import asyncImport from "@async-module/import"
async function test(a,b) {
const times = await asyncImport("tpls/times")
result = times(a,b)
console.log("minus:", times) // load the script, and exec the minus function
}
test(2,3)
watch out
only support es module