Skip to content

Babel plugin to report dynamic imports with import-inspector with metadata about the import

License

Notifications You must be signed in to change notification settings

unfold/babel-plugin-import-inspector

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

babel-plugin-import-inspector

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()
});

Options

currentModuleFileName (default: true)

report(import("./module"), {
  currentModuleFileName: "path/to/file.js"
});

importedModulePath (default: true)

report(import("./module"), {
  importedModulePath: "./module"
});

serverSideRequirePath (default: false)

import path from 'path';
// ...
report(import("./module"), {
  serverSideRequirePath: path.join(__dirname, "./module")
});

webpackRequireWeakId (default: false)

report(import("./module"), {
  webpackRequireWeakId: () => require.resolveWeak("./module")
});

timeToImport (default: false)

const start = Date.now();
// ...
report(import("./module"), {
  timeToImport: start - Date.now()
});

About

Babel plugin to report dynamic imports with import-inspector with metadata about the import

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%