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

swc_bundler: emitting all symbols in certain scenarios #1119

Closed
kitsonk opened this issue Sep 29, 2020 · 1 comment · Fixed by #1105
Closed

swc_bundler: emitting all symbols in certain scenarios #1119

kitsonk opened this issue Sep 29, 2020 · 1 comment · Fixed by #1105
Assignees
Labels
Milestone

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Sep 29, 2020

Describe the bug

swc_bundler wrongly emits all symbols in a module in certain scenarios.

I have tried to get the reproducible as small as possible.

Input code

example10.ts

export { a, b } from "./k.ts";

i.ts

export function a(...d: string[]): string {
  return d.join(" ");
}

j.ts

export function a(...d: string[]): string {
  return d.join("/");
}

k.ts

import * as _i from "./i.ts";
import * as _j from "./j.ts";

const k = globalThis.value ? _i : _j;

export const i = _i;
export const j = _j;

export const {
  a,
} = k;

Expected behavior

That non-exported symbols don't get exported.

Current bundling outputs, where d couldn't possible be exported. In the real world-code example this is based on, basically any symbol in the module in this situation gets exported, which of course is totally invalid at run-time:

const _i = function() {
    function a(...d) {
        return d.join(" ");
    }
    return {
        a,
        d
    };
}();
const _j = function() {
    function a(...d) {
        return d.join("/");
    }
    return {
        a,
        d
    };
}();
const k = globalThis.value ? _i : _j;
const { a ,  } = k;
export { a };

Version

Version: swc_bundler 0.8.1 (current #1005 branch)

Additional context

Working to integrate swc_bundler into Deno.

@kitsonk kitsonk added the C-bug label Sep 29, 2020
@kdy1 kdy1 self-assigned this Sep 29, 2020
@kdy1 kdy1 added this to the v1.2.35 milestone Sep 29, 2020
kdy1 added a commit to kdy1/swc that referenced this issue Sep 29, 2020
@kdy1 kdy1 closed this as completed in #1105 Oct 2, 2020
kdy1 added a commit that referenced this issue Oct 2, 2020
swc_bundler:
 - Correct lca for circular dependencies.
 - Handle namespaced imports. (#1109)
 - Handle namespaced reexports. (#1110)
 - Handle shorthand properly. (#1111)
 - Implement `import.meta` (#1115)
 - Handle reexport mixed with imports correctly. (#1116)
 - Handle export default decls in computed-key modules. 
 - Remove all export * from. output. (#1118)
 - Handle export of class or function declaration in a computed module properly. (#1119)


swc_ecma_transforms:
 - Do not rename class members. (#1117)
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 26, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants