Webpack umd, похоже, нарушает функциональность stacktrace-js
Мы пытаемся использовать stacktrace-js с удивительным logary-js (мой проект), но после прохождения веб-пакета может показаться, что он больше не работает.
Вот конфигурация для веб-пакета https://github.com/logary/logary-js/blob/c7fdec752e5ce33843d458e9e6c590657005c60a/webpack.config.js
Вот вывод, который меня беспокоит (npm run build
):
> logary@2.0.2 build /Users/h/dev/haf/logary-js
> NODE_ENV=production webpack --progress --color --display-error-details --display-reasons --optimize-minimize
Hash: d1c4b6913d586c4424ce
Version: webpack 1.13.0
Time: 2263ms
Asset Size Chunks Chunk Names
logary.js 55.2 kB 0 [emitted] logary
logary.js.map 407 kB 0 [emitted] logary
+ 19 hidden modules
WARNING in logary.js from UglifyJs
Side effects in initialization of unused variable promise [./src/index.js:357,8]
Side effects in initialization of unused variable Targets [./src/index.js:382,13]
Dropping side-effect-free statement [./~/jssha/src/sha.js:12,0]
Condition always true [./~/jssha/src/sha.js:37,116]
Condition always true [./~/stacktrace-js/stacktrace.js:6,0]
Dropping unreachable code [./~/stacktrace-js/stacktrace.js:8,5]
Condition always true [./~/error-stack-parser/error-stack-parser.js:6,0]
Dropping unreachable code [./~/error-stack-parser/error-stack-parser.js:8,5]
Condition always true [./~/stackframe/stackframe.js:6,0]
Dropping unreachable code [./~/stackframe/stackframe.js:8,5]
Condition always true [./~/stack-generator/stack-generator.js:6,0]
Dropping unreachable code [./~/stack-generator/stack-generator.js:8,5]
Condition always true [./~/stacktrace-gps/stacktrace-gps.js:6,0]
Dropping unreachable code [./~/stacktrace-gps/stacktrace-gps.js:8,5]
В этой ветке я пытаюсь отключить UglifyJs безрезультатно.
npm run test
дает этот вывод (разрезанный):
stacktrace enricher
✓ should be a function
✓ should accept a message and return a function
✓ passes through messages without errors
✓ parses errors in generated errors (385ms)
✓ should parse errors into stack traces
Так что, кажется, интеграция webpack-mocha в dev работает очень хорошо. Однако, когда я использую logary из другого JS после освобождения, я получаю этот вывод из stacktrace-js:
Когда он должен выполнить эти модульные тесты (что происходит, когда я запускаю mocha, но не когда я запускаю его в браузере):
const stacktrace = Middleware.stacktrace
// snip
it('passes through messages without errors', function() {
const msg = Message.event('Signup');
const res = stacktrace(logger)(msg);
expect(res.value.event).to.equal('Signup');
expect(res.level).to.equal('info');
expect(res.fields).to.deep.equal({});
expect(res.context).to.deep.equal({
logger: 'AreaX.ComponentA',
service: 'MyWebSite'
});
});
it('parses errors in generated errors', function(done) {
const msg = Message.eventError('Uncomfortable Error', error);
const subjectMsg = stacktrace(logger)(msg);
expect(expect(subjectMsg).to.eventually.be.fulfilled.then(msg => {
expect(msg.fields).to.be.an('object');
expect(msg.fields.errors).to.have.lengthOf(1);
expect(msg.fields.errors[0]).to.not.equal(error);
expect(msg.fields.errors[0]).to.be.an('Array');
})).to.notify(done);
});
it('should parse errors into stack traces', function(done) {
const msg = Message.eventError('Uncomfortable Error', error, {
myField: 'abc'
}),
actual = stacktrace(logger)(msg).then(x => x.fields);
expect(expect(Promise.all([
actual,
StackTrace.fromError(error)
])).to.eventually.be.fulfilled.then(([actualFields, expectedError]) => {
expect(actualFields.errors[0]).to.deep.equal(expectedError);
expect(actualFields.myField).to.equal('abc');
})).to.notify(done);