mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-09-11 12:15:24 +03:00
Merge pull request #84 from RealKinetic/fix-phantom-comments
Fix phantom comments causing runtime exceptions
This commit is contained in:
commit
9e6001b717
@ -1,5 +1,11 @@
|
||||
# Upcoming
|
||||
|
||||
- Fix "phantom comments" issue. The sourceFile's comments were intermingling
|
||||
with optimized-record output causing runtime exceptions in some cases. It's
|
||||
suspected to be an issue
|
||||
|
||||
- Bump typescript compiler to 4.5.5
|
||||
|
||||
- Expose `transform: (jsSource: string) => string` JS API. Useful for build toolchains.
|
||||
|
||||
- Update chromedriver to work with latest version of Chrome
|
||||
|
@ -68,6 +68,6 @@
|
||||
"commander": "^6.0.0",
|
||||
"node-elm-compiler": "^5.0.4",
|
||||
"ts-union": "^2.2.1",
|
||||
"typescript": "^3.9.7"
|
||||
"typescript": "^4.5.5"
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,18 @@ export const transform = async (
|
||||
verbose: boolean,
|
||||
transforms: Transforms
|
||||
): Promise<string> => {
|
||||
let source = ts.createSourceFile('elm.js', jsSource, ts.ScriptTarget.ES2018);
|
||||
/* First, remove comments from source.
|
||||
|
||||
We've encountered a bug when running some of the transforms (specifically the
|
||||
record-update transform when the -O3 flag is enabled) where comments from the
|
||||
source file appear interspersed throughout the transformed file. In some cases
|
||||
this will result in runtime exceptions.
|
||||
*/
|
||||
const sourceWithComments = ts.createSourceFile('n/a', jsSource, ts.ScriptTarget.ES2018);
|
||||
const noCommentsPrinter = ts.createPrinter({ removeComments: true });
|
||||
const jsSourceWithoutComments = noCommentsPrinter.printFile(sourceWithComments);
|
||||
|
||||
let source = ts.createSourceFile('elm.js', jsSourceWithoutComments, ts.ScriptTarget.ES2018);
|
||||
|
||||
let parsedVariants = primitives;
|
||||
if (elmfile && transforms.variantShapes) {
|
||||
|
Loading…
Reference in New Issue
Block a user