summaryrefslogtreecommitdiff
path: root/src/compiler/codegen
diff options
context:
space:
mode:
Diffstat (limited to 'src/compiler/codegen')
-rw-r--r--src/compiler/codegen/index.ts19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/compiler/codegen/index.ts b/src/compiler/codegen/index.ts
index a10268883..bca24d81d 100644
--- a/src/compiler/codegen/index.ts
+++ b/src/compiler/codegen/index.ts
@@ -9,11 +9,12 @@ import path from 'path';
import { walk } from 'estree-walker';
import _babelGenerator from '@babel/generator';
import babelParser from '@babel/parser';
+import { codeFrameColumns } from "@babel/code-frame";
import * as babelTraverse from '@babel/traverse';
import { ImportDeclaration, ExportNamedDeclaration, VariableDeclarator, Identifier } from '@babel/types';
import { warn } from '../../logger.js';
import { fetchContent } from './content.js';
-import { isFetchContent, isImportMetaDeclaration } from './utils.js';
+import { isFetchContent } from './utils.js';
import { yellow } from 'kleur/colors';
const traverse: typeof babelTraverse.default = (babelTraverse.default as any).default;
@@ -315,10 +316,22 @@ function compileModule(module: Script, state: CodegenState, compileOptions: Comp
const componentPlugins = new Set<ValidExtensionPlugins>();
if (module) {
- const program = babelParser.parse(module.content, {
+ const parseOptions: babelParser.ParserOptions = {
sourceType: 'module',
plugins: ['jsx', 'typescript', 'topLevelAwait'],
- }).program;
+ };
+ let parseResult;
+ try {
+ parseResult = babelParser.parse(module.content, parseOptions)
+ } catch(err) {
+ const location = { start: err.loc };
+ const frame = codeFrameColumns(module.content, location);
+ err.frame = frame;
+ err.filename = state.filename;
+ err.start = err.loc;
+ throw err;
+ }
+ const program = parseResult.program;
const { body } = program;
let i = body.length;
/astro/src/cli/open.ts?h=@astrojs/vercel@0.0.3-beta.0&id=d0777ad3aff0084d7fc0e159ac32ebea062d921c&follow=1'>Astro add docs (#2958)Gravatar Peter Singh 3-3/+49 * So This works 😎 * need to add to the cli next * Renamed Files and Export Applied creditation to where I found the 'inspiration' for this application. * applied `astro docs` to cli * Trying to add to CLI, Not working πŸ€·β€β™‚οΈ * Converted into async method, * πŸŽ†πŸŽ† It works!!! πŸ₯³πŸŽ‰πŸ₯³ Embarrasing as it is I totally missed the part where logic was to be in. * Moved `docs` cmd to `supportedCommands` * refactor: cleanup docs command * chore: add changeset * chore: rename browser to open Co-authored-by: Nate Moore <nate@skypack.dev> 2022-04-06fix: @astrojs/vercel bug fixes (#3000)Gravatar Juan MartΓ­n Seery 2-6/+29 * Fixed outDir * Updated server out * changeset * Renamed out to tmp 2022-04-06[ci] formatGravatar matthewp 1-32/+32 2022-04-06[ci] release (beta) (#3005)astro@1.0.0-beta.3Gravatar github-actions[bot] 31-88/+98 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2022-04-06Fixes dynamic API routes in SSR (#3006)Gravatar Matthew Phillips 4-1/+26 * Fixes dynamic API routes in SSR * Adds a changeset 2022-04-06[ci] formatGravatar tony-sull 1-1/+1 2022-04-06fix(#2981): keeps `astro preview` server alive (#3004)Gravatar Tony Sullivan 3-1/+17 * fix(#2981): keeps server alive * chore: adding changeset * keep alive until the 'close' or 'error' event fires 2022-04-06Update readme.mdGravatar Nate Moore 1-2/+3 2022-04-06[ci] collect statsGravatar FredKSchott 1-0/+1 2022-04-05[ci] formatGravatar matthewp 1-1/+1 2022-04-05[ci] release (beta) (#2997)@astrojs/netlify@0.1.1-beta.0Gravatar github-actions[bot] 3-2/+9 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> 2022-04-05Docs: netlify adapter site requirement (#2996)Gravatar Ben Holmes 3-4/+23 * feat: human-readable error on bad site or base * fix: human-readable error should have 1 config option * docs: update README * chore: changeset * docs: mention localhost for testing via netlify CLI 2022-04-05[ci] collect statsGravatar FredKSchott 1-0/+1 2022-04-05[ci] formatGravatar FredKSchott 1-32/+32 2022-04-04[ci] release (beta) (#2992)astro@1.0.0-beta.2Gravatar github-actions[bot] 31-87/+94 Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>