From 900a90d533c8e1d10a8b1d04251c7ab83d92ecfc Mon Sep 17 00:00:00 2001 From: Evan Wallace Date: Wed, 13 Sep 2023 19:42:58 -0400 Subject: [PATCH] transform: banner/footer with local-css/global-css --- pkg/api/api_impl.go | 2 +- scripts/js-api-tests.js | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/pkg/api/api_impl.go b/pkg/api/api_impl.go index ebe7df7a3d2..c471d071b71 100644 --- a/pkg/api/api_impl.go +++ b/pkg/api/api_impl.go @@ -1768,7 +1768,7 @@ func transformImpl(input string, transformOpts TransformOptions) TransformResult SourceFile: transformOpts.Sourcefile, }, } - if options.Stdin.Loader == config.LoaderCSS { + if options.Stdin.Loader.IsCSS() { options.CSSBanner = transformOpts.Banner options.CSSFooter = transformOpts.Footer } else { diff --git a/scripts/js-api-tests.js b/scripts/js-api-tests.js index 261e2761c4c..3c5d822c2a1 100644 --- a/scripts/js-api-tests.js +++ b/scripts/js-api-tests.js @@ -5302,14 +5302,16 @@ let transformTests = { }, async cssBannerFooterTransform({ esbuild }) { - var { code } = await esbuild.transform(` - div { color: red } - `, { - loader: 'css', - banner: '/* banner */', - footer: '/* footer */', - }) - assert.strictEqual(code, `/* banner */\ndiv {\n color: red;\n}\n/* footer */\n`) + for (const loader of ['css', 'local-css', 'global-css']) { + var { code } = await esbuild.transform(` + div { color: red } + `, { + loader, + banner: '/* banner */', + footer: '/* footer */', + }) + assert.strictEqual(code, `/* banner */\ndiv {\n color: red;\n}\n/* footer */\n`) + } }, async transformDirectEval({ esbuild }) {