-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for pswpModule import without absolute path (#1764)
- Loading branch information
1 parent
05d7eea
commit b669a09
Showing
3 changed files
with
10 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
export function dynamicImportModule(module) { | ||
// TODO: polyfill import? | ||
return import(module); | ||
return typeof module === 'string' ? import(module) : module; | ||
} | ||
|
||
export function dynamicImportPlugin(pluginKey, pluginItem) { | ||
return new Promise((resolve) => { | ||
if (typeof pluginItem === 'string') { | ||
if(typeof pluginItem === 'string' || typeof pluginItem === 'object'){ | ||
dynamicImportModule(pluginItem).then((module) => { | ||
resolve({ | ||
pluginKey, | ||
moduleClass: module.default | ||
moduleClass: typeof module === 'string' ? module.default : module | ||
}); | ||
}).catch(resolve); | ||
} else { | ||
} else{ | ||
resolve(); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters