- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的应用程序依赖于公司内部的 TS 库,该库很少被编辑。我刚刚更新了它,现在用于构建它的 gulp 任务之一将失败。所有其他任务将独立工作或按顺序/并行使用,但使用 @rollup/stream
包的任务会导致 gulp 在声明自己完成后挂起。发现这一点是因为构建自动化最终终止了构建,因为它暂停了 2 小时以等待 gulp 任务完成。
我不得不更新我们的内部库,因为它由于以下问题导致构建失败。
'rollup' errored after 1.51 s
Error: '__spreadArray' is not exported by node_modules\tslib\tslib.es6.js, imported by src\ObjectUtils.ts
所以我将 tsconfig.json
文件从 "target": "es5",
更新为 "target": "es6",
这会导致汇总挂起。
运行 gulp rollup
得到以下输出
Using gulpfile path/to/gulp/file
Starting 'rollup'...
//
// Outputs all the files being rolled up here...
//
Finished 'rollup' after 1.43 s
// The gulp process then stays open instead of closing and returning me to my prompt
举个例子,我在本地运行任务,然后自己用 control+c 退出,它报告在那里等待 10 分 15 秒
阅读了我能找到的所有文档和 SO 问题后,我确信我们正在做 async gulp tasks文档建议处理流但它不会工作。然后我尝试使用 .on('end', () => {//etc })
自己手动关闭返回的汇总流,将内容包装在 promises 中并返回一个在流已完成,使用提供给每个任务函数的回调,上述组合,但我无法让汇总任务正确完成并将控制权返回给提示。
我已经包含了我的 gulpfile 的相关部分,tsconfig.json 和我的 package.json 依赖项。
// gulpfile.js
const gulp = require('gulp');
const gulpif = require('gulp-if');
const terser = require("gulp-terser");
const typescript = require("@rollup/plugin-typescript");
const rollup = require("@rollup/stream");
const buffer = require('vinyl-buffer');
const source = require('vinyl-source-stream');
const production = process.env.NODE_ENV == 'production';
function rollupTask () {
// rollup() returns a stream, so returning this should satisfy the async tasks requirements.
// When the stream closes it should tell gulp the tasks has finished right?
return rollup({
input: "./src/main.ts",
external: [
"lodash",
],
output: {
format: "cjs",
sourcemap: true
},
plugins: [
typescript(),
],
})
.pipe(source("common.bundle.js"))
.pipe(buffer())
.pipe(gulpif(production, terser()))
.pipe(gulp.dest('./dist'));
};
exports.rollup = rollupTask;
// tsconfig.json
{
"compilerOptions": {
"declaration": false,
"module": "es2015",
"target": "es6",
"emitDecoratorMetadata": true,
"listFiles": true,
"noImplicitAny": false,
"noUnusedLocals": true,
"noLib": false,
"removeComments": true,
"sourceMap": true,
"experimentalDecorators": true,
"lib": [
"ES5",
"Dom",
"ScriptHost",
"ES2015",
"ES2016",
"ES2017"
]
}
}
// package.json dependencies
"dependencies": {
"lodash": "^4.17.5"
},
"devDependencies": {
"@rollup/plugin-typescript": "^6.1.0",
"@rollup/stream": "^1.1.0",
"@types/lodash": "^4.14.165",
"del": "^6.0.0",
"gulp": "^4.0.2",
"gulp-if": "^3.0.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-terser": "^2.0.0",
"gulp-tslint": "^8.0.0",
"gulp-typescript": "^5.0.1",
"merge2": "^1.4.1",
"rollup": "^2.33.3",
"tslint": "^6.1.3",
"typescript": "^4.0.5",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0"
},
如果事实证明我可以在 tsconfig.json
中继续使用 "target": "es5",
并修复 __spreadArray
找到问题,我也可以这样做。
最佳答案
我被困在两个不同的错误之间:
tsconfig.json
中设置 "target": "ES6"
会因永不退出 gulp 任务而中断。tsconfig.json
中设置为 "target": "ES5"
会提示 tslib< 中缺少 __spreadArray
函数
。这是我最终解决这个问题的方法:
npm i --save-dev tslib
手动 tslib
以确保有可用的最新版本。因为我在步骤 1 中更新了 TS 版本。它应该包括最新的 tslib
这可能是不必要的......但无论如何手动包含它感觉很好。@rollup/plugin-typescript
分支让它工作。这本身就是一个奇怪的问题,因为据说 fork 只存在于在控制台中添加错误日志记录以告诉您任何 TS 错误。但是现在原始项目也输出错误,但不再为我们(或者可能只是我)使用 gulp。 fork 在 npm 上得到维护和流行,所以我不太担心,但我仍然更愿意使用“官方”包。显然,我更改了我的 gulpfile.js
以使用这个新包,但就 API 而言,它的替代品有所下降。tslib
Node 模块,我手动检查以确保它具有我们需要的 __spreadArray
函数。我在 this answer 中找到了此修复程序而我正在寻找线索的相关问题以上所有的一些组合修复了它。可能 3 和 4 是主要修复。
以下是我的 tsconfig.json
和我的 package.json
的相关部分的更新版本,以防它对任何 future 的读者有用。
// tsconfig.json
{
"compilerOptions": {
"declaration": false,
"module": "ES2015",
"target": "ES6",
"emitDecoratorMetadata": true,
"listFiles": true,
"noImplicitAny": false,
"noUnusedLocals": true,
"noLib": false,
"removeComments": true,
"sourceMap": true,
"experimentalDecorators": true,
"importHelpers": true,
"paths": {
"tslib": [
"./node_modules/tslib/tslib.d.ts"
]
},
"lib": [
"ES5",
"Dom",
"ScriptHost",
"ES2015",
"ES2016",
"ES2017"
]
}
}
// package.json
"dependencies": {
"lodash": "^4.17.21"
},
"devDependencies": {
"@rollup/plugin-typescript": "^8.2.5",
"@rollup/stream": "^2.0.0",
"@types/lodash": "^4.14.165",
"del": "^6.0.0",
"gulp": "^4.0.2",
"gulp-if": "^3.0.0",
"gulp-sourcemaps": "^3.0.0",
"gulp-terser": "^2.0.1",
"gulp-tslint": "^8.1.4",
"gulp-typescript": "^5.0.1",
"merge2": "^1.4.1",
"rollup": "^2.56.3",
"rollup-plugin-typescript2": "^0.30.0",
"tslib": "^2.3.1",
"tslint": "^6.1.3",
"typescript": "^4.4.2",
"vinyl-buffer": "^1.0.1",
"vinyl-source-stream": "^2.0.0"
},
"files": [
"dist/"
]
关于javascript - 在 tsconfig.json 中使用 @rollup/stream 和 es6 目标时,Gulp 4 任务不会完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69016358/
我正在尝试实现具有以下签名的方法: public static Pair, Stream> flatten(Iterator, Stream>> iterator); 该方法的目标是将每种流类型展平
我有两个流从两个不同的 api 获取。 Stream get monthOutStream => monthOutController.stream; Stream get resultOutStre
Stream.of(int[])返回 Stream ,而 Stream.of(String[])返回 Stream . 为什么这两种方法的行为不同?两者都应该返回 Stream和 Stream或 St
我正在使用 rxdart在 dart 中处理流的包。我被困在处理一个特殊的问题上。 请看一下这个虚拟代码: final userId = BehaviorSubject(); Stream getSt
我到处都找遍了,还是没弄明白。我知道你可以用流建立两个关联: 用于支持数据存储的包装器意味着作为消费者和供应商之间的抽象层 数据随着时间的推移变得可用,而不是一次全部 SIMD 代表单指令,多数据;在
考虑下面的代码: List l=new ArrayList<>(); l.add(23);l.add(45);l.add(90); Stream str=l.stream
我有一个大型主干/requirejs 应用程序,我想迁移到 webpack,最新的“webpack”:“^4.27.1”,但我遇到了一个我无法解决的错误。 我一直在阅读 https://webpack
我正在使用 xmpp 开发聊天应用程序,根据我们的要求,我们有三台服务器 Apache Tomcat 7、ejabbered 2.1.11 和 mysql 5.5, to run xmppbot on
我知道如何使用 Java 库,并且我可以编写一些循环来执行我需要的操作,但问题更多,为什么 scala.collection.JavaConverters 中没有任何内容或scala.collecti
我正在尝试创建一个单一的衬里,它应该计算一个非常长的文本文件中的唯一单词。独特的词例如:márya fëdorovna scarlet-liveried,...所以基本上都是非英语词。 我的问题是我的
如果我有以下情况: StreamWriter MySW = null; try { Stream MyStream = new FileStream("asdf.txt"); MySW =
有人可以帮我将以下语句转换为 Java8: 我有一个像这样的 HashMap : private Map, List>> someMap; 我想在java8中转换以下逻辑: private Strin
有人可以帮我将以下语句转换为 Java8: 我有一个像这样的 HashMap : private Map, List>> someMap; 我想在java8中转换以下逻辑: private Strin
考虑两种测试方法parallel()和sequential(): @Test public void parallel() throws Exception { System.ou
我是 NodeJS 的新手,我基本上想做的是通过 HTTP 将 .pdf 上传到我的服务器。我正在使用 POST rquest 来处理 Content-Type multipart/form-data
哪个更好:MemoryStream.WriteTo(Stream destinationStream) 或 Stream.CopyTo(Stream destinationStream)?? 我正在谈
给定一个 Stream,我想创建一个新的 Stream,其中的元素在它们之间有时间延迟。 我尝试使用 tokio_core::reactor::Timeout 和 Stream 的 and_then
我是 Kafka Streams 和 Spring Cloud Stream 的新手,但在将集成相关代码移动到属性文件方面已经阅读了有关它的好东西,因此开发人员可以主要专注于事物的业务逻辑方面。 这里
源代码看起来非常相似:pump , pipe .为什么我要使用一个而不是另一个?一个只是另一个的更好版本吗? 最佳答案 Stream.pipe 现在显然是自 0.3.x 以来的首选方法,因此尽可能尝试
我正在寻找是否有更好的方法来解决我不得不使用这些签名的困境(注意:由于 Spock 测试,T[][] 是必需的,我提供 T[][] 作为数据提供商) 我的方法签名是: public T[][] cr
我是一名优秀的程序员,十分优秀!