Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bundler fails on import * as foo from "..." #8625

Closed
ije opened this issue Dec 5, 2020 · 3 comments
Closed

bundler fails on import * as foo from "..." #8625

ije opened this issue Dec 5, 2020 · 3 comments
Labels
bug Something isn't working correctly cli related to cli/ dir swc related to swc (bundling/transpiling)

Comments

@ije
Copy link

ije commented Dec 5, 2020

// foo.ts

export function Foo(name: string) {
    return 'foo' + name
}
// bar.ts

import { Foo } from "./foo.ts"

const bar = Foo('bar')

export default bar
// bundling.ts

import * as foo from "./foo.ts"
import bar from "./bar.ts"

console.log(foo, bar)

when I run deno bundle bundling.ts out.js, i got an error output:

thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /Users/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/swc_bundler-0.17.5/src/bundler/chunk/merge.rs:127:18
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

change last line to console.log(foo.Foo, bar) in bundling.ts can fix it.

deno nightly 2020.12.05 (release, x86_64-apple-darwin)

@lucacasonato lucacasonato added bug Something isn't working correctly cli related to cli/ dir swc related to swc (bundling/transpiling) labels Dec 5, 2020
@lucacasonato
Copy link
Member

cc @kdy1

@kdy1 kdy1 mentioned this issue Dec 6, 2020
7 tasks
kdy1 added a commit to kdy1/swc that referenced this issue Dec 6, 2020
kdy1 added a commit to swc-project/swc that referenced this issue Dec 9, 2020
swc_bundler:
 - Handle indirect wrapped es modules. (denoland/deno#8597, denoland/deno#8625)
 - Respect `export { foo }`. (denoland/deno#8626)

swc_ecma_parser:
- Allow `??=`, `||=`, `??=` in non-ts modules. (denoland/deno#8627)

swc_ecma_transforms:
 - Make `hygiene` check if a variable with expanded name exists. (denoland/deno#8620)
 - Handle `??=` correctly.
@bartlomieju
Copy link
Member

In 1.6.3 output is as follows:

const mod = function() {
    function Foo(name) {
        return 'foo' + name;
    }
    return {
        Foo
    };
}();
const Foo = mod.Foo;
const bar = Foo('bar');
console.log(mod, bar);

Closing as resolved.

@ije
Copy link
Author

ije commented Dec 31, 2020

thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir swc related to swc (bundling/transpiling)
Projects
None yet
Development

No branches or pull requests

3 participants