Babel plugin to report dynamic imports with import-inspector with metadata about the import
Input:
import("./module");
Output: (with all options turned on)
import path from "path";
import { report } from "import-inspector";
const start = Date.now();
report(import("./module"), {
currentModuleFileName: "path/to/file.js",
importedModulePath: "./module",
serverSideRequirePath: path.join(__dirname, "./module"),
webpackRequireWeakId: () => require.resolveWeak("./module"),
timeToImport: start - Date.now()
});
report(import("./module"), {
currentModuleFileName: "path/to/file.js"
});
report(import("./module"), {
importedModulePath: "./module"
});
import path from 'path';
// ...
report(import("./module"), {
serverSideRequirePath: path.join(__dirname, "./module")
});
report(import("./module"), {
webpackRequireWeakId: () => require.resolveWeak("./module")
});
const start = Date.now();
// ...
report(import("./module"), {
timeToImport: start - Date.now()
});