From 6e9fa9e0fd15f2e373873e9ddfc888879c15e28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Mon, 16 Jan 2023 09:53:17 +0100 Subject: [PATCH] deps: Upgrade github.com/evanw/esbuild v0.15.18 => v0.17.0 Also add a test to make sure legal comments are preserved in JS bundles. Closes #10536 --- go.mod | 2 +- go.sum | 2 + .../js/integration_test.go | 41 +++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 6e7c1258e..bab064029 100644 --- a/go.mod +++ b/go.mod @@ -19,7 +19,7 @@ require ( github.com/cli/safeexec v1.0.0 github.com/disintegration/gift v1.2.1 github.com/dustin/go-humanize v1.0.0 - github.com/evanw/esbuild v0.15.18 + github.com/evanw/esbuild v0.17.0 github.com/fortytw2/leaktest v1.3.0 github.com/frankban/quicktest v1.14.4 github.com/fsnotify/fsnotify v1.6.0 diff --git a/go.sum b/go.sum index b25dd9f2c..637bff303 100644 --- a/go.sum +++ b/go.sum @@ -240,6 +240,8 @@ github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go. github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/evanw/esbuild v0.15.18 h1:CM7eAoUjjNkZs1LH0p6fkwtADrbFr4JV2SlT1bUMjEo= github.com/evanw/esbuild v0.15.18/go.mod h1:iINY06rn799hi48UqEnaQvVfZWe6W9bET78LbvN8VWk= +github.com/evanw/esbuild v0.17.0 h1:gGx9TCZDO9k9x1PJdizx6syIpUq29RwrtHWlgDIdQH8= +github.com/evanw/esbuild v0.17.0/go.mod h1:iINY06rn799hi48UqEnaQvVfZWe6W9bET78LbvN8VWk= github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fortytw2/leaktest v1.3.0 h1:u8491cBMTQ8ft8aeV+adlcytMZylmA5nnwwkRZjI8vw= github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g= diff --git a/resources/resource_transformers/js/integration_test.go b/resources/resource_transformers/js/integration_test.go index ef371248c..023569b8d 100644 --- a/resources/resource_transformers/js/integration_test.go +++ b/resources/resource_transformers/js/integration_test.go @@ -303,3 +303,44 @@ IMPORT_SRC_DIR:imp3/foo.ts } } + +// See https://github.com/evanw/esbuild/issues/2745 +func TestPreserveLegalComments(t *testing.T) { + t.Parallel() + + files := ` +-- assets/js/main.js -- +/* @license + * Main license. + */ +import * as foo from 'js/utils'; +console.log("Hello Main"); +-- assets/js/utils/index.js -- +export * from './util1'; +export * from './util2'; +-- assets/js/utils/util1.js -- +/*! License util1 */ +console.log("Hello 1"); +-- assets/js/utils/util2.js -- +//! License util2 */ +console.log("Hello 2"); +-- layouts/index.html -- +{{ $js := resources.Get "js/main.js" | js.Build (dict "minify" false) }} +{{ $js.RelPermalink }} +` + + b := hugolib.NewIntegrationTestBuilder( + hugolib.IntegrationTestConfig{ + T: t, + NeedsOsFS: true, + TxtarString: files, + }).Build() + + b.AssertFileContent("public/js/main.js", ` +License util1 +License util2 +Main license + + `) + +}