yahoo / yahoo/serialize-javascript
Unexpected regular expression
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.9k
- Forks
- 215
- Avg merge
- 1d 12h
- Merged PRs (30d)
- 2
Description
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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided serialize-then-Function example and inspect how the options object, regular expression, and function are serialized. Confirm the fix by ensuring this input no longer throws SyntaxError: Unexpected regular expression, then add or update a regression test if the repository has coverage for this entry point.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100