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

Bun build failed: SyntaxError: Unexpected keyword 'export' #2772

Open
approached opened this issue Nov 6, 2023 · 4 comments
Open

Bun build failed: SyntaxError: Unexpected keyword 'export' #2772

approached opened this issue Nov 6, 2023 · 4 comments

Comments

@approached
Copy link

Describe the bug
Not possible to build via bun.

To Reproduce

  1. Create a file:
import mjml2html from "mjml";

/*
  Compile an mjml string
*/
const htmlOutput = mjml2html(
	`
  <mjml>
    <mj-body>
      <mj-section>
        <mj-column>
          <mj-text>
            Hello World!
          </mj-text>
        </mj-column>
      </mj-section>
    </mj-body>
  </mjml>
`,
);

/*
  Print the responsive HTML generated and MJML errors if any
*/
console.log(htmlOutput);
  1. Build
bun build --sourcemap=external --target=bun ./src/test.ts --outdir ./build && bun run ./build/test.js

Expected behavior

  test.js        3076.02 KB

  test.js.map    5568.02 KB

[107ms] bundle 665 modules
SyntaxError: Unexpected keyword 'export'
      at .../api/build/test.js:70860
error: script "testfile" exited with code 1 (SIGHUP)

Line 70860:

  exports.FILES = [
    "......../api/node_modules/uglify-js/tools/exports.js"
  ];
  new Function("domprops", "exports", function() {
    var code = exports.FILES.map(function(file) {
      return fs.readFileSync(file, "utf8");
    });
    code.push("exports.describe_ast = " + describe_ast.toString());
    return code.join("\n\n");
  }())(require_domprops(), exports);
  if (+process.env["UGLIFY_BUG_REPORT"]) {
    var $minify = function(files, options) {
      if (typeof options == "undefined")
        options = "<<undefined>>";
      var code = [
        "// UGLIFY_BUG_REPORT",
        to_comment(options)
      ];
      if (typeof files == "string") {
        code.push("");
        code.push("//-------------------------------------------------------------");
        code.push("// INPUT CODE", files);
      } else
        for (var name in files) {
          code.push("");
          code.push("//-------------------------------------------------------------");
          code.push(to_comment(name), files[name]);
        }
      if (options.sourceMap && options.sourceMap.url) {
        code.push("");
        code.push("//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9");
      }
      var result = { code: code.join("\n") };
      if (options.sourceMap)
        result.map = '{"version":3,"sources":[],"names":[],"mappings":""}';
      return result;
    };

    export { $minify as minify };
  }

What the hell is export { $minify as minify }; ?

@iRyusa
Copy link
Member

iRyusa commented Nov 6, 2023 via email

@approached
Copy link
Author

The package uglify-js has follow dependency:
mjml > mjml-core > html-minifier > uglify-js

The package https://github.com/kangax/html-minifier would not be maintained. The last version ist from Apr 1, 2019 👎

@approached
Copy link
Author

@approached
Copy link
Author

Ohh last update of https://github.com/mishoo/UglifyJS/ was:
Oct 23, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants