ts-browser icon indicating copy to clipboard operation
ts-browser copied to clipboard

export {a} from "./b" not handled

Open smhanov opened this issue 3 years ago • 1 comments

bar.ts:

function bar() {
    console.log("bar() is called");
}

foo.ts:

export {bar} from "./bar"

Result:

export { bar } from "./bar";

//# sourceURL=./foo.ts
Uncaught (in promise) TypeError: Error resolving module specifier “./bar”. Relative module specifiers must start with “./”, “../” or “/”.

smhanov avatar Mar 25 '21 20:03 smhanov

Well, you know what to do =3

Thanks for the issue, would be good to fix that. Not sure I'll get to that anytime soon, though.

I wonder if such exports are, same as imports, limited to only the start of the script. If they are, that would simplify things.

The iteration over top-level statements happens here: https://github.com/klesun/ts-browser/blob/aa76bfcb6fd8f148aca6b273365ba38b4224a4ea/src/actions/ParseTsModule_sideEffects.js#L128

I guess the way to go is to console.log out the data structure of these export statements (though not touch other export statements, as they are not limited to start of script), add an else if branch with basically same logic as for ImportDeclaration (should probably move it to a separate function and reuse from both branches) with addition of export { bar }; after the imports block or something like that...

klesun avatar Mar 25 '21 21:03 klesun