Skip to content

[bug] dynamic import should interop imported module #993

@stormslowly

Description

@stormslowly

期望

ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import#return_value

( import(...) ) Returns a promise which fulfills to a module namespace object: an object containing all exports from moduleName.

翻译成代码说:

import * as mod from "/my-module.js";

import("/my-module.js").then((mod2) => {
  console.log(mod === mod2); // true
});

实际

import ("react")
.then((m)=>{
    // m.default  is undefined
})

found by @Jinbao1001

原来 import("foo/index.js") 翻译为

Promise.all([
                __mako_require__.ensure("foo/index.js")
            ]).then(__mako_require__.bind(__mako_require__, "foo/index.js"))...

需要调整为

const wildcard_interop = require("interop")
Promise.all([
                __mako_require__.ensure("foo/index.js")
            ]).then(()=>wildcard_interop(__mako_require__("foo/index.js"))...

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-Bug-confirmedStatus: report has been confirmed as a valid buggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions