Skip to content

Commit

Permalink
Merge branch 'main' into local-css-prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
chowey authored Jan 19, 2025
2 parents 7c1e87c + df815ac commit 6ec5842
Show file tree
Hide file tree
Showing 63 changed files with 3,282 additions and 1,879 deletions.
1,030 changes: 1,030 additions & 0 deletions CHANGELOG-2024.md

Large diffs are not rendered by default.

933 changes: 11 additions & 922 deletions CHANGELOG.md

Large diffs are not rendered by default.

23 changes: 18 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ platform-all:
platform-linux-riscv64 \
platform-linux-s390x \
platform-linux-x64 \
platform-netbsd-arm64 \
platform-netbsd-x64 \
platform-neutral \
platform-openbsd-arm64 \
Expand Down Expand Up @@ -361,6 +362,9 @@ platform-freebsd-x64:
platform-freebsd-arm64:
@$(MAKE) --no-print-directory GOOS=freebsd GOARCH=arm64 NPMDIR=npm/@esbuild/freebsd-arm64 platform-unixlike

platform-netbsd-arm64:
@$(MAKE) --no-print-directory GOOS=netbsd GOARCH=arm64 NPMDIR=npm/@esbuild/netbsd-arm64 platform-unixlike

platform-netbsd-x64:
@$(MAKE) --no-print-directory GOOS=netbsd GOARCH=amd64 NPMDIR=npm/@esbuild/netbsd-x64 platform-unixlike

Expand Down Expand Up @@ -442,22 +446,26 @@ publish-all: check-go-version

@echo Enter one-time password:
@read OTP && OTP="$$OTP" $(MAKE) --no-print-directory -j4 \
publish-freebsd-x64 \
publish-freebsd-arm64 \
publish-freebsd-x64 \
publish-openbsd-arm64 \
publish-openbsd-x64 \
publish-openbsd-x64

@echo Enter one-time password:
@read OTP && OTP="$$OTP" $(MAKE) --no-print-directory -j4 \
publish-darwin-arm64 \
publish-darwin-x64 \
publish-netbsd-arm64 \
publish-netbsd-x64

@echo Enter one-time password:
@read OTP && OTP="$$OTP" $(MAKE) --no-print-directory -j4 \
publish-android-x64 \
publish-android-arm \
publish-android-arm64 \
publish-darwin-x64
publish-android-arm64

@echo Enter one-time password:
@read OTP && OTP="$$OTP" $(MAKE) --no-print-directory -j4 \
publish-darwin-arm64 \
publish-linux-x64 \
publish-linux-ia32 \
publish-linux-arm
Expand Down Expand Up @@ -522,6 +530,9 @@ publish-freebsd-x64: platform-freebsd-x64
publish-freebsd-arm64: platform-freebsd-arm64
test -n "$(OTP)" && cd npm/@esbuild/freebsd-arm64 && npm publish --otp="$(OTP)"

publish-netbsd-arm64: platform-netbsd-arm64
test -n "$(OTP)" && cd npm/@esbuild/netbsd-arm64 && npm publish --otp="$(OTP)"

publish-netbsd-x64: platform-netbsd-x64
test -n "$(OTP)" && cd npm/@esbuild/netbsd-x64 && npm publish --otp="$(OTP)"

Expand Down Expand Up @@ -619,6 +630,7 @@ validate-builds:
@$(MAKE) --no-print-directory TARGET=platform-linux-riscv64 SCOPE=@esbuild/ PACKAGE=linux-riscv64 SUBPATH=bin/esbuild validate-build
@$(MAKE) --no-print-directory TARGET=platform-linux-s390x SCOPE=@esbuild/ PACKAGE=linux-s390x SUBPATH=bin/esbuild validate-build
@$(MAKE) --no-print-directory TARGET=platform-linux-x64 SCOPE=@esbuild/ PACKAGE=linux-x64 SUBPATH=bin/esbuild validate-build
@$(MAKE) --no-print-directory TARGET=platform-netbsd-arm64 SCOPE=@esbuild/ PACKAGE=netbsd-arm64 SUBPATH=bin/esbuild validate-build
@$(MAKE) --no-print-directory TARGET=platform-netbsd-x64 SCOPE=@esbuild/ PACKAGE=netbsd-x64 SUBPATH=bin/esbuild validate-build
@$(MAKE) --no-print-directory TARGET=platform-openbsd-arm64 SCOPE=@esbuild/ PACKAGE=openbsd-arm64 SUBPATH=bin/esbuild validate-build
@$(MAKE) --no-print-directory TARGET=platform-openbsd-x64 SCOPE=@esbuild/ PACKAGE=openbsd-x64 SUBPATH=bin/esbuild validate-build
Expand Down Expand Up @@ -655,6 +667,7 @@ clean:
rm -rf npm/@esbuild/linux-riscv64/bin
rm -rf npm/@esbuild/linux-s390x/bin
rm -rf npm/@esbuild/linux-x64/bin
rm -rf npm/@esbuild/netbsd-arm64/bin
rm -rf npm/@esbuild/netbsd-x64/bin
rm -rf npm/@esbuild/openbsd-arm64/bin
rm -rf npm/@esbuild/openbsd-x64/bin
Expand Down
2 changes: 1 addition & 1 deletion cmd/esbuild/version.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
package main

const esbuildVersion = "0.24.0"
const esbuildVersion = "0.24.2"
20 changes: 11 additions & 9 deletions compat-table/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions compat-table/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"githubDependencies": {
"kangax/compat-table": "02bfc256f8db6768a6570016fdad5c7d5bc7cede",
"williamkapke/node-compat-table": "20fa0775d01324b90a1ee3ec72ecf1d6520afa3a"
"kangax/compat-table": "b3427ba3a2d6fd2dc427c3dfcf191832f634eb06",
"williamkapke/node-compat-table": "97a03aa807cfa8d83ad806fbcfe317ad95a7a159"
},
"dependencies": {
"@mdn/browser-compat-data": "5.6.2",
"@mdn/browser-compat-data": "5.6.25",
"@types/caniuse-lite": "1.0.1",
"@types/node": "20.3.2",
"caniuse-lite": "1.0.30001662"
"caniuse-lite": "1.0.30001690"
}
}
42 changes: 21 additions & 21 deletions compat-table/src/mdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,31 +34,31 @@ const cssFeatures: Partial<Record<CSSFeature, string | string[]>> = {
'css.types.color.oklch',
],
GradientDoublePosition: [
'css.types.image.gradient.conic-gradient.doubleposition',
'css.types.image.gradient.linear-gradient.doubleposition',
'css.types.image.gradient.radial-gradient.doubleposition',
'css.types.image.gradient.repeating-linear-gradient.doubleposition',
'css.types.image.gradient.repeating-radial-gradient.doubleposition',
'css.types.gradient.conic-gradient.doubleposition',
'css.types.gradient.linear-gradient.doubleposition',
'css.types.gradient.radial-gradient.doubleposition',
'css.types.gradient.repeating-linear-gradient.doubleposition',
'css.types.gradient.repeating-radial-gradient.doubleposition',
],
GradientInterpolation: [
'css.types.image.gradient.conic-gradient.hue_interpolation_method',
'css.types.image.gradient.conic-gradient.interpolation_color_space',
'css.types.image.gradient.linear-gradient.hue_interpolation_method',
'css.types.image.gradient.linear-gradient.interpolation_color_space',
'css.types.image.gradient.radial-gradient.hue_interpolation_method',
'css.types.image.gradient.radial-gradient.interpolation_color_space',
'css.types.image.gradient.repeating-conic-gradient.hue_interpolation_method',
'css.types.image.gradient.repeating-conic-gradient.interpolation_color_space',
'css.types.image.gradient.repeating-linear-gradient.hue_interpolation_method',
'css.types.image.gradient.repeating-linear-gradient.interpolation_color_space',
'css.types.image.gradient.repeating-radial-gradient.hue_interpolation_method',
'css.types.image.gradient.repeating-radial-gradient.interpolation_color_space',
'css.types.gradient.conic-gradient.hue_interpolation_method',
'css.types.gradient.conic-gradient.interpolation_color_space',
'css.types.gradient.linear-gradient.hue_interpolation_method',
'css.types.gradient.linear-gradient.interpolation_color_space',
'css.types.gradient.radial-gradient.hue_interpolation_method',
'css.types.gradient.radial-gradient.interpolation_color_space',
'css.types.gradient.repeating-conic-gradient.hue_interpolation_method',
'css.types.gradient.repeating-conic-gradient.interpolation_color_space',
'css.types.gradient.repeating-linear-gradient.hue_interpolation_method',
'css.types.gradient.repeating-linear-gradient.interpolation_color_space',
'css.types.gradient.repeating-radial-gradient.hue_interpolation_method',
'css.types.gradient.repeating-radial-gradient.interpolation_color_space',
],
GradientMidpoints: [
'css.types.image.gradient.linear-gradient.interpolation_hints',
'css.types.image.gradient.radial-gradient.interpolation_hints',
'css.types.image.gradient.repeating-linear-gradient.interpolation_hints',
'css.types.image.gradient.repeating-radial-gradient.interpolation_hints',
'css.types.gradient.linear-gradient.interpolation_hints',
'css.types.gradient.radial-gradient.interpolation_hints',
'css.types.gradient.repeating-linear-gradient.interpolation_hints',
'css.types.gradient.repeating-radial-gradient.interpolation_hints',
],
HexRGBA: 'css.types.color.rgb_hexadecimal_notation.alpha_hexadecimal_notation',
HWB: 'css.types.color.hwb',
Expand Down
54 changes: 49 additions & 5 deletions internal/bundler/bundler.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,29 @@ type tlaCheck struct {
}

func parseFile(args parseArgs) {
pathForIdentifierName := args.keyPath.Text

// Identifier name generation may use the name of the parent folder if the
// file name starts with "index". However, this is problematic when the
// parent folder includes the parent directory of what the developer
// considers to be the root of the source tree. If that happens, strip the
// parent folder to avoid including it in the generated name.
if relative, ok := args.fs.Rel(args.options.AbsOutputBase, pathForIdentifierName); ok {
for {
next := strings.TrimPrefix(strings.TrimPrefix(relative, "../"), "..\\")
if relative == next {
break
}
relative = next
}
pathForIdentifierName = relative
}

source := logger.Source{
Index: args.sourceIndex,
KeyPath: args.keyPath,
PrettyPath: args.prettyPath,
IdentifierName: js_ast.GenerateNonUniqueNameFromPath(args.keyPath.Text),
IdentifierName: js_ast.GenerateNonUniqueNameFromPath(pathForIdentifierName),
}

var loader config.Loader
Expand Down Expand Up @@ -1857,15 +1875,20 @@ func (s *scanner) addEntryPoints(entryPoints []EntryPoint) []graph.EntryPoint {
return nil
}

// Parse all entry points that were resolved successfully
// Determine output paths for all entry points that were resolved successfully
type entryPointToParse struct {
index int
parse func() uint32
}
var entryPointsToParse []entryPointToParse
for i, info := range entryPointInfos {
if info.results == nil {
continue
}

for _, resolveResult := range info.results {
resolveResult := resolveResult
prettyPath := resolver.PrettyPath(s.fs, resolveResult.PathPair.Primary)
sourceIndex := s.maybeParseFile(resolveResult, prettyPath, nil, logger.Range{}, nil, inputKindEntryPoint, nil)
outputPath := entryPoints[i].OutputPath
outputPathWasAutoGenerated := false

Expand Down Expand Up @@ -1900,9 +1923,17 @@ func (s *scanner) addEntryPoints(entryPoints []EntryPoint) []graph.EntryPoint {
outputPathWasAutoGenerated = true
}

// Defer parsing for this entry point until later
entryPointsToParse = append(entryPointsToParse, entryPointToParse{
index: len(entryMetas),
parse: func() uint32 {
return s.maybeParseFile(resolveResult, prettyPath, nil, logger.Range{}, nil, inputKindEntryPoint, nil)
},
})

entryMetas = append(entryMetas, graph.EntryPoint{
OutputPath: outputPath,
SourceIndex: sourceIndex,
SourceIndex: ast.InvalidRef.SourceIndex,
OutputPathWasAutoGenerated: outputPathWasAutoGenerated,
})
}
Expand All @@ -1924,6 +1955,11 @@ func (s *scanner) addEntryPoints(entryPoints []EntryPoint) []graph.EntryPoint {
}
}

// Only parse entry points after "AbsOutputBase" has been determined
for _, toParse := range entryPointsToParse {
entryMetas[toParse.index].SourceIndex = toParse.parse()
}

// Turn all output paths back into relative paths, but this time relative to
// the "outbase" value we computed above
for i := range entryMetas {
Expand Down Expand Up @@ -2541,11 +2577,13 @@ func (s *scanner) processScannedFiles(entryPointMeta []graph.EntryPoint) []scann
// the entry point itself.
customFilePath := ""
useOutputFile := false
isEntryPoint := false
if result.file.inputFile.Loader == config.LoaderCopy {
if metaIndex, ok := entryPointSourceIndexToMetaIndex[uint32(sourceIndex)]; ok {
template = s.options.EntryPathTemplate
customFilePath = entryPointMeta[metaIndex].OutputPath
useOutputFile = s.options.AbsOutputFile != ""
isEntryPoint = true
}
}

Expand Down Expand Up @@ -2596,8 +2634,14 @@ func (s *scanner) processScannedFiles(entryPointMeta []graph.EntryPoint) []scann
helpers.QuoteForJSON(result.file.inputFile.Source.PrettyPath, s.options.ASCIIOnly),
len(bytes),
)
entryPointJSON := ""
if isEntryPoint {
entryPointJSON = fmt.Sprintf("\"entryPoint\": %s,\n ",
helpers.QuoteForJSON(result.file.inputFile.Source.PrettyPath, s.options.ASCIIOnly))
}
jsonMetadataChunk = fmt.Sprintf(
"{\n \"imports\": [],\n \"exports\": [],\n \"inputs\": %s,\n \"bytes\": %d\n }",
"{\n \"imports\": [],\n \"exports\": [],\n %s\"inputs\": %s,\n \"bytes\": %d\n }",
entryPointJSON,
inputs,
len(bytes),
)
Expand Down
31 changes: 28 additions & 3 deletions internal/bundler_tests/bundler_dce_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1272,9 +1272,9 @@ func TestTreeShakingReactElements(t *testing.T) {
}

func TestDisableTreeShaking(t *testing.T) {
defines := config.ProcessDefines(map[string]config.DefineData{
"pure": {Flags: config.CallCanBeUnwrappedIfUnused},
"some.fn": {Flags: config.CallCanBeUnwrappedIfUnused},
defines := config.ProcessDefines([]config.DefineData{
{KeyParts: []string{"pure"}, Flags: config.CallCanBeUnwrappedIfUnused},
{KeyParts: []string{"some", "fn"}, Flags: config.CallCanBeUnwrappedIfUnused},
})
dce_suite.expectBundled(t, bundled{
files: map[string]string{
Expand Down Expand Up @@ -1405,6 +1405,31 @@ func TestDeadCodeFollowingJump(t *testing.T) {
})
}

func TestDeadCodeInsideEmptyTry(t *testing.T) {
dce_suite.expectBundled(t, bundled{
files: map[string]string{
"/entry.js": `
try { foo() }
catch { require('./a') }
finally { require('./b') }
try {}
catch { require('./c') }
finally { require('./d') }
`,
"/a.js": ``,
"/b.js": ``,
"/c.js": `TEST FAILED`, // Dead code paths should not import code
"/d.js": ``,
},
entryPaths: []string{"/entry.js"},
options: config.Options{
Mode: config.ModeBundle,
AbsOutputFile: "/out.js",
},
})
}

func TestRemoveTrailingReturn(t *testing.T) {
dce_suite.expectBundled(t, bundled{
files: map[string]string{
Expand Down
Loading

0 comments on commit 6ec5842

Please sign in to comment.