deno

2021年前端会有什么新变化?

China☆狼群 提交于 2021-01-20 03:48:26
2020年前端圈带来具有突破意义的内容或框架不多,也不会再有2013年到2017间日日新的框架大战局面,也不会有Node全栈之争,也不会因为React-Native、Weex、Flutter这类跨端而欣喜若狂。 我能看到的是今天前端已趋于稳定,在深水区探索,比如蚂蚁金服的x6,在图形可视化方面做的就是非常好,比如淘宝的midway-faas,在Serverless领域确实有它独特的定位。比如语雀,钉钉文档,在线Excel等等,也都不是可以轻松可以搞定的。 我很开心的看到,混乱之后,大家都能在深水区里进行探索。2019年阿里经济体前端委员会四大技术方向:第一搭建服务,第二是 Serverless,第三是智能化,第四是 IDE。2020年阿里经济体前端委员的突破方向是互动技术、跨端技术、智能化。而中后台、数据可视化、Node.js(Serverless)、工程体系(安全生产)都变成了基础技术方向。这大概是能够代表前端技术走向的。 我个人也走过类似的路,2017年加入阿里,将 PHP 替换为Node.js,随后搞了开源项目egg-react-ssr,然后在2019年加入前端委员会,负责Serverless-side render方向。在2020年,转岗到淘系前端,负责前端智能化相关开发。我其实是非常看好Serverless的,Serverless这种稳步推进的必然是前端新基建

Deno Oak Disable Cors

。_饼干妹妹 提交于 2021-01-19 06:44:22
问题 I am trying to 'connect' my small React JS app with my Deno API backend on my local environment with fetch() . const apiUrl = `http://localhost:8000`; try{ fetch(apiUrl) .then((res) => res.json()) .then((repos) => { console.log(repos); setAppState({ loading: false, repos: repos }); }); }catch(err){ console.log(err); } My app is serving on localhost:3000 and my deno api on localost:8000 . However, I am having problem with CORS: Access to fetch at 'http://localhost:8000/' from origin 'http:/

TypeScript import with extension

こ雲淡風輕ζ 提交于 2021-01-03 06:38:04
问题 You may have heard of Deno which is a new TypeScript runtime. One major difference between Deno and normal TypeScript is that you must include the file extension in the import statement. e.g: import foo from './bar.ts' ^^ I would like to write code that is compatible with both Deno and Webpack. How can I configure Webpack to allow importing with .ts extension like above? Also, how can I prevent the following VSCode error? 回答1: Webpack can be configured to resolve the extensions of all imports

TypeScript inconsistent check for undefined — Why do I need an exclamation point here?

心不动则不痛 提交于 2020-12-21 05:08:19
问题 I'm trying to understand the automatic type rules. In this example I Have a function with an optional parameter. Check if it's undefined and if so fill in a new value. Use it. And finally return it. Steps 1, 2 and 4 work as expected. At step 4 typescript clearly knows that the "map" parameter cannot be undefined. But at step 3 I have to explicitly add an ! or I will get an error message. The code works (now that I've added the exclamation/assertion) but it does not make sense. Is this the

TypeScript inconsistent check for undefined — Why do I need an exclamation point here?

折月煮酒 提交于 2020-12-21 05:03:51
问题 I'm trying to understand the automatic type rules. In this example I Have a function with an optional parameter. Check if it's undefined and if so fill in a new value. Use it. And finally return it. Steps 1, 2 and 4 work as expected. At step 4 typescript clearly knows that the "map" parameter cannot be undefined. But at step 3 I have to explicitly add an ! or I will get an error message. The code works (now that I've added the exclamation/assertion) but it does not make sense. Is this the

TypeScript inconsistent check for undefined — Why do I need an exclamation point here?

家住魔仙堡 提交于 2020-12-21 05:02:51
问题 I'm trying to understand the automatic type rules. In this example I Have a function with an optional parameter. Check if it's undefined and if so fill in a new value. Use it. And finally return it. Steps 1, 2 and 4 work as expected. At step 4 typescript clearly knows that the "map" parameter cannot be undefined. But at step 3 I have to explicitly add an ! or I will get an error message. The code works (now that I've added the exclamation/assertion) but it does not make sense. Is this the

TypeScript inconsistent check for undefined — Why do I need an exclamation point here?

风流意气都作罢 提交于 2020-12-21 05:00:51
问题 I'm trying to understand the automatic type rules. In this example I Have a function with an optional parameter. Check if it's undefined and if so fill in a new value. Use it. And finally return it. Steps 1, 2 and 4 work as expected. At step 4 typescript clearly knows that the "map" parameter cannot be undefined. But at step 3 I have to explicitly add an ! or I will get an error message. The code works (now that I've added the exclamation/assertion) but it does not make sense. Is this the

How to manage Deno dependencies in one place

孤街浪徒 提交于 2020-12-12 13:48:03
问题 In Deno it is possible to version the dependencies in the import statement, and there's no package.json like with npm . But how to managed it's URLs and versions in a single place? I will have multiple files and dependencies that will be declared all over my system. For example: dateUtils.ts import { parseDate } from 'https://deno.land/std@0.50.0/datetime/mod.ts'; const DEFAULT_MASK = "dd-mm-yyyy"; export function parse(date: string): Date { return parseDate(date, DEFAULT_MASK); }; service.ts

How to manage Deno dependencies in one place

耗尽温柔 提交于 2020-12-12 13:47:47
问题 In Deno it is possible to version the dependencies in the import statement, and there's no package.json like with npm . But how to managed it's URLs and versions in a single place? I will have multiple files and dependencies that will be declared all over my system. For example: dateUtils.ts import { parseDate } from 'https://deno.land/std@0.50.0/datetime/mod.ts'; const DEFAULT_MASK = "dd-mm-yyyy"; export function parse(date: string): Date { return parseDate(date, DEFAULT_MASK); }; service.ts

什么是架构师的必备技能?

北城以北 提交于 2020-12-04 06:03:10
搭建项目脚手架工程 是 架构师必需必会的基础技能 。 在脚手架的帮助下,我们只需要跑一个命令就可以生成一个项目,不需要再思考项目的目录结构,单元测试,所需要的依赖等繁琐的事情。 虽然脚手架一般只用于前端工作流中项目的起始阶段,而且由于“用后即弃”的性质,并不被前端工程化领域所重视。但 随着前端工程体系越来越复杂,脚手架的重要性却在逐渐突出。 引用 《前端工程化:体系设计与实践》 书里的一段话:“前端工程体系的功能涵盖范围广,封装的方案类型多,对应的配置项也非常复杂。对于多数业务开发者来说,他们不需要了解其中的复杂原理,只需要知道如何配置即可。” 这就要求脚手架能够快速开发快速配置,将非必要的工程化体系的技术细节封装到一个黑盒中,把一线业务开发人员从不必要的工程体系相关繁琐的工作开发任务隔离开来,提高相关业务人员关注的业务本身,提高专注性,提高生产效率。 轻松构建你自己的脚手架 我们熟知的vue-cli,create-react-app都是前端圈最知名、最流行、最大众化的脚手架工具,但是实际工作的时候,常常会有凭现有工具无法满足的复杂需求。 这就需要我们掌握快速开发自己的脚手架工具的能力。 在这里给大家推荐一套视频教程—— 《从0到1用Node完成一个CLI工具》 帮助你: 从零构建一个Cli工具 command命令行 模板库代码拉取 Vue约定路由功能 npm库发布