对于我正在处理的 typescript stenciljs 项目,我在依赖项之间的交互rollup-plugin-node-builtins
以及node-gyp-build
在依赖项中使用的交互方面遇到了问题。为了解决它,我能够对汇总插件进行一些更改并将其设置为模板中的自定义纱线分辨率
"resolutions": {
"@stencil/core/**/rollup-plugin-node-builtins": "https://github.com/Matthew-Smith/rollup-plugin-node-builtins.git"
}
当我在本地运行它时效果很好,但是我们的构建过程在执行时没有可用的 gityarn install
所以我们尝试将分辨率设置为.tar.gz
插件的版本:
"resolutions": {
"@stencil/core/**/rollup-plugin-node-builtins": "https://github.com/Matthew-Smith/rollup-plugin-node-builtins/archive/v2.1.3.tar.gz"
}
这似乎正确地将代码克隆到 node_modules 中:
> l node_modules | grep rollup
drwxr-xr-x 8 matthewsmith staff 256B Jan 9 11:26 rollup
drwxr-xr-x 9 matthewsmith staff 288B Jan 9 11:26 rollup-plugin-commonjs
drwxr-xr-x 13 matthewsmith staff 416B Jan 9 11:26 rollup-plugin-node-builtins
drwxr-xr-x 8 matthewsmith staff 256B Jan 9 11:26 rollup-plugin-node-resolve
drwxr-xr-x 7 matthewsmith staff 224B Jan 9 11:26 rollup-pluginutils
> l node_modules/rollup-plugin-node-builtins
total 64
drwxr-xr-x 13 matthewsmith staff 416B Jan 9 11:26 .
drwxr-xr-x 670 matthewsmith staff 21K Jan 9 11:26 ..
-rw-r--r-- 1 matthewsmith staff 36B Jan 9 11:13 .babelrc
-rw-r--r-- 1 matthewsmith staff 650B Jan 9 11:13 .eslintrc
-rw-r--r-- 1 matthewsmith staff 5B Jan 9 11:13 .gitignore
-rw-r--r-- 1 matthewsmith staff 14B Jan 9 11:13 .npmignore
drwxr-xr-x 5 matthewsmith staff 160B Jan 9 11:26 browser-test
-rw-r--r-- 1 matthewsmith staff 500B Jan 9 11:13 build-constants.js
-rw-r--r-- 1 matthewsmith staff 1.3K Jan 9 11:13 package.json
-rw-r--r-- 1 matthewsmith staff 2.5K Jan 9 11:13 readme.md
-rw-r--r-- 1 matthewsmith staff 216B Jan 9 11:13 rollup.config.js
drwxr-xr-x 4 matthewsmith staff 128B Jan 9 11:26 src
drwxr-xr-x 4 matthewsmith staff 128B Jan 9 11:26 test
但是当我尝试构建代码时,我得到了这个输出:
$ sd concurrent "stencil build --dev --watch" "stencil-dev-server"
[26:41.1] @stencil/core v0.12.4
[26:41.2] build, app, dev mode, started ...
[26:41.7] transpile started ...
[26:43.8] transpile finished in 2.07 s
[26:43.8] module map started ...
[26:43.8] generate styles started ...
[26:43.8] module map finished in 12 ms
[26:43.9] generate styles finished in 76 ms
[ ERROR ] Cannot find module 'rollup-plugin-node-builtins' at Function.Module._resolveFilename
(internal/modules/cjs/loader.js:580:15) at Function.Module._load
(internal/modules/cjs/loader.js:506:25) at Module.require (internal/modules/cjs/loader.js:636:17) at
require (internal/modules/cjs/helpers.js:20:18) at
/Users/matthewsmith/penfield/node_modules/@stencil/core/dist/compiler/index.js:18322:26
at Generator.next (<anonymous>) at
/Users/matthewsmith/penfield/node_modules/@stencil/core/dist/compiler/index.js:18306:71
at new Promise (<anonymous>) at __awaiter$13
(/Users/matthewsmith/penfield/node_modules/@stencil/core/dist/compiler/index.js:18302:12)
at createBundle
(/Users/matthewsmith/penfield/node_modules/@stencil/core/dist/compiler/index.js:18310:12)
是否有使用压缩档案进行纱线分辨率的特殊过程?
编辑
这是我的 yarn.lock 对于这个依赖项的样子:
rollup-plugin-node-builtins@2.1.2, "rollup-plugin-node-builtins@https://github.com/Matthew-Smith/rollup-plugin-node-builtins/archive/v2.1.3.tar.gz":
version "2.1.3"
resolved "https://github.com/Matthew-Smith/rollup-plugin-node-builtins/archive/v2.1.3.tar.gz#af40f65e716e2c62e698cbea169127f9c1717e7d"
dependencies:
browserify-fs "^1.0.0"
buffer-es6 "^4.9.2"
crypto-browserify "^3.11.0"
process-es6 "^0.11.2"
纱线版本:
1.12.3
节点版本:
10.12.0
模板版本:
0.12.4