Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: support ?raw for ts #3435

Open
ouzhou opened this issue Sep 10, 2024 · 5 comments
Open

[Feature]: support ?raw for ts #3435

ouzhou opened this issue Sep 10, 2024 · 5 comments

Comments

@ouzhou
Copy link

ouzhou commented Sep 10, 2024

What problem does this feature solve?

import LODASH_array from '@types/lodash/common/array.d.ts?raw';

I want to return a string

What does the proposed API look like?

As intuition suggests, any file should only return a string after concatenating this suffix
The current situation is that this suffix function only supports files other than ts like 'txt' etc....

@SoonIter
Copy link
Member

you could try use tools.rspack or tools.bundlerChain to support resourceQuery like svgr plugin

https://rsbuild.dev/plugins/list/plugin-svgr#svgroptionsexporttype
https://github.com/web-infra-dev/rsbuild/tree/main/packages/plugin-svgr

@ouzhou
Copy link
Author

ouzhou commented Sep 10, 2024

see #3070

@SoonIter
Copy link
Member

SoonIter commented Sep 10, 2024

could you add enforce: 'pre' to your rule? @ouzhou

@ouzhou
Copy link
Author

ouzhou commented Sep 10, 2024

I tried all the parameters of enforce from the beginning

import str from "!./myType.ts?raw";
add ! can reslove this , but use ! is not a intuitive writing style

Without this feature, I find it difficult to migrate painlessly from vite
https://vitejs.dev/guide/assets.html#importing-asset-as-string

@eatfishs
Copy link

Image
Image
我主动为“?raw”结尾的链接添加了“!”,折中的实现了和vite类似的效果

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants