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

function will be ignored? #1611

Closed
pigLoveRabbit520 opened this issue Sep 16, 2021 · 1 comment · Fixed by #1625
Closed

function will be ignored? #1611

pigLoveRabbit520 opened this issue Sep 16, 2021 · 1 comment · Fixed by #1625

Comments

@pigLoveRabbit520
Copy link

pigLoveRabbit520 commented Sep 16, 2021

index.js

let classMap = new Map();

function test() {
    console.log('hello world')
}

and build

result := api.Build(api.BuildOptions{
		EntryPoints: []string{"index.js"},
		AbsWorkingDir: cwd + "/js",
		Platform:    api.PlatformNode,
		Bundle:      true,
		Write:       true,
		Outfile:     "bundle.js",
	})

get bundle.js

// index.js
var classMap = new Map();

Why does the test function dissapear?

OS: Ubuntu 20.04.3 LTS
golang: go1.17.1
esbuild: v0.12.28

@hyrious
Copy link

hyrious commented Sep 16, 2021

Because you're doing bundle, which enables DCE (Dead Code Elimination) by default (and can not be disabled).

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

Successfully merging a pull request may close this issue.

2 participants