denoland / denoland/deno-rolldown-plugin

Plugin should discard `import.meta.main` blocks of non-entry modules

Open
#15 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
31
Forks
2
PR merge metrics
No merged PRs in 30d

Description

```ts
// (property) ImportMeta.main: boolean
// A flag that indicates if the current module is the main module that was called when starting the program under Deno.

if (import.meta.main) {
// this was loaded as the main module, maybe do some bootstrapping
}
```

But after bundle into a single file through `rolldown`, the `import.meta.main` blocks of all imported submodules also enter the dist file and will be run. This is not expected behavior and causes surprises.

The deno plugin should remove the `import.meta.main` block of non-entry modules, or possibly replace it with `false` and discard the block via tree-shaking.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.