Babel plugin to report dynamic imports with import-inspector with metadata about the import
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
__snapshots__ Update to import-inspector 2.0 Jun 14, 2017
.flowconfig Init commit Jun 14, 2017
.gitignore
LICENSE Init commit Jun 14, 2017
README.md
index.js
package.json 2.0.0 Jun 14, 2017
test.js Init commit Jun 14, 2017
yarn.lock Init commit Jun 14, 2017

README.md

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