Skip to content

Commit

Permalink
feat: add ESM version of library
Browse files Browse the repository at this point in the history
  • Loading branch information
fczbkk committed Dec 15, 2021
1 parent 995840f commit e34bdc5
Show file tree
Hide file tree
Showing 28 changed files with 67 additions and 63 deletions.
31 changes: 0 additions & 31 deletions .eslintrc-typescript.json

This file was deleted.

File renamed without changes.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/.idea/
*.DS_Store
/temp/
/esm/
5 changes: 5 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/.grunt/
/node_modules/
/.idea/
*.DS_Store
/temp/
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Then include it in your source code:
import getCssSelector from 'css-selector-generator';
```

Or you can use the ESM version:

```javascript
import getCssSelector from 'css-selector-generator/esm';
```

## How to use

Simplest way to use it is to provide an element reference, without any options.
Expand Down
2 changes: 2 additions & 0 deletions build/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!package.json
1 change: 0 additions & 1 deletion build/index.js

This file was deleted.

1 change: 0 additions & 1 deletion build/index.js.map

This file was deleted.

3 changes: 3 additions & 0 deletions build/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,23 @@
"title": "CSS Selector Generator",
"version": "3.4.5-0",
"description": "JavaScript object that creates unique CSS selector for given element.",
"author": "Riki Fridrich <[email protected]> (http://fczbkk.com)",
"author": "Riki Fridrich <[email protected]> (https://fczbkk.com)",
"license": "MIT",
"type": "module",
"main": "build/index.js",
"exports": {
"./esm": "./esm/index.js"
},
"module": "./esm/index.js",
"types": "types/index.d.ts",
"scripts": {
"test": "karma start ./tools/karma.conf.js",
"dev": "npm run test -- --no-single-run --auto-watch",
"prebuild": "npm run lint:build && rimraf ./build",
"build": "webpack --config ./tools/webpack.build.js",
"lint": "eslint ./src/**/*.ts ./test/**/*.js ./tools/**/*.js --config .eslintrc.js",
"prebuild": "npm run lint:build",
"build": "npm run build:umd && npm run build:esm",
"build:umd": "webpack --config ./tools/webpack.build.js",
"build:esm": "tsc --project ./tsconfig.esm.json",
"lint": "eslint ./src/**/*.ts ./test/**/*.js ./tools/**/*.js --config .eslintrc.cjs",
"lint:build": "npm run lint -- --max-warnings 0",
"doc": "tsc ./src/*.ts --declaration --allowJs --emitDeclarationOnly --downlevelIteration --outDir types",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
Expand All @@ -37,7 +44,6 @@
"karma-webpack": "^5.0.0",
"mocha": "^9.1.3",
"raw-loader": "^4.0.2",
"rimraf": "^3.0.2",
"ts-loader": "^9.2.6",
"typescript": "^4.5.2",
"webpack": "^5.65.0",
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/complex.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert} from 'chai'
import {getCssSelector} from '../src'
import {getCssSelector} from '../src/index.ts'
import {testSelector} from '../src/utilities-dom.ts'
import html_code from './html/complex.html'

Expand Down
2 changes: 1 addition & 1 deletion test/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {assert} from 'chai'
import {testSelector} from '../src/utilities-dom.ts'
import {getCssSelector} from '../src'
import {getCssSelector} from '../src/index.ts'

describe('CssSelectorGenerator', function () {

Expand Down
2 changes: 1 addition & 1 deletion test/memo.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert} from 'chai'
import {createMemo} from '../src/memo'
import {createMemo} from '../src/memo.ts'

describe('Memo', () => {

Expand Down
2 changes: 1 addition & 1 deletion test/options-blacklist.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert} from 'chai'
import {getCssSelector} from '../src'
import {getCssSelector} from '../src/index.ts'

describe('options: blacklist', function () {

Expand Down
2 changes: 1 addition & 1 deletion test/options-combine-between-selectors.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert} from 'chai'
import {getCssSelector} from '../src'
import {getCssSelector} from '../src/index.ts'

describe('options: combineBetweenSelectors', function () {

Expand Down
2 changes: 1 addition & 1 deletion test/options-combine-within-selector.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert} from 'chai'
import {getCssSelector} from '../src'
import {getCssSelector} from '../src/index.ts'

describe('options: combineWithinSelector', function () {

Expand Down
2 changes: 1 addition & 1 deletion test/options-include-tag.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {getCssSelector} from '../src'
import {getCssSelector} from '../src/index.ts'
import {assert} from 'chai'

describe('options: includeTag', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/options-max-number.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert} from 'chai'
import {sanitizeMaxNumber} from '../src/utilities-options'
import {sanitizeMaxNumber} from '../src/utilities-options.ts'

describe('options: maxNumber', () => {

Expand Down
2 changes: 1 addition & 1 deletion test/options-whitelist.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert} from 'chai'
import {getCssSelector} from '../src'
import {getCssSelector} from '../src/index.ts'

describe('options: whitelist', function () {

Expand Down
2 changes: 1 addition & 1 deletion test/selector-attribute.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {assert} from 'chai'
import getCssSelector from '../src'
import getCssSelector from '../src/index.ts'
import {getAttributeSelectors} from '../src/selector-attribute.ts'

describe('selector - attribute', function () {
Expand Down
2 changes: 1 addition & 1 deletion test/selector-nth-of-type.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {assert} from 'chai'
import {getNthOfTypeSelector} from '../src/selector-nth-of-type.ts'
import {getCssSelector} from '../src'
import {getCssSelector} from '../src/index.ts'
import {constructSelector} from '../src/utilities-selectors.ts'

describe('selector - nth-of-type', function () {
Expand Down
3 changes: 3 additions & 0 deletions tools/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"type": "commonjs"
}
18 changes: 18 additions & 0 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"include": [
"./src/**/*.ts"
],
"compilerOptions": {
"noImplicitAny": true,
"module": "es6",
"target": "es6",
"allowJs": true,
"sourceMap": true,
"moduleResolution": "node",
"lib": [
"ES6",
"DOM",
"DOM.Iterable"
]
}
}
6 changes: 6 additions & 0 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "./tsconfig.base.json",
"compilerOptions": {
"outDir": "./esm"
}
}
14 changes: 1 addition & 13 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,3 @@
{
"compilerOptions": {
"noImplicitAny": true,
"module": "es6",
"target": "es6",
"allowJs": true,
"sourceMap": true,
"moduleResolution": "node",
"lib": [
"ES6",
"DOM",
"DOM.Iterable"
]
}
"extends": "./tsconfig.base.json"
}

0 comments on commit e34bdc5

Please sign in to comment.