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

Compiling a module that exports Object defined anew results in invalid CommonJS code #444

Open
yuhr opened this issue Jan 3, 2025 · 0 comments

Comments

@yuhr
Copy link

yuhr commented Jan 3, 2025

const Object = "hello"
export default Object

A module named repro.ts with the above content is compiled into out/script/repro.js with the following content:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const Object = "hello";
exports.default = Object;

where the configuration used is

import { build } from "jsr:@deno/[email protected]"
await build({
	entryPoints: ["./repro.ts"],
	outDir: "./out",
	shims: {},
	package: { name: "reproduction", version: "0.0.0" },
	packageManager: "pnpm",
	typeCheck: false,
	test: false,
	skipSourceOutput: true,
})

Loading the compiled CommonJS module of course fails with an “access before initialization” error.

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

1 participant