Rollup-plugin-typescript2: Monorepo:rollup -w 与 rpt2 导致(插件 rpt2)错误:找不到源文件

创建于 2020-03-11  ·  2评论  ·  资料来源: ezolenko/rollup-plugin-typescript2

会发生什么以及为什么会出错

正常的一次性构建工作正常。 但是,当使用rollup -w ,如果我在其他包之一中编辑更深层次的模块依赖项之一,rpt2 似乎无法找到源文件。

这是使用 Lerna monorepo 设置到 in-repo 依赖项的符号链接。

测试仓库: https :

我不想使用preserveSymlinks因为在我的真实项目中,它会导致最终构建的项目中的模块重复,因为 repo 中的多个包共享公共依赖项。 我尝试了一个使用preserveSymlinks ,所以作为最后的手段,我可​​以配置一个使用preserveSymlinks的开发设置,但独立/首次构建没有它,我想保留手表设置与正常构建相同。

环境

要在上述示例存储库中重现的详细信息。

版本

  • 打字稿:3.8.3
  • 汇总:1.32.1
  • 汇总插件打字稿2:0.26.0

汇总配置文件

import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';

export default {
  input: 'src/index.ts',
  output: {
    file: 'dist/jr-player.js',
    format: 'iife',
    name: 'jrPlayer',
    exports: 'named'
  },
  watch: {
    include: ['src/**', '../jr-lib/src/**', '../jr-auth/src/**']
  },
  plugins: [
    typescript({
      include: ['src/**/*.ts+(|x)', '../jr-lib/**/*.ts+(|x)', '../jr-auth/**/*.ts+(|x)'],
      verbosity: 3
    }),
    resolve(),
    commonjs()
  ]
};

配置文件

顶级 tsconfig.json:

{
  "compilerOptions": {
    "moduleResolution": "node",
    "module": "es2015",
    "lib": [
      "es2015",
      "es2016",
      "es2017",
      "dom"
    ],
    "strict": true,
    "sourceMap": true,
    "declaration": true,
    "allowSyntheticDefaultImports": true,
    "downlevelIteration": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "noImplicitAny": false,
    "esModuleInterop": true,
    "removeComments": true,
    "resolveJsonModule": true,
    "skipLibCheck": true
  }
}

packages/jr-player/tsconfig.json

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "target": "es5",
    "declarationDir": "lib",
    "outDir": "lib"
  },
  "include": ["."]
}

包.json

我认为它不相关,但它在测试仓库中。

详细程度为 3 的插件输出

已附加,但也在verbose-error.txt测试仓库中:

详细错误.txt

所有2条评论

可能与#188有关

另一种解决方法是使用check: false禁用类型检查,当然这会删除大部分功能......

我有结合rollup-plugin-typescript2rollup-plugin-postcss 。 当我导入 _css_ 文件(例如import * as style from ./mystyle.css )并启用 _watch_ 标志时,它给了我同样的错误。

我会尝试多调试一点,但确实check: false解决了这个问题。

此页面是否有帮助?
0 / 5 - 0 等级