deno bundle: `__rest is not defined` Error

Created on 31 Aug 2020  路  1Comment  路  Source: denoland/deno

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?

bug swc

Most helpful comment

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.

>All comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sh7dm picture sh7dm  路  3Comments

motss picture motss  路  3Comments

metakeule picture metakeule  路  3Comments

kitsonk picture kitsonk  路  3Comments

davidbarratt picture davidbarratt  路  3Comments