mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
js: Pass tsconfig.json to esBuild
Note that esBuild only inspects/honors certain fields. See https://esbuild.github.io/content-types/#tsconfig-json. Fixes #11232
This commit is contained in:
parent
5bec50838c
commit
f1886f8c37
2 changed files with 40 additions and 10 deletions
|
@ -86,6 +86,7 @@ func (t *buildTransformation) Transform(ctx *resources.ResourceTransformationCtx
|
||||||
opts.resolveDir = t.c.rs.Cfg.BaseConfig().WorkingDir // where node_modules gets resolved
|
opts.resolveDir = t.c.rs.Cfg.BaseConfig().WorkingDir // where node_modules gets resolved
|
||||||
opts.contents = string(src)
|
opts.contents = string(src)
|
||||||
opts.mediaType = ctx.InMediaType
|
opts.mediaType = ctx.InMediaType
|
||||||
|
opts.tsConfig = t.c.rs.ResolveJSConfigFile("tsconfig.json")
|
||||||
|
|
||||||
buildOptions, err := toBuildOptions(opts)
|
buildOptions, err := toBuildOptions(opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -344,3 +344,32 @@ Main license
|
||||||
`)
|
`)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue #11232
|
||||||
|
func TestTypeScriptExperimentalDecorators(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
disableKinds = ['RSS','sitemap','taxonomy','term']
|
||||||
|
-- tsconfig.json --
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
-- assets/ts/main.ts --
|
||||||
|
function addFoo(target: any) {target.prototype.foo = 'bar'}
|
||||||
|
@addFoo
|
||||||
|
class A {}
|
||||||
|
-- layouts/index.html --
|
||||||
|
{{ $opts := dict "target" "es2020" "targetPath" "js/main.js" }}
|
||||||
|
{{ (resources.Get "ts/main.ts" | js.Build $opts).Publish }}
|
||||||
|
`
|
||||||
|
b := hugolib.NewIntegrationTestBuilder(
|
||||||
|
hugolib.IntegrationTestConfig{
|
||||||
|
T: t,
|
||||||
|
NeedsOsFS: true,
|
||||||
|
TxtarString: files,
|
||||||
|
}).Build()
|
||||||
|
b.AssertFileContent("public/js/main.js", "__decorateClass")
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue