-
-
Notifications
You must be signed in to change notification settings - Fork 179
refactor: use serialize-javascript
instead own implementation
#183
Conversation
serialize-javascript
package instead own implementationserialize-javascript
instead own implementation
Nothing against this change in particular and if serialization is unavoidable, but I would like to traige eventual possibilities to avoid serialization for
|
@michael-ciniawsky |
src/uglify/worker.js
Outdated
|
||
module.exports = (options, callback) => { | ||
try { | ||
callback(null, minify(JSON.parse(options, decode))); | ||
// eslint-disable-next-line no-eval | ||
callback(null, minify(eval(`(${options})`))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// 'use strict' => this === undefined (Clean Scope)
// Safer for possible security issues, albeit not critical at all here
options = new Function(`'use strict'\nreturn ${options}`)()
callback(null, minify(options));
test/cache-options.test.js
Outdated
@@ -378,11 +379,12 @@ describe('when options.cache', () => { | |||
|
|||
// Make sure that we cached files | |||
expect(cacheEntriesListKeys.length).toBe(files.length); | |||
cacheEntriesListKeys.forEach((cacheJSONEntry) => { | |||
const cacheEntry = JSON.parse(cacheJSONEntry); | |||
cacheEntriesListKeys.forEach((serializedCacheEntry) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cacheEntriesListKeys
=> cacheKeys
&& serializedCacheEntry
=> cacheEntry
test/__snapshots__/ecma.test.js.snap
Outdated
@@ -106,7 +106,7 @@ exports[`ecma 6: errors 1`] = `Array []`; | |||
|
|||
exports[`ecma 6: main.js 1`] = ` | |||
"webpackJsonp([ 0 ], [ function(module, exports) { | |||
class Mortgage { | |||
module.exports = class { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did this change ? It's the same as in #190 I just can't reason about it 😛
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-ciniawsky oh yep 👍
75a3454
to
ea2c021
Compare
@michael-ciniawsky done |
src/uglify/worker.js
Outdated
module.exports = (options, callback) => { | ||
/* eslint-disable no-new-func */ | ||
|
||
module.exports = (workerOptions, callback) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
workerOptions
=> options
(Just reassign options
below please)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michael-ciniawsky eslint throw problem about no-param-reassign
, but it is not make sense here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
eslint-disable-next-line
? 🙃
ea2c021
to
eeee677
Compare
@michael-ciniawsky done 👍 |
Notable Changes
serialize-javascript
more stable and support many features (see https://github.com/yahoo/serialize-javascript/blob/master/index.js#L14 https://github.com/yahoo/serialize-javascript/blob/master/index.js#L90 and etc)Issues