Skip to content

Commit

Permalink
feat: rename to resolvedConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
vagusX committed Jul 26, 2020
1 parent b99b82e commit 9550dfc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
### 异步注册
* kaitian 中注册 languages/grammars 都是异步注册的

### resolvedContent 字段
* 为了跟原本插件的 contribute 的 `path/configuration` 字段区分开,统一使用 resolvedContent 挂载原本的 json file 中的内容,如
### resovledConfiguration 字段
* 为了跟原本插件的 contribute 的 `path/configuration` 字段区分开,统一使用 resovledConfiguration 挂载原本的 json file 中的内容,如

* `"configuration": "./language-configuration.json"` --> `"resolvedContent": require('./language-configuration.json')`
* `"path": "./syntaxes/JavaScript.tmLanguage.json"` --> `"resolvedContent": require('./syntaxes/JavaScript.tmLanguage.json')
* `"configuration": "./language-configuration.json"` --> `"resovledConfiguration": require('./language-configuration.json')`
* `"path": "./syntaxes/JavaScript.tmLanguage.json"` --> `"resovledConfiguration": require('./syntaxes/JavaScript.tmLanguage.json')

### tmLanguage 文件
由于 require 语法导致在 webpack 中需要额外添加 raw-loader 去处理 tmLanguage 文件,且会导致 resolvedContent 的内容格式不统一,因此目前都通过 fork vscode 插件 [TextMate Languages] 将 tmLanguage 转成 json
由于 require 语法导致在 webpack 中需要额外添加 raw-loader 去处理 tmLanguage 文件,且会导致 resovledConfiguration 的内容格式不统一,因此目前都通过 fork vscode 插件 [TextMate Languages] 将 tmLanguage 转成 json

目前已经被 fork 过的语言插件列表如下:
* javascript
6 changes: 4 additions & 2 deletions scripts/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const targetEsDir = path.resolve(__dirname, '../es')

templateSettings.escape = false

const ResolvedConfigFiled = 'resolvedConfiguration';

class Extension {
constructor(extPath) {
this.extPath = extPath
Expand Down Expand Up @@ -56,7 +58,7 @@ class Extension {
*/
const languageStr = JSON.stringify(data.languages).replace(
/"configuration":\s*(".+?.json?")/g,
`resolvedContent:${requireKeyword}($1)`
`${ResolvedConfigFiled}:${requireKeyword}($1)`
)
/**
* 处理以下字符串,因为有 tmLanguage 后缀,因此将 `.json` 设置为可选匹配项
Expand All @@ -68,7 +70,7 @@ class Extension {
*/
const grammarStr = JSON.stringify(data.grammars).replace(
/"path":\s*(".+?[.json]?")/g,
`resolvedContent:${requireKeyword}($1)`
`${ResolvedConfigFiled}:${requireKeyword}($1)`
)

const content = compiled({
Expand Down

0 comments on commit 9550dfc

Please sign in to comment.