Comments (4)
from react-ui.
嗯,没有加 .d.ts 文件,暂不支持 TypeScript
from react-ui.
还有一个问题。
我现在自己写d.tsx文件,例如我给Button.js 写了一个Button.d.ts
并且使用它
import Button from 'rctui/Button';
但是他会报错
./node_modules/rctui/Button.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: D:\demo\environment\node_modules\rctui\Button.js: Unexpected token (32:11)
我的babel配置如下
"@babel/core": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.0.0",
"@babel/runtime": "^7.0.0",
{
test: /\.(js|jsx|ts|tsx)$/,
use: 'babel-loader'
},
.babelrc
{
"presets": [
"@babel/preset-react",
[
"@babel/preset-env",
{
"modules": false,
"targets": {
"browsers": ["last 5 versions"]
},
"useBuiltIns": "usage"
}
],
"@babel/preset-typescript"
],
"plugins": [
[
"@babel/transform-runtime",
{
"helpers": false,
"regenerator": true
}
]
]
}
奇怪的是,我把button.js从node_modules文件放到src目录下,则不会报错,
后来经过测试放到node_modules/rctui里面的Button.js render函数内解析不了jsx,返回123456数字或者字符串则不会报错。
render() {
123456
}
因为用了babel7 目前找不到问题出在哪,感觉是babel7的问题
from react-ui.
因为看源码,rctui的按需加载是直接引用Button的,放到src目录下跟node_modules下是一样的。
我把错误复现放到了我的仓库上,如果作者有空的话,麻烦看一下,webpack4+babel7+tsx的一个环境。
在这里我说明一下,babel7支持typescript不再需要ts-loader
通过presets 的形式 "@babel/preset-typescript"
地址:https://github.com/Faithree/webpack-ci/tree/master/25-rctui
from react-ui.
Related Issues (20)
- 启动报错:You may need an appropriate loader to handle this file type. HOT 4
- react & typescript & webpack & ES6 HOT 1
- 请问下用antd表格columns的fixed 用‘left’和’right‘ 错怎么解决? HOT 1
- 关于css modules的问题 HOT 6
- 我在用web-dev-server时遇到下列问题 HOT 25
- 关于bootstrap4 HOT 6
- 1. Chrome65下行首没有办法输入正确的中文 HOT 1
- The module needs to be precompiled to ES5 before use
- 关于table的问题 HOT 5
- table中pagination中的onChange问题 HOT 13
- Checkbox 使用后为何不能点击? HOT 16
- DatepickerRange数据验证逻辑错误 HOT 1
- 您好,请问如何开发类似的一套ui库,让其他人可供使用的。 HOT 1
- Table控件选中记录操作
- Datepicker的min值判断的问题 HOT 2
- webpack include 和 exclude的配置问题 HOT 2
- 地址打不开。 HOT 3
- Message模块下似乎有BUG HOT 1
- Trying to get in touch regarding a security issue
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-ui.