Skip to content

Commit f50b350

Browse files
committed
fix: include js file extension into the mjs build, closes #22
1 parent 824312f commit f50b350

14 files changed

+38
-25
lines changed

.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
"order": "asc",
4949
"caseInsensitive": true
5050
}
51-
}]
51+
}],
52+
"import/extensions": ["error", "always"]
5253
},
5354
"settings": {
5455
"import/resolver": {

benchmark/benchmark.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {createParser} from '../src';
1+
import {createParser} from '../src/index.js';
22

33
const parse = createParser({substitutes: true});
44

jest.config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/** @type {import('ts-jest').JestConfigWithTsJest} */
22
module.exports = {
33
preset: 'ts-jest',
4-
testEnvironment: 'node'
4+
testEnvironment: 'node',
5+
resolver: 'jest-ts-webcompat-resolver'
56
};

package-lock.json

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"eslint-plugin-prettier": "^4.2.1",
3939
"husky": "^4.3.8",
4040
"jest": "^29.5.0",
41+
"jest-ts-webcompat-resolver": "^1.0.0",
4142
"prettier": "^2.2.1",
4243
"standard-version": "^9.5.0",
4344
"ts-jest": "^29.1.0",
@@ -67,8 +68,8 @@
6768
"test": "jest test",
6869
"test:watch": "jest --watch test",
6970
"test:dist": "TEST_DIST=cjs npm run test",
70-
"lint": "eslint src/**.ts",
71-
"lint:fix": "eslint --fix src/**.ts",
71+
"lint": "eslint {src,test,benchmark}/**.ts",
72+
"lint:fix": "eslint --fix {src,test,benchmark}/**.ts",
7273
"benchmark": "ts-node benchmark/benchmark.ts",
7374
"release": "standard-version",
7475
"prepublishOnly": "npm run build"

src/index.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
export {createParser, Parser, ParserError} from './parser';
2-
export {render} from './render';
1+
export {createParser, Parser, ParserError} from './parser.js';
2+
export {render} from './render.js';
33
export {
44
ast,
55
AstAttribute,
@@ -17,5 +17,5 @@ export {
1717
AstTagName,
1818
AstWildcardNamespace,
1919
AstWildcardTag
20-
} from './ast';
21-
export {CssLevel, SyntaxDefinition} from './syntax-definitions';
20+
} from './ast.js';
21+
export {CssLevel, SyntaxDefinition} from './syntax-definitions.js';

src/parser.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import {AstAttribute, AstPseudoClass, AstRule, AstSelector, AstTagName, AstWildcardTag} from './ast';
1+
import {AstAttribute, AstPseudoClass, AstRule, AstSelector, AstTagName, AstWildcardTag} from './ast.js';
22
import {
33
createMulticharIndex,
44
createRegularIndex,
55
emptyMulticharIndex,
66
emptyRegularIndex,
77
MulticharIndex
8-
} from './indexes';
8+
} from './indexes.js';
99
import {
1010
calculatePseudoClassSignatures,
1111
defaultPseudoClassSignature,
1212
emptyPseudoClassSignatures
13-
} from './pseudo-class-signatures';
13+
} from './pseudo-class-signatures.js';
1414
import {
1515
CssLevel,
1616
cssSyntaxDefinitions,
1717
extendSyntaxDefinition,
1818
getXmlOptions,
1919
SyntaxDefinition
20-
} from './syntax-definitions';
21-
import {digitsChars, isHex, isIdent, isIdentStart, quoteChars, stringEscapeChars, whitespaceChars} from './utils';
20+
} from './syntax-definitions.js';
21+
import {digitsChars, isHex, isIdent, isIdentStart, quoteChars, stringEscapeChars, whitespaceChars} from './utils.js';
2222

2323
/**
2424
* This error is thrown when parser encounters problems in CSS string.

src/pseudo-class-signatures.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {PseudoClassType} from './syntax-definitions';
1+
import {PseudoClassType} from './syntax-definitions.js';
22

33
export type PseudoClassSignature = {optional: boolean} & (
44
| {

src/render.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {AstNamespaceName, AstNoNamespace, AstRule, AstSelector, AstSubstitution, AstWildcardNamespace} from './ast';
2-
import {escapeIdentifier, escapePseudoClassString, escapeStr} from './utils';
1+
import {AstNamespaceName, AstNoNamespace, AstRule, AstSelector, AstSubstitution, AstWildcardNamespace} from './ast.js';
2+
import {escapeIdentifier, escapePseudoClassString, escapeStr} from './utils.js';
33

44
function renderNamespace(namespace: AstNamespaceName | AstWildcardNamespace | AstNoNamespace) {
55
if (namespace.type === 'WildcardNamespace') {

src/syntax-definitions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {AstPseudoClassArgument} from './ast';
1+
import {AstPseudoClassArgument} from './ast.js';
22

33
export type PseudoClassType = 'NoArgument' | AstPseudoClassArgument['type'];
44
export type CssLevel = 'css1' | 'css2' | 'css3' | 'selectors-3' | 'selectors-4' | 'latest' | 'progressive';

test/ast.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import {ast} from './import';
2-
import {AstEntity} from '../src';
1+
import {ast} from './import.js';
2+
import {AstEntity} from '../src/index.js';
33

44
const lcFirst = (s: string) => s[0].toLowerCase() + s.slice(1);
55

test/import.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import * as Lib from '../src';
1+
import * as Lib from '../src/index.js';
22

33
// eslint-disable-next-line @typescript-eslint/no-var-requires
44
const {ast, render, createParser} = require(process.env.TEST_DIST
5-
? `../dist/${process.env.TEST_DIST}`
6-
: '../src') as typeof Lib;
5+
? `../dist/${process.env.TEST_DIST}/index.js`
6+
: '../src/index.js') as typeof Lib;
77

88
export {ast, render, createParser};

test/parser.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {createParser, ast} from './import';
1+
import {createParser, ast} from './import.js';
22

33
describe('parse()', () => {
44
const parse = createParser({

test/render.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {createParser, render} from './import';
1+
import {createParser, render} from './import.js';
22

33
const testCases = {
44
'.class': '.class',

0 commit comments

Comments
 (0)