From 6e9de97af4b5cf5c9572fa47745ca9d83d62f5d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Thu, 26 Sep 2024 18:43:15 +0200 Subject: [PATCH 1/2] feat: expose ESM version --- .github/workflows/ci.yml | 1 + package.json | 4 +++- tsconfig.esm.json | 8 ++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 tsconfig.esm.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ca9b426..64e0392 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,4 +13,5 @@ jobs: node-version: 14 - run: npm ci - run: npm run compile + - run: npm run compile:esm - run: npm test diff --git a/package.json b/package.json index e6c32f0..ff7b21b 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "name": "Microsoft Corporation" }, "main": "./release/main.js", + "module": "./release/esm/main.js", "typings": "./release/main.d.ts", "repository": { "type": "git", @@ -18,13 +19,14 @@ "scripts": { "watch": "tsc --watch", "compile": "tsc", + "compile:esm": "tsc -b ./tsconfig.esm.json", "test": "mocha --ui=tdd ./out/tests/all.test.js", "benchmark": "node benchmark/benchmark.js", "inspect": "node out/tests/inspect.js", "tmconvert": "node scripts/tmconvert.js", "version": "npm run compile && npm run test", "postversion": "git push && git push --tags", - "prepublishOnly": "tsc && webpack --progress", + "prepublishOnly": "tsc && tsc -b ./tsconfig.esm.json && webpack --progress", "bundle": "webpack" }, "devDependencies": { diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 0000000..756bbf8 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,8 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { + "module": "ES2020", + "outDir": "release/esm", + "sourceMap": false + } +} From 01c4364d1171bf3dcaf8eac2757d90c00f8e5e51 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= Date: Thu, 26 Sep 2024 18:43:40 +0200 Subject: [PATCH 2/2] fix: make code ES2020 compatible --- src/diffStateStacks.ts | 2 +- src/main.ts | 2 +- src/registry.ts | 2 +- src/tests/inspect.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/diffStateStacks.ts b/src/diffStateStacks.ts index d2528e5..5a18e31 100644 --- a/src/diffStateStacks.ts +++ b/src/diffStateStacks.ts @@ -2,7 +2,7 @@ * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ -import { StateStackImpl, StateStackFrame } from "./grammar"; +import { StateStackImpl, StateStackFrame } from "./grammar/index"; import { StateStack } from "./main"; export function diffStateStacksRefEq(first: StateStack, second: StateStack): StackDiff { diff --git a/src/main.ts b/src/main.ts index b79dd99..de9d92f 100644 --- a/src/main.ts +++ b/src/main.ts @@ -2,7 +2,7 @@ * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ -import { BalancedBracketSelectors, StateStackImpl } from './grammar'; +import { BalancedBracketSelectors, StateStackImpl } from './grammar/index'; import * as grammarReader from './parseRawGrammar'; import { IOnigLib } from './onigLib'; import { IRawGrammar } from './rawGrammar'; diff --git a/src/registry.ts b/src/registry.ts index 600608c..9e60a6d 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -2,7 +2,7 @@ * Copyright (C) Microsoft Corporation. All rights reserved. *--------------------------------------------------------*/ -import { BalancedBracketSelectors, createGrammar, Grammar, IGrammarRepository, IThemeProvider, AttributedScopeStack } from './grammar'; +import { BalancedBracketSelectors, createGrammar, Grammar, IGrammarRepository, IThemeProvider, AttributedScopeStack } from './grammar/index'; import { IRawGrammar } from './rawGrammar'; import { IGrammar, IEmbeddedLanguagesMap, ITokenTypeMap } from './main'; import { ScopeStack, Theme, StyleAttributes, ThemeTrieElementRule, ScopeName } from './theme'; diff --git a/src/tests/inspect.ts b/src/tests/inspect.ts index 3a1a565..85df15a 100644 --- a/src/tests/inspect.ts +++ b/src/tests/inspect.ts @@ -4,7 +4,7 @@ import * as fs from 'fs'; import { Registry, IGrammar, parseRawGrammar } from '../main'; -import { StateStackImpl as StackElementImpl, Grammar as GrammarImpl } from '../grammar'; +import { StateStackImpl as StackElementImpl, Grammar as GrammarImpl } from '../grammar/index'; import * as debug from '../debug'; import { getOniguruma } from './onigLibs';