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

2019前端面试题 —— Node相关 #14

Open
fengmiaosen opened this issue Jul 8, 2019 · 0 comments
Open

2019前端面试题 —— Node相关 #14

fengmiaosen opened this issue Jul 8, 2019 · 0 comments

Comments

@fengmiaosen
Copy link
Owner

fengmiaosen commented Jul 8, 2019

  1. require加载模块的机制

    https://juejin.im/entry/5b4b5081e51d451984696cb7

  2. Webpack 的构建流程

    Webpack 的构建流程可以分为以下三大阶段:

    • 初始化:启动构建,读取与合并配置参数,加载 Plugin,实例化 Compiler。
    • 编译:从 Entry 发出,针对每个 Module 串行调用对应的 Loader 去翻译文件内容,再找到该 Module 依赖的 Module,递归地进行编译处理。
    • 输出:对编译后的 Module 组合成 Chunk,把 Chunk 转换成文件,输出到文件系统。

    https://juejin.im/entry/5b0e3eba5188251534379615

  3. npm link

    npm link 专门用于开发和调试本地 Npm 模块,能做到在不发布模块的情况下,把本地的一个正在开发的模块的源码链接到项目的 node_modules 目录下,让项目可以直接使用本地的 Npm 模块。 由于是通过软链接的方式实现的,编辑了本地的 Npm 模块代码,在项目中也能使用到编辑后的代码。

    完成 npm link 的步骤如下:

    • 确保正在开发的本地 Npm 模块(也就是正在开发的 Loader)的 package.json 已经正确配置好;
    • 在本地 Npm 模块根目录下执行 npm link,把本地模块注册到全局;
    • 在项目根目录下执行 npm link loader-name,把第2步注册到全局的本地 Npm 模块链接到项目的 node_moduels 下,其中的 loader-name 是指在第1步中的 package.json 文件中配置的模块名称。
    • 链接好 Loader 到项目后你就可以像使用一个真正的 npm 模块一样使用本地的 npm模块了
  4. Koa2 中间件原理解析

    https://juejin.im/post/5ba7868e6fb9a05cdf309292

  5. Koa 的洋葱模型

    浅析koa的洋葱模型实现
    从头实现一个koa框架

  6. webpack 插件 prerender-spa-plugin

    单页应用预渲染插件,此插件在本地模拟浏览器环境,预先执行我们的打包文件,这样通过解析就可以获取首屏的 HTML,在正常环境中,我们就可以返回预先解析好的 HTML

    prerender-spa-plugin

  7. ORM

    对象关系映射(Object Relational Mapping,简称ORM)是通过使用描述对象和数据库之间映射的元数据,将面向对象语言程序中的对象自动持久化到关系数据库中。 本质上就是将数据从一种形式转换到另外一种形式。

  8. util.promisify实现原理

function util (func) {
  return (...arg) => new Promise((resolve, reject) => {
    func(...arg, (err, arg) => {
      if (err) reject(err)
      else resolve(arg)
    })
  })
}
  1. Node多线程

    https://juejin.im/post/5c63b5676fb9a049ac79a798

    worker_threads

参考资料

@fengmiaosen fengmiaosen changed the title 2019前端面试题(一)—— Node,相关 2019前端面试题(一)—— Node相关 Jul 8, 2019
@fengmiaosen fengmiaosen changed the title 2019前端面试题(一)—— Node相关 2019前端面试题 —— Node相关 Jul 8, 2019
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

1 participant