comment-parser 1.3.1 → 1.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/browser/index.js +1 -1
  3. package/es6/index.d.ts +14 -14
  4. package/es6/parser/block-parser.d.ts +3 -3
  5. package/es6/parser/index.d.ts +3 -3
  6. package/es6/parser/source-parser.d.ts +2 -2
  7. package/es6/parser/spec-parser.d.ts +3 -3
  8. package/es6/parser/tokenizers/description.d.ts +4 -4
  9. package/es6/parser/tokenizers/index.d.ts +2 -2
  10. package/es6/parser/tokenizers/name.d.ts +1 -1
  11. package/es6/parser/tokenizers/tag.d.ts +1 -1
  12. package/es6/parser/tokenizers/type.d.ts +3 -3
  13. package/es6/primitives.js +1 -1
  14. package/es6/stringifier/index.d.ts +2 -2
  15. package/es6/stringifier/inspect.d.ts +1 -1
  16. package/es6/transforms/align.d.ts +2 -2
  17. package/es6/transforms/crlf.d.ts +2 -2
  18. package/es6/transforms/indent.d.ts +1 -1
  19. package/es6/transforms/index.d.ts +2 -2
  20. package/es6/util.d.ts +1 -1
  21. package/jest.config.cjs +3 -1
  22. package/lib/index.cjs +39 -33
  23. package/lib/index.cjs.map +1 -1
  24. package/lib/index.d.ts +14 -14
  25. package/lib/parser/block-parser.d.ts +3 -3
  26. package/lib/parser/index.cjs +16 -16
  27. package/lib/parser/index.cjs.map +1 -1
  28. package/lib/parser/index.d.ts +3 -3
  29. package/lib/parser/source-parser.cjs +8 -8
  30. package/lib/parser/source-parser.cjs.map +1 -1
  31. package/lib/parser/source-parser.d.ts +2 -2
  32. package/lib/parser/spec-parser.cjs +2 -2
  33. package/lib/parser/spec-parser.cjs.map +1 -1
  34. package/lib/parser/spec-parser.d.ts +3 -3
  35. package/lib/parser/tokenizers/description.cjs +4 -4
  36. package/lib/parser/tokenizers/description.cjs.map +1 -1
  37. package/lib/parser/tokenizers/description.d.ts +4 -4
  38. package/lib/parser/tokenizers/index.d.ts +2 -2
  39. package/lib/parser/tokenizers/name.cjs +4 -4
  40. package/lib/parser/tokenizers/name.cjs.map +1 -1
  41. package/lib/parser/tokenizers/name.d.ts +1 -1
  42. package/lib/parser/tokenizers/tag.d.ts +1 -1
  43. package/lib/parser/tokenizers/type.cjs +2 -2
  44. package/lib/parser/tokenizers/type.cjs.map +1 -1
  45. package/lib/parser/tokenizers/type.d.ts +3 -3
  46. package/lib/stringifier/index.d.ts +2 -2
  47. package/lib/stringifier/inspect.cjs +2 -2
  48. package/lib/stringifier/inspect.cjs.map +1 -1
  49. package/lib/stringifier/inspect.d.ts +1 -1
  50. package/lib/transforms/align.cjs +5 -5
  51. package/lib/transforms/align.cjs.map +1 -1
  52. package/lib/transforms/align.d.ts +2 -2
  53. package/lib/transforms/crlf.cjs +2 -2
  54. package/lib/transforms/crlf.cjs.map +1 -1
  55. package/lib/transforms/crlf.d.ts +2 -2
  56. package/lib/transforms/indent.cjs +2 -2
  57. package/lib/transforms/indent.cjs.map +1 -1
  58. package/lib/transforms/indent.d.ts +1 -1
  59. package/lib/transforms/index.d.ts +2 -2
  60. package/lib/util.d.ts +1 -1
  61. package/package.json +3 -4
  62. package/src/index.ts +13 -13
  63. package/src/parser/block-parser.ts +1 -1
  64. package/src/parser/index.ts +10 -10
  65. package/src/parser/source-parser.ts +2 -2
  66. package/src/parser/spec-parser.ts +3 -3
  67. package/src/parser/tokenizers/description.ts +2 -2
  68. package/src/parser/tokenizers/index.ts +1 -1
  69. package/src/parser/tokenizers/name.ts +3 -3
  70. package/src/parser/tokenizers/tag.ts +2 -2
  71. package/src/parser/tokenizers/type.ts +3 -3
  72. package/src/stringifier/index.ts +1 -1
  73. package/src/stringifier/inspect.ts +2 -2
  74. package/src/transforms/align.ts +3 -3
  75. package/src/transforms/crlf.ts +3 -3
  76. package/src/transforms/indent.ts +3 -3
  77. package/src/transforms/index.ts +1 -1
  78. package/src/util.ts +1 -1
  79. package/tests/e2e/examples.js +41 -0
  80. package/tests/unit/block-parser.spec.ts +3 -3
  81. package/tests/unit/inspect.spec.ts +3 -3
  82. package/tests/unit/parser.spec.ts +2 -2
  83. package/tests/unit/source-parser.spec.ts +3 -3
  84. package/tests/unit/spacer-description-joiner.spec.ts +3 -3
  85. package/tests/unit/spec-description-tokenizer.spec.ts +2 -2
  86. package/tests/unit/spec-name-tokenizer.spec.ts +2 -2
  87. package/tests/unit/spec-parser.spec.ts +7 -7
  88. package/tests/unit/spec-tag-tokenizer.spec.ts +2 -2
  89. package/tests/unit/spec-type-tokenizer.spec.ts +2 -2
  90. package/tests/unit/stringifier.spec.ts +1 -1
  91. package/tests/unit/transforms-align.spec.ts +3 -3
  92. package/tests/unit/transforms-crlf.spec.ts +3 -3
  93. package/tests/unit/transforms-indent.spec.ts +3 -3
  94. package/tests/unit/transforms.spec.ts +3 -3
  95. package/tests/unit/util-rewire.spec.ts +1 -1
  96. package/tests/unit/util.spec.ts +1 -1
  97. package/tsconfig.json +1 -2
  98. package/tsconfig.node.json +1 -1
package/lib/util.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Block, Tokens, Spec } from './primitives';
1
+ import { Block, Tokens, Spec } from './primitives.js';
2
2
  export declare function isSpace(source: string): boolean;
3
3
  export declare function hasCR(source: string): boolean;
4
4
  export declare function splitCR(source: string): [string, string];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "comment-parser",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "description": "Generic JSDoc-like comment parser",
5
5
  "type": "module",
6
6
  "main": "lib/index.cjs",
@@ -39,17 +39,16 @@
39
39
  "convert-extension": "^0.3.0",
40
40
  "jest": "^27.0.5",
41
41
  "prettier": "2.3.1",
42
- "replace": "^1.2.1",
43
42
  "rimraf": "^3.0.2",
44
43
  "rollup": "^2.52.2",
45
44
  "ts-jest": "^27.0.3",
46
- "typescript": "^4.3.4"
45
+ "typescript": "^4.9.5"
47
46
  },
48
47
  "engines": {
49
48
  "node": ">= 12.0.0"
50
49
  },
51
50
  "scripts": {
52
- "build": "rimraf lib es6 browser; tsc -p tsconfig.json && tsc -p tsconfig.node.json && rollup -o browser/index.js -f iife --context window -n CommentParser es6/index.js && convert-extension cjs lib/ && cd es6 && replace \"from '(\\.[^']*)'\" \"from '\\$1.js'\" * -r --include=\"*.js\"",
51
+ "build": "rimraf lib es6 browser; tsc -p tsconfig.json && tsc -p tsconfig.node.json && rollup -o browser/index.js -f iife --context window -n CommentParser es6/index.js && convert-extension cjs lib/",
53
52
  "format": "prettier --write src tests",
54
53
  "pretest": "rimraf coverage; npm run build",
55
54
  "test": "prettier --check src tests && jest --verbose",
package/src/index.ts CHANGED
@@ -1,23 +1,23 @@
1
- import getParser, { Options as ParserOptions } from './parser/index';
2
- import descriptionTokenizer from './parser/tokenizers/description';
3
- import nameTokenizer from './parser/tokenizers/name';
4
- import tagTokenizer from './parser/tokenizers/tag';
5
- import typeTokenizer from './parser/tokenizers/type';
6
- import getStringifier from './stringifier/index';
7
- import alignTransform from './transforms/align';
8
- import indentTransform from './transforms/indent';
9
- import crlfTransform from './transforms/crlf';
10
- import { flow as flowTransform } from './transforms/index';
11
- import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util';
1
+ import getParser, { Options as ParserOptions } from './parser/index.js';
2
+ import descriptionTokenizer from './parser/tokenizers/description.js';
3
+ import nameTokenizer from './parser/tokenizers/name.js';
4
+ import tagTokenizer from './parser/tokenizers/tag.js';
5
+ import typeTokenizer from './parser/tokenizers/type.js';
6
+ import getStringifier from './stringifier/index.js';
7
+ import alignTransform from './transforms/align.js';
8
+ import indentTransform from './transforms/indent.js';
9
+ import crlfTransform from './transforms/crlf.js';
10
+ import { flow as flowTransform } from './transforms/index.js';
11
+ import { rewireSpecs, rewireSource, seedBlock, seedTokens } from './util.js';
12
12
 
13
- export * from './primitives';
13
+ export * from './primitives.js';
14
14
 
15
15
  export function parse(source: string, options: Partial<ParserOptions> = {}) {
16
16
  return getParser(options)(source);
17
17
  }
18
18
 
19
19
  export const stringify = getStringifier();
20
- export { default as inspect } from './stringifier/inspect';
20
+ export { default as inspect } from './stringifier/inspect.js';
21
21
 
22
22
  export const transforms = {
23
23
  flow: flowTransform,
@@ -1,4 +1,4 @@
1
- import { Line } from '../primitives';
1
+ import { Line } from '../primitives.js';
2
2
 
3
3
  const reTag = /^@\S+/;
4
4
 
@@ -1,15 +1,15 @@
1
- import { Block, Line, Problem, BlockMarkers, Markers } from '../primitives';
2
- import { splitLines } from '../util';
3
- import blockParser from './block-parser';
4
- import sourceParser from './source-parser';
5
- import specParser from './spec-parser';
6
- import { Tokenizer } from './tokenizers/index';
7
- import tokenizeTag from './tokenizers/tag';
8
- import tokenizeType from './tokenizers/type';
9
- import tokenizeName from './tokenizers/name';
1
+ import { Block, Line, Problem, BlockMarkers, Markers } from '../primitives.js';
2
+ import { splitLines } from '../util.js';
3
+ import blockParser from './block-parser.js';
4
+ import sourceParser from './source-parser.js';
5
+ import specParser from './spec-parser.js';
6
+ import { Tokenizer } from './tokenizers/index.js';
7
+ import tokenizeTag from './tokenizers/tag.js';
8
+ import tokenizeType from './tokenizers/type.js';
9
+ import tokenizeName from './tokenizers/name.js';
10
10
  import tokenizeDescription, {
11
11
  getJoiner as getDescriptionJoiner,
12
- } from './tokenizers/description';
12
+ } from './tokenizers/description.js';
13
13
 
14
14
  export interface Options {
15
15
  // start count for source line numbers
@@ -1,5 +1,5 @@
1
- import { Line, Tokens, BlockMarkers, Markers } from '../primitives';
2
- import { seedTokens, splitSpace, splitCR } from '../util';
1
+ import { Line, Tokens, BlockMarkers, Markers } from '../primitives.js';
2
+ import { seedTokens, splitSpace, splitCR } from '../util.js';
3
3
 
4
4
  export interface Options {
5
5
  startLine: number;
@@ -1,6 +1,6 @@
1
- import { Line, Spec } from '../primitives';
2
- import { seedSpec } from '../util';
3
- import { Tokenizer } from './tokenizers/index';
1
+ import { Line, Spec } from '../primitives.js';
2
+ import { seedSpec } from '../util.js';
3
+ import { Tokenizer } from './tokenizers/index.js';
4
4
 
5
5
  export type Parser = (source: Line[]) => Spec;
6
6
 
@@ -1,5 +1,5 @@
1
- import { Spec, Line, BlockMarkers, Markers } from '../../primitives';
2
- import { Tokenizer } from './index';
1
+ import { Spec, Line, BlockMarkers, Markers } from '../../primitives.js';
2
+ import { Tokenizer } from './index.js';
3
3
 
4
4
  /**
5
5
  * Walks over provided lines joining description token into a single string.
@@ -1,4 +1,4 @@
1
- import { Spec } from '../../primitives';
1
+ import { Spec } from '../../primitives.js';
2
2
 
3
3
  /**
4
4
  * Splits `spect.lines[].token.description` into other tokens,
@@ -1,6 +1,6 @@
1
- import { Spec, Line } from '../../primitives';
2
- import { splitSpace, isSpace } from '../../util';
3
- import { Tokenizer } from './index';
1
+ import { Spec, Line } from '../../primitives.js';
2
+ import { splitSpace, isSpace } from '../../util.js';
3
+ import { Tokenizer } from './index.js';
4
4
 
5
5
  const isQuoted = (s: string) => s && s.startsWith('"') && s.endsWith('"');
6
6
 
@@ -1,5 +1,5 @@
1
- import { Spec } from '../../primitives';
2
- import { Tokenizer } from './index';
1
+ import { Spec } from '../../primitives.js';
2
+ import { Tokenizer } from './index.js';
3
3
 
4
4
  /**
5
5
  * Splits the `@prefix` from remaining `Spec.lines[].token.description` into the `tag` token,
@@ -1,6 +1,6 @@
1
- import { Spec, Tokens } from '../../primitives';
2
- import { splitSpace } from '../../util';
3
- import { Tokenizer } from './index';
1
+ import { Spec, Tokens } from '../../primitives.js';
2
+ import { splitSpace } from '../../util.js';
3
+ import { Tokenizer } from './index.js';
4
4
 
5
5
  /**
6
6
  * Joiner is a function taking collected type token string parts,
@@ -1,4 +1,4 @@
1
- import { Block, Tokens } from '../primitives';
1
+ import { Block, Tokens } from '../primitives.js';
2
2
 
3
3
  export type Stringifier = (block: Block) => string;
4
4
 
@@ -1,5 +1,5 @@
1
- import { Block, Tokens } from '../primitives';
2
- import { isSpace } from '../util';
1
+ import { Block, Tokens } from '../primitives.js';
2
+ import { isSpace } from '../util.js';
3
3
 
4
4
  interface Width {
5
5
  line: number;
@@ -1,6 +1,6 @@
1
- import { Transform } from './index';
2
- import { BlockMarkers, Block, Line, Markers } from '../primitives';
3
- import { rewireSource } from '../util';
1
+ import { Transform } from './index.js';
2
+ import { BlockMarkers, Block, Line, Markers } from '../primitives.js';
3
+ import { rewireSource } from '../util.js';
4
4
 
5
5
  interface Width {
6
6
  start: number;
@@ -1,6 +1,6 @@
1
- import { Transform } from './index';
2
- import { Block, Line } from '../primitives';
3
- import { rewireSource } from '../util';
1
+ import { Transform } from './index.js';
2
+ import { Block, Line } from '../primitives.js';
3
+ import { rewireSource } from '../util.js';
4
4
 
5
5
  const order = [
6
6
  'end',
@@ -1,6 +1,6 @@
1
- import { Transform } from './index';
2
- import { Block, Line } from '../primitives';
3
- import { rewireSource } from '../util';
1
+ import { Transform } from './index.js';
2
+ import { Block, Line } from '../primitives.js';
3
+ import { rewireSource } from '../util.js';
4
4
 
5
5
  const pull = (offset: number) => (str) => str.slice(offset);
6
6
  const push = (offset: number) => {
@@ -1,4 +1,4 @@
1
- import { Block } from '../primitives';
1
+ import { Block } from '../primitives.js';
2
2
 
3
3
  export type Transform = (Block: Block) => Block;
4
4
 
package/src/util.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Block, Tokens, Spec, Line } from './primitives';
1
+ import { Block, Tokens, Spec, Line } from './primitives.js';
2
2
 
3
3
  export function isSpace(source: string): boolean {
4
4
  return /^\s+$/.test(source);
@@ -192,6 +192,46 @@ function parse_advanced_parsing(source, parse, _, _, tokenizers) {
192
192
  .join('\n');
193
193
  }
194
194
 
195
+ function stringify_rename(source, parse, stringify, transforms) {
196
+ // You can do any manipulations with the parsed result
197
+ // See how each block is being mapped. If you are updating a Block.source
198
+ // then rewireSource(block) should be called on each changed block.
199
+ // If changes were made to Block.tags[].source then call rewireSpecs(block).
200
+ // This example shows how you can "rename" @param tags: value1 -> value11, value2 -> value22
201
+
202
+ /**
203
+ * Description may go
204
+ * over multiple lines followed by @tags
205
+ * @param {string} name the name parameter
206
+ * @param {any} value1 first value parameter
207
+ * with a multipline description
208
+ * @param {any} value2 second value parameter
209
+ */
210
+
211
+ function renameParam(from, to) {
212
+ return (block) => {
213
+ for (const tag of block.tags) {
214
+ if (tag.tag === 'param' && tag.name === from) {
215
+ tag.name = to;
216
+ for (const line of tag.source) {
217
+ if (line.tokens.name === from) line.tokens.name = to;
218
+ }
219
+ }
220
+ }
221
+ return block;
222
+ };
223
+ }
224
+
225
+ const transform = transforms.flow(
226
+ renameParam('value1', 'value11'),
227
+ renameParam('value2', 'value22'),
228
+ stringify
229
+ );
230
+
231
+ const parsed = parse(source);
232
+ const stringified = parsed.map(transform);
233
+ }
234
+
195
235
  (typeof window === 'undefined' ? module.exports : window).examples = [
196
236
  parse_defaults,
197
237
  parse_line_numbering,
@@ -200,4 +240,5 @@ function parse_advanced_parsing(source, parse, _, _, tokenizers) {
200
240
  parse_source_exploration,
201
241
  parse_advanced_parsing,
202
242
  stringify_formatting,
243
+ stringify_rename,
203
244
  ];
@@ -1,6 +1,6 @@
1
- import getParser from '../../src/parser/block-parser';
2
- import { Line } from '../../src/primitives';
3
- import { seedTokens } from '../../src/util';
1
+ import getParser from '../../src/parser/block-parser.js';
2
+ import { Line } from '../../src/primitives.js';
3
+ import { seedTokens } from '../../src/util.js';
4
4
 
5
5
  let source: Line[];
6
6
 
@@ -1,6 +1,6 @@
1
- import getParser from '../../src/parser/index';
2
- import inspect from '../../src/stringifier/inspect';
3
- import { seedBlock } from '../../src/util';
1
+ import getParser from '../../src/parser/index.js';
2
+ import inspect from '../../src/stringifier/inspect.js';
3
+ import { seedBlock } from '../../src/util.js';
4
4
 
5
5
  test('multiple lines', () => {
6
6
  const source = `
@@ -1,5 +1,5 @@
1
- import getParser from '../../src/parser';
2
- import { seedTokens } from '../../src/util';
1
+ import getParser from '../../src/parser/index.js';
2
+ import { seedTokens } from '../../src/util.js';
3
3
 
4
4
  test('block with tags', () => {
5
5
  const parsed = getParser()(`
@@ -1,6 +1,6 @@
1
- import getParser, { Parser } from '../../src/parser/source-parser';
2
- import { Line } from '../../src/primitives';
3
- import { splitLines, seedBlock, seedTokens } from '../../src/util';
1
+ import getParser, { Parser } from '../../src/parser/source-parser.js';
2
+ import { Line } from '../../src/primitives.js';
3
+ import { splitLines, seedBlock, seedTokens } from '../../src/util.js';
4
4
 
5
5
  let _parse: Parser;
6
6
 
@@ -1,6 +1,6 @@
1
- import { getJoiner } from '../../src/parser/tokenizers/description';
2
- import { Line } from '../../src/primitives';
3
- import { seedTokens } from '../../src/util';
1
+ import { getJoiner } from '../../src/parser/tokenizers/description.js';
2
+ import { Line } from '../../src/primitives.js';
3
+ import { seedTokens } from '../../src/util.js';
4
4
 
5
5
  const source: Line[] = [
6
6
  {
@@ -1,5 +1,5 @@
1
- import descriptionTokenizer from '../../src/parser/tokenizers/description';
2
- import { seedSpec, seedTokens } from '../../src/util';
1
+ import descriptionTokenizer from '../../src/parser/tokenizers/description.js';
2
+ import { seedSpec, seedTokens } from '../../src/util.js';
3
3
 
4
4
  const sourceSingle = [
5
5
  {
@@ -1,5 +1,5 @@
1
- import nameTokenizer from '../../src/parser/tokenizers/name';
2
- import { seedTokens, seedSpec } from '../../src/util';
1
+ import nameTokenizer from '../../src/parser/tokenizers/name.js';
2
+ import { seedTokens, seedSpec } from '../../src/util.js';
3
3
 
4
4
  const tokenize = nameTokenizer();
5
5
 
@@ -1,10 +1,10 @@
1
- import descriptionTokenizer from '../../src/parser/tokenizers/description';
2
- import nameTokenizer from '../../src/parser/tokenizers/name';
3
- import tagTokenizer from '../../src/parser/tokenizers/tag';
4
- import typeTokenizer from '../../src/parser/tokenizers/type';
5
- import getParser from '../../src/parser/spec-parser';
6
- import { seedTokens, seedSpec } from '../../src/util';
7
- import { Spec, Problem } from '../../src/primitives';
1
+ import descriptionTokenizer from '../../src/parser/tokenizers/description.js';
2
+ import nameTokenizer from '../../src/parser/tokenizers/name.js';
3
+ import tagTokenizer from '../../src/parser/tokenizers/tag.js';
4
+ import typeTokenizer from '../../src/parser/tokenizers/type.js';
5
+ import getParser from '../../src/parser/spec-parser.js';
6
+ import { seedTokens, seedSpec } from '../../src/util.js';
7
+ import { Spec, Problem } from '../../src/primitives.js';
8
8
 
9
9
  const parse = getParser({
10
10
  tokenizers: [
@@ -1,5 +1,5 @@
1
- import tagTokenizer from '../../src/parser/tokenizers/tag';
2
- import { seedTokens, seedSpec } from '../../src/util';
1
+ import tagTokenizer from '../../src/parser/tokenizers/tag.js';
2
+ import { seedTokens, seedSpec } from '../../src/util.js';
3
3
 
4
4
  const tokenize = tagTokenizer();
5
5
 
@@ -1,5 +1,5 @@
1
- import typeTokenizer, { Joiner } from '../../src/parser/tokenizers/type';
2
- import { seedTokens, seedSpec } from '../../src/util';
1
+ import typeTokenizer, { Joiner } from '../../src/parser/tokenizers/type.js';
2
+ import { seedTokens, seedSpec } from '../../src/util.js';
3
3
 
4
4
  const tokenize = typeTokenizer();
5
5
 
@@ -1,4 +1,4 @@
1
- import getStringifier from '../../src/stringifier';
1
+ import getStringifier from '../../src/stringifier/index.js';
2
2
 
3
3
  const source = [
4
4
  {
@@ -1,6 +1,6 @@
1
- import align from '../../src/transforms/align';
2
- import getParser, { Parser } from '../../src/parser/index';
3
- import getStringifier, { Stringifier } from '../../src/stringifier/index';
1
+ import align from '../../src/transforms/align.js';
2
+ import getParser, { Parser } from '../../src/parser/index.js';
3
+ import getStringifier, { Stringifier } from '../../src/stringifier/index.js';
4
4
 
5
5
  let parse: Parser;
6
6
  let stringify: Stringifier;
@@ -1,6 +1,6 @@
1
- import crlf, { Ending } from '../../src/transforms/crlf';
2
- import getParser, { Parser } from '../../src/parser/index';
3
- import getStringifier, { Stringifier } from '../../src/stringifier/index';
1
+ import crlf, { Ending } from '../../src/transforms/crlf.js';
2
+ import getParser, { Parser } from '../../src/parser/index.js';
3
+ import getStringifier, { Stringifier } from '../../src/stringifier/index.js';
4
4
 
5
5
  const tests = [
6
6
  [
@@ -1,6 +1,6 @@
1
- import indent from '../../src/transforms/indent';
2
- import getParser from '../../src/parser/index';
3
- import getStringifier from '../../src/stringifier/index';
1
+ import indent from '../../src/transforms/indent.js';
2
+ import getParser from '../../src/parser/index.js';
3
+ import getStringifier from '../../src/stringifier/index.js';
4
4
 
5
5
  test('push', () => {
6
6
  const source = `
@@ -1,6 +1,6 @@
1
- import { flow } from '../../src/transforms/index';
2
- import { seedBlock } from '../../src/util';
3
- import { Block } from '../../src/primitives';
1
+ import { flow } from '../../src/transforms/index.js';
2
+ import { seedBlock } from '../../src/util.js';
3
+ import { Block } from '../../src/primitives.js';
4
4
 
5
5
  const t0 = (b: Block): Block => ({ ...b, description: b.description + ' t0' });
6
6
  const t1 = (b: Block): Block => ({ ...b, description: b.description + ' t1' });
@@ -1,4 +1,4 @@
1
- import { seedTokens, rewireSource, rewireSpecs } from '../../src/util';
1
+ import { seedTokens, rewireSource, rewireSpecs } from '../../src/util.js';
2
2
 
3
3
  test('source to spec', () => {
4
4
  const block = {
@@ -6,7 +6,7 @@ import {
6
6
  splitLines,
7
7
  splitSpace,
8
8
  seedSpec,
9
- } from '../../src/util';
9
+ } from '../../src/util.js';
10
10
 
11
11
  test.each([
12
12
  ['beginning', '\r to end', false],
package/tsconfig.json CHANGED
@@ -1,8 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "es2015",
4
- "module": "es2015",
5
- "moduleResolution": "node",
4
+ "module": "node16",
6
5
  "declaration": true,
7
6
  "outDir": "./es6",
8
7
  "lib": ["es2016", "es5"]
@@ -2,7 +2,7 @@
2
2
  "compilerOptions": {
3
3
  "target": "es2015",
4
4
  "module": "commonjs",
5
- "moduleResolution": "node",
5
+ "moduleResolution": "node16",
6
6
  "declaration": true,
7
7
  "outDir": "./lib",
8
8
  "lib": ["es2016", "es5"]