我包含一个模块(来自私人 git repo)
包.json:
"my-module": "git+https://username:[email protected]/username/repo.git"
回购有一个打字稿文件:
export class MyClass {}
该模块旨在用于节点和浏览器环境。
当我在我的节点环境中运行它时,我收到一个错误:
SyntaxError: Unexpected token export
(function (exports, require, module, __filename, __dirname) { export class MyClass {}
我包含的模块没有 dist 文件夹(即它不是预编译的)。
这里出了什么问题?我需要预编译它并引用 dist 文件夹还是有办法直接访问 src?
导入的模块和导入项目都有一个 tsconfig.json target: "es6", module: "commonjs"
typescript 项目建议您不要编译依赖项,而是在发布包之前构建它们。
这对您来说很难,因为您使用的是 git 依赖项。在这种情况下,我建议:
tsconfig.json
为也编译该依赖项目录中的文件。本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句