-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
👑 [需求] 移除*.less中的@import ~ 前置符号,兼容ESM构建工具 #1933
Comments
来个pr支持一下? |
在snowpack项目中也是无法运行, #1885 |
还没搞定? |
暂时通过这个方式解决:vitejs/vite#2185 (comment) _(:3J∠)_ |
要 umi 提个 pr,我一直没空搞 |
这是什么意思?跟 umi 有什么关系吗?:joy: |
我们项目使用 umi做脚手架的,改了之后我们的项目就跑不起来 |
这样啊,那我觉得 vite 用我楼上的临时方案也挺好的。umi 要做这个支持改动大吗?不太了解这一块。 |
不大,增加个预设就行了,兼容原来的 |
这行加进去,你有兴趣可以试试 |
@chenshuai2144 大佬看看这样处理对吗?这个没有测试用例 |
link 到 项目中试试呢? pro 项目就是用来做这种测试的 |
@chenshuai2144 好像问题挺大的,先在本地 link 试了一下,解析失败。重新研究了相关文档,最后看了 less-loader 的 release 发现了问题:
如果按照 release 的说法, 至于像 Vite 之类的构建工具,短期来看可能还是上面提到的通过 alias 的方式更有效: export default defineConfig({
// ...
resolve: {
alias: [
{ find: /^~/, replacement: '' }
],
}
}); |
这个看来还需要一段时间才能实现 |
This PR fixes this error im having?
Sorry to ask, can't understand chinese and google doesn't help much :( |
打包时,ts 转 js,有2中方式:tsc 、babel。 具体区别:https://www.typescriptlang.org/docs/handbook/babel-with-typescript.html#babel-vs-tsc-for-typescript 上面的报错,是打包用了 tsc 方式。比如vite,可以看package.json脚本: 由于 tsc 打包会做类型校验。导致上面的错误,因为底层的路径错了,pro-components里.d.ts声明没有provider目录,只有pro-provider目录。 可考虑用 babel 方式打包,实测可行。 package.json: "build": "vite build" vite.config.js 参考 import babel from 'rollup-plugin-babel';
import { DEFAULT_EXTENSIONS } from '@babel/core';
export default defineConfig({
plugins: [react()],
build: {
rollupOptions: {
babel({
exclude: 'node_modules/**',
extensions: [
...DEFAULT_EXTENSIONS,
'.ts',
'.tsx'
]
}),
}
}
}) 或者tsconfig.json 中改。tsconfig 配置参考:https://www.tslang.cn/docs/handbook/compiler-options.html skipLibCheck: true // 默认是 false. 忽略 库的默认声明文件的类型检查。 可能改后还是有问题。没具体实践,后来看到的。 |
import babel from 'rollup-plugin-babel';
import { DEFAULT_EXTENSIONS } from '@babel/core';
export default defineConfig({
plugins: [react()],
build: {
rollupOptions: babel({
exclude: 'node_modules/**',
extensions: [
...DEFAULT_EXTENSIONS,
'.ts',
'.tsx'
]
})
}
}) |
The
Actually, the import is coming from this library, I cannot modify the import path directly. Do we have some news on the issue? |
已经告别了 less了,现在可以很简单的使用了 |
看起来 pro-components 也重构成 cssinjs 了,那服务端渲染是不是要做特殊处理才行? |
这个有解决吗? |
🥰 需求描述
移除*.less中的@import
~
前置符号,兼容ESM构建工具,例如:Vite🧐 解决方案
less-loader 现在也推荐移除
~
符号https://github.com/webpack-contrib/less-loader#imports
🚑 其他信息
The text was updated successfully, but these errors were encountered: