Skip to content
This repository has been archived by the owner on Jan 14, 2025. It is now read-only.

Commit

Permalink
Fix lib is not defined
Browse files Browse the repository at this point in the history
  • Loading branch information
dwqs committed Mar 11, 2018
1 parent 12f934b commit 8af28ce
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function importOnDemand(_ref) {
var t = _ref.types;

return {
name: 'import-on-demand',
visitor: {
ImportDeclaration: function ImportDeclaration(path, _ref2) {
var _ref2$opts = _ref2.opts,
Expand All @@ -38,7 +39,7 @@ function importOnDemand(_ref) {
if (node.source.value === libraryName) {
node.specifiers.forEach(function (specifier) {
if (specifier.type === 'ImportSpecifier') {
path.insertBefore(t.importDeclaration([t.importDefaultSpecifier(t.identifier(specifier.imported.name))], t.stringLiteral(libraryName + '/' + lib + '/' + parseName(specifier.imported.name))));
path.insertBefore(t.importDeclaration([t.importDefaultSpecifier(t.identifier(specifier.imported.name))], t.stringLiteral(libraryName + '/' + libraryPath + '/' + parseName(specifier.imported.name))));
}
});
path.remove();
Expand Down
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function importOnDemand ({types: t}) {
path.insertBefore(
t.importDeclaration(
[t.importDefaultSpecifier(t.identifier(specifier.imported.name))],
t.stringLiteral(`${libraryName}/${lib}/${parseName(specifier.imported.name)}`)
t.stringLiteral(`${libraryName}/${libraryPath}/${parseName(specifier.imported.name)}`)
)
);
}
Expand Down

0 comments on commit 8af28ce

Please sign in to comment.