Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Transpilation Error with fuse-box 4.0.0 (or maybe I'm simply blind) #2024

Description

@mqualizz

I'm running into an issue where fuse-box isn't correctly transpiling statements like:
export const { A, B } = .... The exports are completely ignored.

If I do:

const { A, B } = ...
export { A, B };

then things seem fine.

Example:

fuse.ts

import {fusebox} from "fuse-box";

const fuse = fusebox({
    entry: "src/index.ts",
    target: "browser",
    devServer: {
        enabled: true,
        httpServer: {
            port: 8080
        },
        hmrServer: {
            port: 8081
        }
    },
    webIndex: true,

    // Enable hot module replace
    hmr: true,
});

fuse.runDev({
    bundles: {
        distRoot: "dist",
        app: "bundle.js"
    }
});

src/Test.ts

const Stuff = {
    A: 1,
    B: () => { console.log("B") },
    C: () => { console.log("C") }
}

export const { B, C } = Stuff;

export const Doit = () => { B() }

src/index.ts

import { Doit } from "./Test";

Doit();

Relevant snippets from generated bundle.js

__fuse.bundle({

// src/index.ts @1
1: function(__fusereq, exports, module){
exports.__esModule = true;
var Test_1 = __fusereq(4);
Test_1.Doit();

},

and

// src/Test.ts @4
4: function(__fusereq, exports, module){
exports.__esModule = true;
const Stuff = {
  A: 1,
  B: () => {
    console.log("B");
  },
  C: () => {
    console.log("C");
  }
};
exports.undefined = Stuff;
exports.Doit = () => {
  B();
};

},

Issues:

  1. exports.undefined = Stuff -- stuff wasn't exported in the original code
  2. missing exports and corrected references for export { B, C } = Stuff

Further, I get the following error when I try to open this in the browser:

index.ts:3 Uncaught TypeError: Test_1.Doit is not a function
    at 1 (index.ts:3)
    at Object.f.r (bundle.js:24)
    at Test.ts:9
    at Object.f.bundle (bundle.js:10)
    at bundle.js:28

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions