Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ohm-wasm-browser-parsing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/liquid-html-parser': minor
---

Integrate @ohm-js/wasm for browser-compatible parsing
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
node-version: [18, 20]
node-version: [20]

name: Tests / OS ${{ matrix.os }} / NodeJS ${{ matrix.node-version }}

Expand Down
1 change: 1 addition & 0 deletions packages/codemirror-language-client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"outDir": "./dist/esm",
"tsBuildInfoFile": "./dist/esm/tsconfig.tsbuildInfo",
"module": "es6",
"moduleResolution": "node",
"rootDir": "src",
"resolveJsonModule": false,
"lib": [
Expand Down
1 change: 1 addition & 0 deletions packages/lang-jsonc/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"outDir": "./dist/esm",
"tsBuildInfoFile": "./dist/esm/tsconfig.tsbuildInfo",
"module": "es6",
"moduleResolution": "node",
"rootDir": "src",
"resolveJsonModule": false,
"lib": [
Expand Down
4 changes: 3 additions & 1 deletion packages/liquid-html-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@
"type-check": "tsc --noEmit"
},
"dependencies": {
"@ohm-js/compiler": "18.0.0-beta.7",
"@ohm-js/to-ast-compat": "18.0.0-beta.7",
"line-column": "^1.0.2",
"ohm-js": "^17.0.0"
"ohm-js": "18.0.0-beta.7"
},
"devDependencies": {
"@types/line-column": "^1.0.0"
Expand Down
8 changes: 4 additions & 4 deletions packages/liquid-html-parser/src/errors.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import lineColumn from 'line-column';
import { MatchResult } from 'ohm-js';
import { FailedMatchResult } from 'ohm-js';
import { NodeTypes, Position } from './types';

interface LineColPosition {
Expand All @@ -10,12 +10,12 @@ interface LineColPosition {
export class LiquidHTMLCSTParsingError extends SyntaxError {
loc?: { start: LineColPosition; end: LineColPosition };

constructor(ohm: MatchResult) {
constructor(ohm: FailedMatchResult) {
super(ohm.shortMessage);
this.name = 'LiquidHTMLParsingError';

const input = (ohm as any).input;
const errorPos = (ohm as any)._rightmostFailurePosition;
const input = ohm.input;
const errorPos = ohm.getRightmostFailurePosition();
const lineCol = lineColumn(input).fromIndex(Math.min(errorPos, input.length - 1));

// Plugging ourselves into @babel/code-frame since this is how
Expand Down
6 changes: 3 additions & 3 deletions packages/liquid-html-parser/src/grammar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ describe('Unit: liquidHtmlGrammar', () => {
expectMatchSucceeded('<6h>').to.be.false;

function expectMatchSucceeded(text: string) {
const match = grammar.LiquidHTML.match(text, 'Node');
using match = grammar.LiquidHTML.match(text, 'Node');
return expect(match.succeeded(), text);
}
});
Expand Down Expand Up @@ -129,7 +129,7 @@ describe('Unit: liquidHtmlGrammar', () => {
`).to.be.true;

function expectMatchSucceeded(text: string) {
const match = grammar.LiquidStatement.match(text.trimStart(), 'Node');
using match = grammar.LiquidStatement.match(text.trimStart(), 'Node');
return expect(match.succeeded(), text);
}
});
Expand All @@ -156,7 +156,7 @@ describe('Unit: liquidHtmlGrammar', () => {
});

function expectMatchSucceeded(text: string) {
const match = placeholderGrammars.LiquidHTML.match(text.trimStart(), 'Node');
using match = placeholderGrammars.LiquidHTML.match(text.trimStart(), 'Node');
return expect(match.succeeded(), text);
}
});
Expand Down
2 changes: 1 addition & 1 deletion packages/liquid-html-parser/src/grammar.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { grammars, Grammar } from 'ohm-js';
import { grammars, Grammar } from '@ohm-js/compiler/compat';

export const liquidHtmlGrammars = grammars(require('../grammar/liquid-html.ohm.js'));

Expand Down
Loading
Loading