Comments (3)
上课时老师说amd或cmd(以前)都是给前端用的规范,commonjs是给后端的,那现在前端用的规范是啥呢。现在都用import这个es6语法,可是这是不是叫做“es6规范”呢。用ts时有看到tsconfig.json文件里面会配置module:commonjs或者esnext,这些应该是去指定规范,可是文件里面还是都可以写import,难道commonjs也支持import了?
from 2019.03.
tsconfig.json 中 module 讲解如下:
target : "ES3" or "ES5" ? "CommonJS" : "ES6"
指定模块代码成:"None","CommonJS","AMD","System","UMD","ES6","ES2015"或"ESNext"。仅"AMD"和"System"可以一起使用--outFile。
ts写的代码,最终在不同环境运行(例如前端,node es5, node es6 ),所以这个时候module 要标明环境是 支持 commonjs 还是 esnext 还是 amd 。不然生成的代码不同是无法运行的
@zzs1020
from 2019.03.
@caihuiji 了解了 谢谢!
from 2019.03.
Related Issues (20)
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 2019.03.