Repository: Kingbultsea/vite-analysis Branch: master Commit: c51b9282f05d Files: 64 Total size: 395.0 KB Directory structure: gitextract_xl9jd137/ ├── 101-110/ │ └── commit-101-110.md ├── 11-20/ │ ├── commit-11-20.md │ └── main.rs ├── 111-120/ │ └── commit-111-120.md ├── 121-130/ │ └── commit-121-130.md ├── 131-140/ │ └── commit-131-140.md ├── 141-150/ │ └── commit-141-150.md ├── 151-160/ │ └── 151-160.md ├── 161-170/ │ └── 161-170.md ├── 171-180/ │ └── 171-180.md ├── 181-190/ │ └── 181-190.md ├── 191-200/ │ └── 191-200.md ├── 201-210/ │ └── 201-210.md ├── 21-30/ │ └── commit-21-30.md ├── 211-220/ │ └── 211-220.md ├── 221-230/ │ └── 221-230.md ├── 231-240/ │ └── 231-240.md ├── 241-250/ │ └── 241-250.md ├── 251-260/ │ └── 251-260.md ├── 261-270/ │ └── 261-270.md ├── 271-280/ │ └── 271-280.md ├── 281-290/ │ └── 281-290.md ├── 291-300/ │ └── 291-300.md ├── 301-310/ │ └── 301-310.md ├── 31-40/ │ └── commit-31-40.md ├── 311-320/ │ └── 311-320.md ├── 321-330/ │ └── 321-330.md ├── 331-340/ │ └── 331-340.md ├── 341-350/ │ └── 341-350.md ├── 351-360/ │ └── 351-360.md ├── 361-370/ │ └── 361-370.md ├── 371-380/ │ └── 371-380.md ├── 381-390/ │ └── 381-390.md ├── 391-400/ │ └── 391-400.md ├── 401-410/ │ └── 401-410.md ├── 41-50/ │ └── commit-41-50.md ├── 411-420/ │ └── 411-420.md ├── 421-430/ │ └── 421-430.md ├── 431-440/ │ └── 431-440.md ├── 441-450/ │ └── 441-450.md ├── 451-460/ │ └── 451-460.md ├── 461-470/ │ └── 461-470.md ├── 471-480/ │ └── 471-480.md ├── 481-490/ │ └── 481-490.md ├── 491-500/ │ └── 491-500.md ├── 501-510/ │ └── 501-510.md ├── 51-60/ │ └── commit-51-60.md ├── 511-520/ │ └── 511-520.md ├── 521-530/ │ └── 521-530.md ├── 531-540/ │ └── 531-540.md ├── 541-550/ │ └── 541-550.md ├── 551-560/ │ └── 551-560.md ├── 561-570/ │ └── 561-570.md ├── 571-580/ │ └── 571-580.md ├── 581-590/ │ └── 581-590.md ├── 591-600/ │ └── 591-600.md ├── 601-610/ │ └── 601-610.md ├── 61-70/ │ └── commit-61-70.md ├── 611-620/ │ └── 611-620.md ├── 71-80/ │ └── commit-71-80.md ├── 81-90/ │ └── commit-81-90.md ├── 91-100/ │ └── commit-91-100.md ├── readme.md └── temp/ └── temp.md ================================================ FILE CONTENTS ================================================ ================================================ FILE: 101-110/commit-101-110.md ================================================ # 101 - d1fe471 新增id映射到请求路径 允许`resolver`拥有`idToRequest`方法。 ```typescript idToRequest: (id: string) => { for (const r of resolvers) { const request = r.idToRequest && r.idToRequest(id) if (request) return request } } ``` ## 影响范围? 在`serverPluginModules.ts`中的`rewriteImports`,会利用`idToRequest`作为**模块改写的路径**。 ```typescript if (/^[^\/\.]/.test(id)) { // import lodash from 'lodash' const rewritten = resolver.idToRequest(id) || `/@modules/${id}` s.overwrite(start, end, rewritten) hasReplaced = true debugImportRewrite(` "${id}" --> "${rewritten}"`) } ``` ## 可能引起的BUG? ```typescript # serverPluginModules // handle /@modules/:id requests const moduleRE = /^\/@modules\// ``` 无法正确解析模块了。 # 102 - fe1ef5a 修复传入的路径类型 修复`handleJSReload`: 原本传入的是`filePath`,真正需要的是`publicPath`。 # 103 - ab2610f 使`js`与`vue`的`reload`方法传入的`timeStamp`参数为可选选项 在重载方法中使时间戳成为可选的。 ```typescript export type ViteWatcher = FSWatcher & { handleVueReload: (file: string, timestamp?: number, content?: string) => void handleJSReload: (file: string, timestamp?: number) => void } ``` # 104 - 3fce891 @xxx自动转变为/@xxx 顺带整理一下改写`import`语句的代码。 把`resolver.idToRequest.defaultIdToRequest`的@id字符转为'/@id'。 把`vue组件`的`import`语句`/@hmr`改写为`@hmr`。 1. 一个`vue组件`,经过`serverPluginVue.ts`处理,变成`import { updateStyle } from '@hmr'`。 2. 经过`serverPluginServe.ts`中的`resolver.idToRequest.defaultToRequest`处理,变成`import { updateStyle } from '/@hmr'` # 105 - c4a2d40 因104修改reademe文档 ### HMR所做的替换 - `*.vue` files come with HMR out of the box. - For `*.js` files, a simple HMR API is provided: ```js import { foo } from './foo.js' import { hot } from '@hmr' // 以前是/@hmr foo() hot.accept('./foo.js', ({ foo }) => { // the callback receives the updated './foo.js' module foo() }) ``` ## `hmr`对`js`文件无效 原因很简单,`importerMap`的键为`filePath`,而`handleJSReload`使用了`publicPath`来获取`importer`。 > 再次提醒importer为引入文件,importee为被引入文件 # 106 - 4c354ca hot路径修改 ```typescript // 以前: hot.accept("/fc.js", "\\foo.js", ({ foo }) => { // the callback receives the updated './foo.js' module foo() }) // 现在 hot.accept("/fc.js", "E:/foo.js", ({ foo }) => { // the callback receives the updated './foo.js' module foo() }) ``` `parseAcceptedDeps`: ![](./1.png) 这里我有些小失误,没有去讲解hot的使用问题,我在51-60commit重新补充了`handleJSReload`相关的。`parseAcceptedDeps`可以把他当作收集依赖与`hot.accept`表达式的改写,例如上面的例子`foo.js`依赖`fc.js`文件。 # 107 - e42d74d `serverPluginsVue`错误提示 添加错误提示(`template script style`) # 108 - 4ac0801 index.html重写缓存 对于`index.html`文件,`rewriteCache`的`key`变成`ctx.body`。 我个人觉得改不改一样,对于功能上,也许更符合语义吧... 但`rewriteCache`的体积会变得更大,因为没有地方删除以前的内容(除非是超出LRU max)。 # 109 - ea97e3b 修复`build.ts`路径处理bug 由于之前把@xxx弄成自动的,在`build`环境下,就不是自动的了。 所以`vitePlugin`(rollup插件)的`resolveId`需要改写。 # 110 - a22472d `hmr`添加新事件`custom` 整理代码命名。 ```typescript # client.ts const customUpdateMap = new Map void)[]>() case 'custom': const cbs = customUpdateMap.get(id) if (cbs) { cbs.forEach((cb) => cb(customData)) } break export const hot = { on(event: string, cb: () => void) { const exisitng = customUpdateMap.get(event) || [] exisitng.push(cb) customUpdateMap.set(event, exisitng) } } ``` 未能分析其作用,将在后续commit解说其作用。 > 看出个大概就是服务端与client端能通过一个事件交流数据`customData`。 ================================================ FILE: 11-20/commit-11-20.md ================================================ # 11 - 7f207eb annotation 添加测试注释(准备测试style HMR)。 # 12 - 5c0f552 fix propublishOnly 注释。 ```json { - prepublishOnly: "tsc" + propublishOnly: "yarn build" } ``` # 13 - be00e79 v0.1.0发布 修改旧名称 ```vds```为```vite```,包括注释,控制台输出,只是更改名称。 # 14 - a47c406 设置npm上传包含的文件 `files` 字段用于描述我们使用 `npm publish` 命令后推送到 `npm` 服务器的文件列表,如果指定文件夹,则文件夹内的所有内容都会包含进来。我们可以查看下载的 `antd` 的 `package.json` 的`files` 字段,内容如下: ```json "files": [ "dist", + "bin" ], ``` 因为```dist```是```build```的文件,```/bin/vite.js```是启动文件,所以这一部分发布到```npm```,提供用户使用即可。 # 15 - a4f093a v0.1.1发布 ```json { - version: "0.1.1" + version: "0.1.1" } ``` # 16 - d58893b chore readme ```chore: readme```,修改```readme```。 # 17 - c76ca14 添加ci ```yml version: 2 defaults: &defaults docker: - image: vuejs/ci # https://hub.docker.com/r/vuejs/ci step_restore_cache: &restore_cache restore_cache: keys: - v1-dependencies-{{ checksum "yarn.lock" }}-1 - v1-dependencies- step_install_deps: &install_deps run: name: Install Dependencies command: yarn --frozen-lockfile step_save_cache: &save_cache save_cache: paths: - node_modules - ~/.cache/yarn key: v1-dependencies-{{ checksum "yarn.lock" }}-1 jobs: test: <<: *defaults steps: - checkout - *restore_cache - *install_deps - *save_cache - run: yarn test workflows: version: 2 ci: jobs: - test ``` setp1: 在自身```Github```上,创建一个```public```仓库,命名为```sbuild```,并把上传这一份代码。 step2: 使用该```github```账号登录```circleci```网站,在目录列表点击```Set Up Project ```。 ![](./circle-view.png) step3: 点击``Start Building`` ![](./circle-test.png) (失败可以不用管,这是运行test命令失败,在不同平台有些不一样) # 18 - 97de06e test: fix pupeteer on ci 修复在```ci```环境下的,```puppeteer```报错问题(如上报错)。 ![](circle-sussess.png) # 19 - bb9baa2 使用本包,如果用户没有vue ### moduleResolver.ts 整理代码,如果用户本地路径没有寻找到```vue.runtime.esm-browser.js```,则从本包中读取```vue.runtime.esm-browser.js```。 # 20 - 0d5a2a4 fix: vue路径 & compile-sfc路径 ### moduleResolver.ts ```vue.runtime.esm-browser.js```的寻找方式:从cwd层级查找。 ```cwd```目录下的```vue```版本需要和本包中的```vue```版本一致,不然报错,且```compiler-sfc```使用本包中的```vue/compiler-sfc```。 如果用户不存在```vue```包,则```compiler-sfc```与```vue.runtime.esm-browser.js```均使用本包的。 这里主要是在客户端```import vue```的时候,顺带设置好```vueCompiler.ts```中需要的```compiler-sfc```。 ### vueCompiler.ts ```typescript import { SFCDescriptor, SFCStyleBlock, SFCTemplateBlock } from '@vue/compiler-sfc' ``` SFC三个类型从本包取,编译功能从```moduleResolver.ts```中取```resolveCompiler```。 ================================================ FILE: 11-20/main.rs ================================================ enum SpreadsheetCell { Int(i32), Float(f64), Text(String), } fn main() { let row = vec![SpreadsheetCell::Int(3), SpreadsheetCell::Float(10.12), SpreadsheetCell::Text(String::from("String text"))]; for i in &row { println!("{:?}", i); match i { SpreadsheetCell::Int(i2) => { println!("{}", i2); }, _ => { println!(".."); } }; if let SpreadsheetCell::Float(value) = i { println!("{}", value); } } } ================================================ FILE: 111-120/commit-111-120.md ================================================ # 111 - 14346ee 修复`__DEV__`条件下`hot.accept`没有被正确渲染的问题 ```typescript // 错误 __DEV__ && hot.accept('./foo.js', ({ foo }) => { // the callback receives the updated './foo.js' module foo() }) // 正确 __DEV__ && hot.accept("/fuck.js", "E:/foo.js", ({ foo }) => { // the callback receives the updated './foo.js' module foo() }) ``` 原因,AST语法树中没有检测不同的类型 ```typescript const checkStatements = (node: Statement) => { if (node.type === 'ExpressionStatement') { // top level hot.accept() call checkAcceptCall(node.expression) // __DEV__ && hot.accept() if ( node.expression.type === 'LogicalExpression' && node.expression.operator === '&&' && node.expression.left.type === 'Identifier' && node.expression.left.name === '__DEV__' ) { checkAcceptCall(node.expression.right) } } // if (__DEV__) ... if ( node.type === 'IfStatement' && node.test.type === 'Identifier' && node.test.name === '__DEV__' ) { if (node.consequent.type === 'BlockStatement') { node.consequent.body.forEach(checkStatements) } if (node.consequent.type === 'ExpressionStatement') { checkAcceptCall(node.consequent.expression) } } } ``` # 112 - 1b0b4ba 配置化构建 ```typescript interface BuildOptions { root?: string cdn?: boolean resolvers?: Resolver[] // 路径转换 srcRoots?: string[] // 资源白名单 rollupInputOptions?: InputOptions // rollup 配置(plugins配置顺序 高于vite所用的plugins) rollupOutputOptions?: OutputOptions // rollup 输出配置(dir) write?: boolean // 是否写输出文件到磁盘中,默认true debug?: boolean // 开启debug后css与JS都不会被压缩,方便我们查看输出的代码,默认false indexPath?: string // 入口文件,默认index.html } ``` 补充几个知识: 1. `transform`的类型是`sequential | async`,如果多个插件实现了相同的钩子函数,那么会串式执行,按照使用插件的顺序从头到尾执行,如果是异步的,会等待之前处理完毕,在执行下一个插件。 2. `resolveId`和`load`的类型是`async, first`,如果多个插件实现了相同的钩子函数,那么会串式执行,从头到尾,但是,如果其中某个的返回值不是`null`也不是`undefined`的话,会直接终止掉后续插件。 > 中文翻译转载了这篇[文章](https://www.cnblogs.com/yangzhuxian/p/13371637.html) ## 我所认为的BUG 发现尤大没有把`input`配置为`indexPath`,难道是故意的(一定是漏了,如果我配置了`indexPath`,那`js`与其它`dom`不同步了)? ```typescript // indexPath被拿去分析的内容了 const bundle = await rollup({ input: path.resolve(root, 'index.html') }) ``` # 113 - 56815ea 整理build的代码 整理代码。 > 现在write仅决定是否写入磁盘的操作,之前还决定是否分析rollup的输出。 > # 114 - fa4c91b readme 现在可以配置化了。需要支持的功能依旧是`source map`。顺带还解析了一下`Vite`为什么叫`Vite`。 ## Trivia [vite](https://en.wiktionary.org/wiki/vite) 是法语快速的首发音 `/vit/`. # 115 - 48f2459 修复深层次的路径BUG ```typescript // recursive: true,创建文件夹,无论是否存在/a或/a/b // filepath = '/a/b/c' await fs.mkdir(path.dirname(filepath), { recursive: true }) ``` # 116 - d9a0798 调整`css`文件名称 - build 去除构建的配置`indexPath`,自动寻找`root`下的`index.html`。 整理代码,当没有`generatedIndex`就不再触发`inject`的相关操作。 ## `cssExtractPlugin`(`rollupPlugin`)新增`generateBundle` 利用`generateBundle`来生成`css`文件,同时可以使`css`文件名称可配置化。 ```typescript const cssExtractPlugin: Plugin = { name: 'vite-css', transform(code: string, id: string) { if (id.endsWith('.css')) { styles.set(id, code) return '/* css extracted by vite */' } }, async generateBundle(_options, bundle) { // finalize extracted css styles.forEach((s) => { css += s }) // minify with cssnano if (!debug) { css = ( await require('postcss')([require('cssnano')]).process(css, { from: undefined }) ).css } bundle[cssFileName] = { isAsset: true, type: 'asset', fileName: cssFileName, source: css } } } ``` `generateBundle`: 类型:`(options: OutputOptions, bundle: { [fileName: string]: AssetInfo | ChunkInfo },isWrite: boolean) => void` 钩子类型:`async`, `parallel` 在`bundle.generate()` 后触发,`bundle.write()`前触发。 ```typescript // AssetInfo { fileName: string, name?: string, source: string | Uint8Array, type: 'asset', } ``` # 117 - 38fd349 去除rollup的`preserveEntrySignatures` 去除`preserveEntrySignatures`,重新使用`export`的代码输出。 [字段解释](https://github.com/Kingbultsea/vite-analysis/blob/d71db28f2e4bdcecdaa4fc6ad311820e6dc81427/commit-61-70/commit-61-70.md#rollup%E9%85%8D%E7%BD%AEpreserveentrysignatures%E4%B8%BAfalse) # 118 - e290349 build打包多出口配置 封装打包操作,遍历`rollupOutputOptions`,调用`generator`。 ```typescript await bundle.generate({ dir: outDir, format: 'es', ...options // OutputOptions[] }) ``` > 注意哦,这里和rollup配置无关。 # 119 - 4bc3035 log静音 添加`slient`配置字段,决定是否输出`write`写入的操作。 同时还删除了一些Log。 # 120 - ddf2d26 添加`window.__DEV__` 开发环境才会有。 ```html
233 ``` ================================================ FILE: 121-130/commit-121-130.md ================================================ # 121 - 1a26b7a 推断正确的构建结果 判断传入build的类型,输出对应的类型。 ```typescript interface SingleBuildOptions extends BuildOptionsBase { rollupOutputOptions?: OutputOptions } interface MultiBuildOptions extends BuildOptionsBase { rollupOutputOptions?: OutputOptions[] } export async function build(options: SingleBuildOptions): Promise export async function build(options: MultiBuildOptions): Promise ``` > 想返回特定情况下的类型,可以多次写一个方法。 # 122 - f5c6699 v0.7.0 release v0.7.0 # 123 - de67bc6 `changelog` # [0.7.0](https://github.com/vuejs/vite/compare/v0.6.1...v0.7.0) (2020-04-29) ### Bug Fixes - 修复写入的情况下,深路径文件的BUG ([48f2459](https://github.com/vuejs/vite/commit/48f2459444fd2affa053ad5857cb8bd325ea2af6)) ### Features - 支持`__DEV__` - 在构建的情况下,支持修改 `cssFileName` ([d9a0798](https://github.com/vuejs/vite/commit/d9a0798b0d8746a816ac516bd4267a409fb82c16)) - 允许通过选项自定义构建 ([1b0b4ba](https://github.com/vuejs/vite/commit/1b0b4ba340b5d552abd7fa0457f9b2de55fc1647)) - 允许插件发送自定义`hmr`事件 ([a22472d](https://github.com/vuejs/vite/commit/a22472d35718d08b4a947d064c82d645cfd49349)) - 支持省略`.js`扩展名 ([d00523f](https://github.com/vuejs/vite/commit/d00523f0efbc4453e31b138ca508d7d5d2479e34)) # 124 - a0053a0 允许配置`rollup-plugin-vue` 新增`rollupPluginVueOptions`选项。 [rollup-plugin-vue](https://rollup-plugin-vue.vuejs.org/options.html) # 125 - 302980c debug -> minify 把`debug`字段改成`minify`。原因是`debug`所做的事情是压缩代码,所以改成`minify`更贴切。 # 126 - 5524e44 拆分`serverPluginModule` `serverPluginModule.ts`拆分为:`serverPluginModuleRewrite.ts`、`serverPluginModuleResolve.ts`。 `serverPluginModuleRewrite.ts`: 改写`import`、`index.html`。 `serverPluginModuleResolve.ts`: 发送模块资源、`vue包`。 `serverPluginServe.ts`更名为`serverPluginServerStatic.ts` # 127 - d4ccd15 readme 新增Build的文档示例 #### Build ```js const { build } = require('vite') ;(async () => { // All options are optional. // check out `src/node/build.ts` for full options interface. const result = await build({ rollupInputOptions: { // https://rollupjs.org/guide/en/#big-list-of-options }, rollupOutputOptions: { // https://rollupjs.org/guide/en/#big-list-of-options }, rollupPluginVueOptions: { // https://github.com/vuejs/rollup-plugin-vue/tree/next#options }, root: process.cwd(), cdn: false, write: true, minify: true, silent: false }) })() ``` # 128 - a084cf2 重构迁移代码 把`serverPluginModuleRewrite.ts`中改写引入了`@hmr` `import`的功能,抽离给`serverPluginHMR.ts`。 ```typescript export const hmrBoundariesMap: HMRStateMap = new Map() export const importerMap: HMRStateMap = new Map() export const importeeMap: HMRStateMap = new Map() // 构建路径 也被迁移到serverPluginHMR.ts ``` 迁移的目的是因为,`hmrBoundariesMap`是给`reloadJS`使用的。 # 129 - a084cf2 chore合并`Import`语句 等同优化代码。 # 130 - b0122b8 readme和`es-dev-server`的区别 ## How is This Different from [es-dev-server](https://open-wc.org/developing/es-dev-server.html)? `es-dev-server` 是一个伟大的项目,在早期重构`vite`时,我们确实从中获得了一些灵感。也就是说,这就是为什么`vite`与`es-dev-server`不同,以及为什么我们不只是将`vite`作为`es-dev-server`的中间件来实现: - `vite` 支持热模块更换, 在不重新加载页面的情况下通过更新模块。 这在开发模式中有着本质性的区别。 `es-dev-server` 内部结构有点不透明,无法通过中间件很好地工作。 - `vite`皆在成为一个拥有开发和构建功能的单一程序。 你可以在不配置任何东西的情况下,使用`vite`来打包代码。 - `vite` 需要原生 ES 模块导入。它不打算增加对旧版浏览器的支持。 ================================================ FILE: 131-140/commit-131-140.md ================================================ # 131 - 30ab444 `hmr.accept`支持调用本身 输入: ```typescript // # foo.js import { hot } from '@hmr' export const count = 1 hot.accept(newModule => { console.log('updated: count is now ', newModule.count) }) ``` 输出: ```typescript // foo.js export const count = 1 hot.accept("/foo.js", "/foo.js", newModule => { console.log('updated: count is now ', newModule.count) }) ``` 新增代码: * `accept`的`callback`默认值`() => {}`,以防止`hot.accept('')` * AST分析树,如果第一个参数类型是`FunctionExpression`,添加上`/foo.js`作为第二个参数。 > 对AST树有兴趣的,可以仔细研究一下。`mozila`有AST类型文档。使用的包`@babel/parser`,类型包`'@babel/types'`,最后使用`magic-string`替换。 # 132 - 4ce94b6 v0.8.0 release v0.8.0 # 133 - d609620 changelog # [0.8.0](https://github.com/vuejs/vite/compare/v0.7.0...v0.8.0) (2020-04-30) ### Features - 构建时,允许配置`rollupPluginVueOptions` ([a0053a0](https://github.com/vuejs/vite/commit/a0053a0eccd2659da685427ac3057cf5b436df80)) - `process.env.NODE_ENV` ([d4ccd15](https://github.com/vuejs/vite/commit/d4ccd154f54f71fb02e746924f9811d3a0e61a8f)) - `hmr.accept`支持调用本身 ([30ab444](https://github.com/vuejs/vite/commit/30ab444bd28b47eec1cf070a3c41116e8e9c64be)) # 134 - b70cd66 [#24](https://github.com/vitejs/vite/pull/24) 语法调整 语法调整 # 135 - 7d5c099 [#26](https://github.com/vitejs/vite/pull/26) 修复错字 修复了在源代码中发现的一些错字 # 136 - 770e558 更新`rollup-plugin-vue` and `vue`包 ![](./pkg.png) # 137 - 7b126af fix `resolver ensurejs` check `ensureJS`当有请求参数的时候尝试补充`.js`拓展名称,不存在则不做任何处理地返回。 ```typescript import { statSync } from 'fs' requestToFile: (publicPath) => { let resolved: string | undefined for (const r of resolvers) { const filepath = r.requestToFile(publicPath, root) if (filepath) { resolved = filepath break } } if (!resolved) { resolved = defaultRequestToFile(publicPath, root) } resolved = ensureJs(resolved) return resolved } // const ensureJs = (id: string) => { // 去除所有参数 const cleanId = id.replace(queryRE, '') // 有参数的情况 if (!/\.\w+$/.test(cleanId)) { // try to see if there is actually a corresponding .js file on disk. // if not, return the id as-is try { statSync(cleanId + '.js') } catch (e) { return id } // 添加js参数 const queryMatch = id.match(queryRE) const query = queryMatch ? queryMatch[0] : '' return cleanId + '.js' + query } return id } ``` ## statSync 同步版本的`fs.stat`,在此作用为查看`.js`文件是否存在,不存在则返回本身`id`。 # 138 - 704fb84 v0.8.1 release v0.8.1 # 139 - 5ec60b1 changelog ## [0.8.1](https://github.com/vuejs/vite/compare/v0.8.0...v0.8.1) (2020-04-30) ### Bug Fixes - 解决`resolver` 里的 `ensurejs` 检测问题 ([3a3442f](https://github.com/vuejs/vite/commit/3a3442f0b95873dd2a6869b00d8ac19b74d650a3)) # 140 - 54366c6 readme 接下来要做的事情 ## TODOs - 支持`import` `.css` 和 `.json` - 公共路径处理(话说这个我不知道是什么... `Public path`我认为是请求路径,需要处理不同的类型,现在仅支持`js`) - 支持`config`配置文件 - 自动引入`postcss config`文件 - `Vue`文件的`source map` ================================================ FILE: 141-150/commit-141-150.md ================================================ # 141 - 6125ee9 拼写错误[#27](https://github.com/vitejs/vite/pull/27) [#27](https://github.com/vitejs/vite/pull/27) # 142 - d27944c 拆分测试[#28](https://github.com/vitejs/vite/pull/28) 拆分测试功能,方便后续使用`test.skip`来进行TDD。 ```typescript describe('my suite', () => { test('my only true test', () => { expect(1 + 1).toEqual(2); }); // Should fail, but isn't even run test.skip('my only true test', () => { expect(1 + 1).toEqual(1); }); }); ``` > TDD是**测试驱动开发**(Test-Driven Development)的英文简称,是敏捷开发中的一项核心实践和技术,也是一种设计方法论。TDD的原理是在开发功能代码之前,先编写单元测试用例代码,测试代码确定需要编写什么产品代码。TDD虽是敏捷方法的核心实践,但不只适用于[XP](https://baike.baidu.com/item/XP/776028)(Extreme Programming),同样可以适用于其他开发方法和过程。 # 143 - f164e46 update rollup-plugin-vue ![](./pkg.png) # 144 - 3ff579c vite命令支持布尔值 支持使用`vite`配置` --flag=false`。 ```typescript // bin/vite.js Object.keys(argv).forEach((key) => { if (argv[key] === 'false') { argv[key] = false } }) ``` # 145 - 2677c93 关闭src转换 编译vue文件中的`