fix: avoid babel startColumn api for now

This commit is contained in:
dpiercey 2024-10-25 14:07:49 -07:00 committed by Dylan Piercey
parent 212fbd063d
commit ea95de1dea
9 changed files with 974 additions and 1524 deletions

View File

@ -0,0 +1,10 @@
---
"@marko/translator-default": patch
"@marko/translator-interop-class-tags": patch
"@marko/translator-tags": patch
"@marko/babel-utils": patch
"@marko/compiler": patch
"marko": patch
---
Avoid babel `startColumn` api until https://github.com/babel/babel/pull/16936 is merged.

2384
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -22,56 +22,56 @@
"test:update": "UPDATE_EXPECTATIONS=1 mocha --update"
},
"devDependencies": {
"@babel/cli": "^7.25.7",
"@babel/core": "^7.25.7",
"@babel/plugin-transform-modules-commonjs": "^7.25.7",
"@babel/plugin-transform-runtime": "^7.25.7",
"@babel/preset-env": "^7.25.7",
"@babel/preset-typescript": "^7.25.7",
"@babel/register": "^7.25.7",
"@babel/cli": "^7.25.9",
"@babel/core": "^7.26.0",
"@babel/plugin-transform-modules-commonjs": "^7.25.9",
"@babel/plugin-transform-runtime": "^7.25.9",
"@babel/preset-env": "^7.26.0",
"@babel/preset-typescript": "^7.26.0",
"@babel/register": "^7.25.9",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.7",
"@ebay/browserslist-config": "^2.9.0",
"@eslint/js": "^9.8.0",
"@changesets/cli": "^2.27.9",
"@ebay/browserslist-config": "^2.10.0",
"@eslint/js": "^9.13.0",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-virtual": "^3.0.2",
"@types/babel__code-frame": "^7.0.6",
"@types/babel__generator": "^7.6.8",
"@types/babel__traverse": "^7.20.6",
"@types/jsdom": "^21.1.7",
"@types/mocha": "^10.0.7",
"@types/node": "^22.1.0",
"@types/mocha": "^10.0.9",
"@types/node": "^22.8.0",
"babel-plugin-minprops": "^2.0.1",
"bluebird": "^3.7.2",
"c8": "^10.1.2",
"chai": "^4.4.1",
"cross-env": "^7.0.3",
"diffable-html": "^5.0.0",
"esbuild": "^0.23.0",
"eslint": "^9.8.0",
"esbuild": "^0.24.0",
"eslint": "^9.13.0",
"eslint-formatter-unix": "^8.40.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"express": "^4.19.2",
"globals": "^15.9.0",
"husky": "^9.1.4",
"express": "^4.21.1",
"globals": "^15.11.0",
"husky": "^9.1.6",
"it-fails": "^1.0.8",
"jsdom": "^24.1.1",
"jsdom-context-require": "^5.2.3",
"jsdom": "^25.0.1",
"jsdom-context-require": "^5.2.4",
"kleur": "^4.1.5",
"lint-staged": "^15.2.8",
"mocha": "^10.7.0",
"lint-staged": "^15.2.10",
"mocha": "^10.7.3",
"mocha-autotest": "^1.1.2",
"mocha-snap": "^5.0.0",
"prettier": "^3.3.3",
"prettier-plugin-packagejson": "^2.5.1",
"prettier-plugin-packagejson": "^2.5.3",
"pretty-format": "^29.7.0",
"rollup": "^4.20.0",
"rollup": "^4.24.0",
"table": "^6.8.2",
"through": "^2.3.8",
"through2": "^4.0.2",
"tiny-glob": "^0.2.9",
"typescript": "^5.5.4",
"typescript-eslint": "^8.0.1",
"typescript": "^5.6.3",
"typescript-eslint": "^8.11.0",
"~ts": "file:scripts/babel-register.js"
}
}

View File

@ -28,12 +28,12 @@
"build": "babel ./src --out-dir ./dist --copy-files --config-file ../../babel.config.js --env-name=production"
},
"dependencies": {
"@babel/runtime": "^7.25.0",
"@babel/runtime": "^7.26.0",
"jsesc": "^3.0.2",
"relative-import-path": "^1.0.0"
},
"devDependencies": {
"@marko/compiler": "^5.37.15"
"@marko/compiler": "^5.37.19"
},
"publishConfig": {
"access": "public"

View File

@ -2,6 +2,7 @@ import * as babelParser from "@babel/parser";
import { types as t } from "@marko/compiler";
import { getLoc, getLocRange } from "./loc";
const CODE_AS_WHITE_SPACE_KEY = Symbol();
export function parseStatements(
file,
@ -120,9 +121,13 @@ function tryParse(
let code = str;
if (typeof sourceStart === "number") {
const startLoc = getLoc(file, sourceStart - (sourceOffset || 0));
parserOpts.startLine = startLoc.line;
parserOpts.startColumn = startLoc.column;
const whitespace =
file.metadata.marko[CODE_AS_WHITE_SPACE_KEY] ||
(file.metadata.marko[CODE_AS_WHITE_SPACE_KEY] = file.code.replace(
/[^\s]/g,
" ",
));
code = whitespace.slice(0, sourceStart - (sourceOffset || 0)) + str;
try {
return isExpression
@ -142,9 +147,6 @@ function tryParse(
} else {
return [parseError];
}
} finally {
parserOpts.startLine = 1;
parserOpts.startColumn = 0;
}
} else {
return isExpression

View File

@ -55,19 +55,19 @@
"prepare": "node -r ~ts scripts/types"
},
"dependencies": {
"@babel/code-frame": "^7.24.7",
"@babel/core": "^7.25.2",
"@babel/generator": "^7.25.0",
"@babel/parser": "^7.25.3",
"@babel/plugin-syntax-typescript": "^7.24.7",
"@babel/plugin-transform-modules-commonjs": "^7.24.8",
"@babel/plugin-transform-typescript": "^7.25.2",
"@babel/runtime": "^7.25.0",
"@babel/traverse": "^7.25.3",
"@babel/types": "^7.25.2",
"@babel/code-frame": "^7.26.0",
"@babel/core": "^7.26.0",
"@babel/generator": "^7.26.0",
"@babel/parser": "^7.26.0",
"@babel/plugin-syntax-typescript": "^7.25.9",
"@babel/plugin-transform-modules-commonjs": "^7.25.9",
"@babel/plugin-transform-typescript": "^7.25.9",
"@babel/runtime": "^7.26.0",
"@babel/traverse": "^7.25.9",
"@babel/types": "^7.26.0",
"@luxass/strip-json-comments": "^1.3.2",
"@marko/babel-utils": "^6.5.7",
"complain": "^1.6.0",
"complain": "^1.6.1",
"he": "^1.2.0",
"htmljs-parser": "^5.5.2",
"jsesc": "^3.0.2",
@ -80,7 +80,7 @@
"source-map-support": "^0.5.21"
},
"devDependencies": {
"@marko/translator-default": "^6.0.19"
"@marko/translator-default": "^6.0.20"
},
"publishConfig": {
"access": "public"

View File

@ -71,7 +71,7 @@
"app-module-path": "^2.2.0",
"argly": "^1.2.0",
"browser-refresh-client": "1.1.4",
"complain": "^1.6.0",
"complain": "^1.6.1",
"csstype": "^3.1.3",
"events-light": "^1.0.5",
"listener-tracker": "^2.0.0",

View File

@ -28,9 +28,9 @@
"build": "babel ./src --out-dir ./dist --copy-files --config-file ../../babel.config.js --env-name=production"
},
"dependencies": {
"@babel/runtime": "^7.25.0",
"@babel/runtime": "^7.26.0",
"@marko/babel-utils": "^6.5.7",
"magic-string": "^0.30.11",
"magic-string": "^0.30.12",
"self-closing-tags": "^1.0.1"
},
"devDependencies": {

View File

@ -28,10 +28,10 @@
"build": "node -r ~ts ./scripts/bundle.ts"
},
"dependencies": {
"@babel/code-frame": "^7.24.7",
"@babel/code-frame": "^7.26.0",
"@marko/babel-utils": "^6.5.7",
"@marko/translator-default": "^6.0.16",
"@marko/translator-tags": "^0.2.12"
"@marko/translator-default": "^6.0.20",
"@marko/translator-tags": "^0.2.13"
},
"peerDependencies": {
"@marko/compiler": "^5.23.0"