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

deno bundle: __rest is not defined Error #7288

Closed
bela53 opened this issue Aug 31, 2020 · 1 comment · Fixed by #8575
Closed

deno bundle: __rest is not defined Error #7288

bela53 opened this issue Aug 31, 2020 · 1 comment · Fixed by #8575
Labels
bug Something isn't working correctly swc related to swc (bundling/transpiling)

Comments

@bela53
Copy link

bela53 commented Aug 31, 2020

Reproduction

main.js:

import * as path from "https://deno.land/[email protected]/path/mod.ts";
const { a, ...rest } = { a: 3, b: "bar" };
console.log(a, rest);

CLI:

deno bundle main.js build/main.js
deno run build/main.js

results in:

error: Uncaught ReferenceError: __rest is not defined
_a = { a: 3, b: "bar" }, a = _a.a, rest = __rest(_a, ["a"]);
^
at execute (file:///tmp/TestProj/build/main.js:389:40)
at gExp (file:///tmp/TestProj/build/main.js:90:7)
at __instantiate (file:///tmp/TestProj/build/main.js:97:27)
at file:///tmp/TestProj/build/main.js:395:1

build/main.js emits:

System.register("file:///tmp/TestProj/main", [], function (exports_11, context_11) {
    // ...
    return {
        // ...
        execute: function () {
            _a = { a: 3, b: "bar" }, a = _a.a, rest = __rest(_a, ["a"]); // this is the error cause
            // ...
        }
    };
});

The __rest method is not defined anywhere in the emitted build output.

If I comment out the import statement on first line, it works again. deno bundle seems to change its build output conditionally dependent on whether the file is a script or a module - doesn't matter what exactly is imported.

Is this a deno bundle error or could it be more related to underlying TS SystemJS bundling?

@kitsonk
Copy link
Contributor

kitsonk commented Aug 31, 2020

Hrmmm... It shouldn't be doing that... it is down emitting syntax and not outputting the helpers.

I confirmed it is occurring on master, need to investigate.

@lucacasonato lucacasonato added bug Something isn't working correctly cli related to cli/ dir labels Aug 31, 2020
@bartlomieju bartlomieju added the upstream Changes in upstream are required to solve these issues label Nov 9, 2020
@kitsonk kitsonk added swc related to swc (bundling/transpiling) and removed cli related to cli/ dir upstream Changes in upstream are required to solve these issues labels Nov 17, 2020
@kdy1 kdy1 mentioned this issue Nov 27, 2020
3 tasks
kdy1 added a commit to kdy1/swc that referenced this issue Nov 27, 2020
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 swc related to swc (bundling/transpiling)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants