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/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'; 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 + } +}