serialize-javascript
serialize-javascript copied to clipboard
Unexpected regular expression
Input:
const options = {
file: 'test5.js',
input: '/******/ function hello(a) {console.log(a)}',
terserOptions: {
output: {
comments: 'all',
},
},
extractComments: {
condition: 'should be extracted',
filename: (file) => file.replace(/(\.\w+)$/, '.license$1'),
banner: (licenseFile) =>
`License information can be found in ${licenseFile}`,
},
}
After serialize we use
const options = new Function(
'exports',
'require',
'module',
'__filename',
'__dirname',
`'use strict'\nreturn ${options}`
)(exports, require, module, __filename, __dirname);
And code in Function
throw SyntaxError: Unexpected regular expression
Hello,
This employee can no longer access email on this account. Your email will not be forwarded.
If you have a sales inquiry, please contact [email protected]
If you require assistance with a legal matter, please contact [email protected]
Thank you!
@krutzler no, i have problems with package and yahoo as always terribly maintenance own repos, instead of a live response, I get a robot :disappointed:
/cc @okuryu friendly ping, we still have problem with example above
test.js:
const serialize = require('serialize-javascript')
const options = {
file: 'test5.js',
input: '/******/ function hello(a) {console.log(a)}',
terserOptions: {
output: {
comments: 'all',
},
},
extractComments: {
condition: 'should be extracted',
filename: (file) => file.replace(/(\.\w+)$/, '.license$1'),
banner: (licenseFile) =>
`License information can be found in ${licenseFile}`,
},
}
console.log(serialize(options))
$ node test.js
{"file":"test5.js","input":"\u002F******\u002F function hello(a) {console.log(a)}","terserOptions":{"output":{"comments":"all"}},"extractComments":{"condition":"should be extracted","filename":(file) => file.replace(/(\.\w+)$/, '.license$1'),"banner":(licenseFile) =>
`License information can be found in ${licenseFile}`}}
Did you mean that /
should serialize to /
not \u002F
?
@okuryu yep, because deserialize not working in this case
Hmm. it seems to be a bug. I'll try to fix it, but it may take some time. Your cooperation is always welcome.