无法在纱线分辨率中使用压缩存档

时间:2019-01-09 17:02:04

标签: yarnpkg stenciljs

对于一个正在进行的stenciljs打字稿项目,我遇到了rollup-plugin-node-builtinsnode-gyp-build之间的交互问题,该交互在依赖项中使用。为了解决这个问题,我能够对汇总插件进行一些更改,并将其设置为模具中的自定义纱线分辨率。

"resolutions": {
    "@stencil/core/**/rollup-plugin-node-builtins": "https://github.com/Matthew-Smith/rollup-plugin-node-builtins.git"
}

当我在本地运行它时效果很好,但是当我们执行yarn install时,我们的构建过程没有git,因此我们尝试将分辨率设置为插件的.tar.gz版本:< / p>

"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

1 个答案:

答案 0 :(得分:0)

所以我能够解决这个问题,尽管我并不十分了解为什么它首先作为git依赖项起作用。

更深入地看,我注意到package.json将主要内容列为:

"main": "dist/rollup-plugin-node-builtins.cjs.js",

,并且有一个脚本来构建软件包:

"build": "rollup -c -f cjs -o dist/rollup-plugin-node-builtins.cjs.js && rollup -c -f es -o dist/rollup-plugin-node-builtins.es6.js && node build-constants.js",

所以我执行了build,通过npm pack .将其打包,然后在我的依赖项解析中使用了该压缩文件!

注意::在了解npm pack .之前,我尝试使用tar -czvf,这给了我与以前相同的错误。