Skip to content

Commit

Permalink
fix: resolve native ES modules
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Oct 8, 2017
1 parent 5cc2d05 commit 8a28426
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/util/resolve-components.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function resolveAsyncComponents (matched: Array<RouteRecord>): Function {
pending++

const resolve = once(resolvedDef => {
if (resolvedDef.__esModule && resolvedDef.default) {
if (isESModule(resolvedDef)) {
resolvedDef = resolvedDef.default
}
// save resolved on async factory in case it's used elsewhere
Expand Down Expand Up @@ -86,6 +86,14 @@ export function flatten (arr: Array<any>): Array<any> {
return Array.prototype.concat.apply([], arr)
}

const hasSymbol =
typeof Symbol === 'function' &&
typeof Symbol.toStringTag === 'symbol'

function isESModule (obj) {
return obj.__esModule || (hasSymbol && obj[Symbol.toStringTag] === 'Module')
}

// in Webpack 2, require.ensure now also returns a Promise
// so the resolve/reject functions may get called an extra time
// if the user uses an arrow function shorthand that happens to
Expand Down

0 comments on commit 8a28426

Please sign in to comment.