css, script and options readers at the folder root; read/ is gone

goodbye-acorn
Nic 21 hours ago
parent 803476f793
commit 652da2c81b

@ -4,7 +4,7 @@
import { walk as zimmerframe_walk } from 'zimmerframe'; import { walk as zimmerframe_walk } from 'zimmerframe';
import { convert } from './legacy.js'; import { convert } from './legacy.js';
import { parse as _parse, Parser } from './phases/1-parse/index.js'; import { parse as _parse, Parser } from './phases/1-parse/index.js';
import { parse_stylesheet } from './phases/1-parse/read/style.js'; import { parse_stylesheet } from './phases/1-parse/css.js';
import { analyze_component, analyze_module } from './phases/2-analyze/index.js'; import { analyze_component, analyze_module } from './phases/2-analyze/index.js';
import { transform_component, transform_module } from './phases/3-transform/index.js'; import { transform_component, transform_module } from './phases/3-transform/index.js';
import { validate_component_options, validate_module_options } from './validate-options.js'; import { validate_component_options, validate_module_options } from './validate-options.js';

@ -1,6 +1,6 @@
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { Parser } from '../index.js' */ /** @import { Parser } from './index.js' */
import * as e from '../../../errors.js'; import * as e from '../../errors.js';
const REGEX_MATCHER = /[~^$*|]?=/y; const REGEX_MATCHER = /[~^$*|]?=/y;
const REGEX_CLOSING_BRACKET = /[\s\]]/; const REGEX_CLOSING_BRACKET = /[\s\]]/;

@ -6,7 +6,7 @@ import fragment from './state/fragment.js';
import { value_names } from '../../utils/ast.js'; import { value_names } from '../../utils/ast.js';
import * as e from '../../errors.js'; import * as e from '../../errors.js';
import { create_fragment } from './utils/create.js'; import { create_fragment } from './utils/create.js';
import read_options from './read/options.js'; import read_options from './options.js';
import { is_reserved } from '../../../utils.js'; import { is_reserved } from '../../../utils.js';
import { disallow_children } from '../2-analyze/visitors/shared/special-element.js'; import { disallow_children } from '../2-analyze/visitors/shared/special-element.js';
import * as state from '../../state.js'; import * as state from '../../state.js';

@ -1,7 +1,7 @@
/** @import { ObjectExpression } from 'estree' */ /** @import { ObjectExpression } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
import { NAMESPACE_MATHML, NAMESPACE_SVG } from '../../../../constants.js'; import { NAMESPACE_MATHML, NAMESPACE_SVG } from '../../../constants.js';
import * as e from '../../../errors.js'; import * as e from '../../errors.js';
/** /**
* @param {AST.SvelteOptionsRaw} node * @param {AST.SvelteOptionsRaw} node

@ -1,11 +1,11 @@
/** @import { Program } from 'estree' */ /** @import { Program } from 'estree' */
/** @import { AST } from '#compiler' */ /** @import { AST } from '#compiler' */
/** @import { Parser } from '../index.js' */ /** @import { Parser } from './index.js' */
import { parse_script } from '../js.js'; import { parse_script } from './js.js';
import * as e from '../../../errors.js'; import * as e from '../../errors.js';
import * as w from '../../../warnings.js'; import * as w from '../../warnings.js';
import { is_text_attribute } from '../../../utils/ast.js'; import { is_text_attribute } from '../../utils/ast.js';
import { locator } from '../../../state.js'; import { locator } from '../../state.js';
const regex_closing_script_tag = /<\/script\s*>/; const regex_closing_script_tag = /<\/script\s*>/;
const regex_starts_with_closing_script_tag = /<\/script\s*>/y; const regex_starts_with_closing_script_tag = /<\/script\s*>/y;
@ -30,8 +30,7 @@ export function read_script(parser, start, attributes) {
parser.read(regex_starts_with_closing_script_tag); parser.read(regex_starts_with_closing_script_tag);
if (ast.loc) { if (ast.loc) {
// Acorn always uses `0` as the start of a `Program`, but for sourcemap purposes // the legacy AST places the program at the tag, not at its contents
// we need it to be the start of the `<script>` contents
({ line: ast.loc.start.line, column: ast.loc.start.column } = locator(start)); ({ line: ast.loc.start.line, column: ast.loc.start.column } = locator(start));
({ line: ast.loc.end.line, column: ast.loc.end.column } = locator(parser.index)); ({ line: ast.loc.end.line, column: ast.loc.end.column } = locator(parser.index));
} }

@ -4,8 +4,8 @@
/** @import { Parser } from '../index.js' */ /** @import { Parser } from '../index.js' */
import { is_void, REGEX_VALID_TAG_NAME } from '../../../../utils.js'; import { is_void, REGEX_VALID_TAG_NAME } from '../../../../utils.js';
import { read_expression } from '../js.js'; import { read_expression } from '../js.js';
import { read_script } from '../read/script.js'; import { read_script } from '../script.js';
import read_style from '../read/style.js'; import read_style from '../css.js';
import { decode_character_references } from '../utils/html.js'; import { decode_character_references } from '../utils/html.js';
import * as e from '../../../errors.js'; import * as e from '../../../errors.js';
import * as w from '../../../warnings.js'; import * as w from '../../../warnings.js';

Loading…
Cancel
Save