Skip to content

Razor class library doesn't add associated Js file generated by typescript. #59188

Closed
@p6laris

Description

@p6laris

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a Razor Class Library (RCL) that includes a TypeScript file for JavaScript interop. When the TypeScript compiles into a JavaScript file and outputs it to the wwwroot directory, the generated JavaScript file is not found when using the component and getting 404 notfound error, after migrating to .NET 9. Also tried #57662

I configured the TS with tsconfig.json, then I tried the MSBuild options in the csproj even though added the following configuration to the file, i encounter the same issue:

<PropertyGroup>
	<TypeScriptOutFile>wwwroot\example.js</TypeScriptOutFile>
	<TypeScriptTarget>ES2016</TypeScriptTarget>
	<TypeScriptAlwaysStrict>true</TypeScriptAlwaysStrict>
	<TypeScriptInclude>Interop\*.ts</TypeScriptInclude>
	<PrepareForBuildDependsOn>
		CompileTypeScript;
		GetTypeScriptOutputForPublishing;$(PrepareForBuildDependsOn)
	</PrepareForBuildDependsOn>
	<TypeScriptSourceMap>false</TypeScriptSourceMap>
</PropertyGroup>

Surprisingly, when i include the TS source map with <TypeScriptSourceMap>true</TypeScriptSourceMap> it works, but will serve the TS file too.

Expected Behavior

The js file should be included in the `_content/MyComponent/example.js".

Steps To Reproduce

No response

Exceptions (if any)

No response

.NET Version

.NET 9

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: Attention 👋This issue needs the attention of a contributor, typically because the OP has provided an update.Needs: ReproIndicates that the team needs a repro project to continue the investigation on this issuearea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions