mirror of
https://github.com/swc-project/swc.git
synced 2024-11-24 02:06:08 +03:00
fix(es/parser): Reset ctx for cond while parsing a stmt (#7232)
This commit is contained in:
parent
c06690ec9c
commit
01db30f91e
@ -101,7 +101,12 @@ impl<'a, I: Tokens> Parser<I> {
|
||||
return self.handle_import_export(top_level, decorators);
|
||||
}
|
||||
|
||||
self.parse_stmt_internal(start, include_decl, top_level, decorators)
|
||||
let ctx = Context {
|
||||
will_expect_colon_for_cond: false,
|
||||
..self.ctx()
|
||||
};
|
||||
self.with_ctx(ctx)
|
||||
.parse_stmt_internal(start, include_decl, top_level, decorators)
|
||||
.map(From::from)
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,34 @@
|
||||
|
||||
|
||||
export async function postProcessHTML(
|
||||
) {
|
||||
const postProcessors: Array<PostProcessorFunction> = [
|
||||
process.env.NEXT_RUNTIME !== 'edge' && inAmpMode
|
||||
? async (html: string) => {
|
||||
const optimizeAmp = require('./optimize-amp')
|
||||
.default as typeof import('./optimize-amp').default
|
||||
html = await optimizeAmp!(html, renderOpts.ampOptimizerConfig)
|
||||
if (!renderOpts.ampSkipValidation && renderOpts.ampValidator) {
|
||||
await renderOpts.ampValidator(html, pathname)
|
||||
}
|
||||
return html
|
||||
}
|
||||
: null,
|
||||
process.env.NEXT_RUNTIME !== 'edge' && renderOpts.optimizeFonts
|
||||
? async (html: string) => {
|
||||
const getFontDefinition = (url: string): string => {
|
||||
}
|
||||
}
|
||||
: null,
|
||||
process.env.NEXT_RUNTIME !== 'edge' && renderOpts.optimizeCss
|
||||
? async (html: string) => {
|
||||
}
|
||||
: null,
|
||||
inAmpMode || hybridAmp
|
||||
? (html: string) => {
|
||||
return html.replace(/&amp=1/g, '&=1')
|
||||
}
|
||||
: null,
|
||||
].filter(nonNullable)
|
||||
|
||||
}
|
1390
crates/swc_ecma_parser/tests/typescript/vercel/web-875/input.ts.json
Normal file
1390
crates/swc_ecma_parser/tests/typescript/vercel/web-875/input.ts.json
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user