Skip to content

Commit a9185b7

Browse files
committedAug 10, 2023
add typescript definition
1 parent 531f6fc commit a9185b7

File tree

8 files changed

+1539
-772
lines changed

8 files changed

+1539
-772
lines changed
 

‎package.json

+18-16
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
"packages/*"
1414
],
1515
"scripts": {
16-
"build": "rollup --bundleConfigAsCjs -c --environment BUILD:production",
16+
"build": "rollup --bundleConfigAsCjs -c && tsc",
1717
"dev": "rollup --bundleConfigAsCjs -c -w",
18-
"lint": "eslint packages/**/src/*.js shared/**/*.js *.config.js",
18+
"lint": "pnpify run prettier --check packages/**/src/*.js && eslint packages/**/src/*.js shared/**/*.js *.config.js",
1919
"test": "jest --config jest.config.js",
20-
"test:watch": "jest --config jest.config.js --watch"
20+
"test:watch": "jest --config jest.config.js --watch",
21+
"format": "pnpify run prettier --write packages/**/src/*.js"
2122
},
2223
"author": "Alexey Vasiliev",
2324
"license": "MIT",
@@ -27,23 +28,24 @@
2728
},
2829
"homepage": "https://github.com/le0pard/cable-shared-worker#readme",
2930
"devDependencies": {
30-
"@babel/core": "^7.22.8",
31-
"@babel/eslint-parser": "^7.22.7",
32-
"@babel/preset-env": "^7.22.7",
31+
"@babel/core": "^7.22.10",
32+
"@babel/eslint-parser": "^7.22.10",
33+
"@babel/preset-env": "^7.22.10",
3334
"@rollup/plugin-alias": "^5.0.0",
3435
"@rollup/plugin-babel": "^6.0.3",
35-
"@rollup/plugin-commonjs": "^25.0.2",
36+
"@rollup/plugin-commonjs": "^25.0.3",
3637
"@rollup/plugin-node-resolve": "^15.1.0",
37-
"@rollup/plugin-terser": "^0.4.3",
38-
"eslint": "^8.44.0",
39-
"eslint-config-prettier": "^8.8.0",
40-
"eslint-import-resolver-node": "^0.3.7",
41-
"eslint-plugin-import": "^2.27.5",
42-
"jest": "^29.6.1",
43-
"jest-environment-jsdom": "^29.6.1",
38+
"@yarnpkg/pnpify": "^4.0.0-rc.48",
39+
"eslint": "^8.46.0",
40+
"eslint-config-prettier": "^9.0.0",
41+
"eslint-import-resolver-node": "^0.3.9",
42+
"eslint-plugin-import": "^2.28.0",
43+
"jest": "^29.6.2",
44+
"jest-environment-jsdom": "^29.6.2",
4445
"jsdom": "^22.1.0",
45-
"prettier": "^3.0.0",
46-
"rollup": "^3.26.2"
46+
"prettier": "^3.0.1",
47+
"rollup": "^3.28.0",
48+
"typescript": "^5.1.6"
4749
},
4850
"packageManager": "yarn@3.6.0"
4951
}

‎packages/web/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
# production
22
dist
3-
lib

‎packages/web/package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cable-shared-worker/web",
3-
"version": "0.3.2",
3+
"version": "0.4.0",
44
"description": "ActionCable and AnyCable Shared Worker support",
55
"keywords": [
66
"anycable",
@@ -9,19 +9,20 @@
99
"visibility api"
1010
],
1111
"files": [
12-
"lib/",
12+
"dist/",
1313
"README.md",
1414
"LICENSE"
1515
],
16-
"main": "lib/index.cjs.js",
17-
"module": "lib/index.esm.js",
18-
"unpkg": "lib/index.umd.js",
16+
"main": "dist/index.cjs.js",
17+
"module": "dist/index.esm.js",
18+
"unpkg": "dist/index.umd.js",
1919
"exports": {
2020
".": {
21-
"import": "./lib/index.esm.js",
22-
"require": "./lib/index.cjs.js"
21+
"import": "./dist/index.esm.js",
22+
"require": "./dist/index.cjs.js"
2323
}
2424
},
25+
"types": "dist/index.esm.d.ts",
2526
"author": "Alexey Vasiliev",
2627
"license": "MIT",
2728
"repository": "github:le0pard/cable-shared-worker",

‎packages/worker/.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
# production
22
dist
3-
lib

‎packages/worker/package.json

+8-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cable-shared-worker/worker",
3-
"version": "0.3.2",
3+
"version": "0.4.0",
44
"description": "ActionCable and AnyCable Shared Worker support",
55
"keywords": [
66
"anycable",
@@ -9,19 +9,20 @@
99
"visibility api"
1010
],
1111
"files": [
12-
"lib/",
12+
"dist/",
1313
"README.md",
1414
"LICENSE"
1515
],
16-
"main": "lib/index.cjs.js",
17-
"module": "lib/index.esm.js",
18-
"unpkg": "lib/index.umd.js",
16+
"main": "dist/index.cjs.js",
17+
"module": "dist/index.esm.js",
18+
"unpkg": "dist/index.umd.js",
1919
"exports": {
2020
".": {
21-
"import": "./lib/index.esm.js",
22-
"require": "./lib/index.cjs.js"
21+
"import": "./dist/index.esm.js",
22+
"require": "./dist/index.cjs.js"
2323
}
2424
},
25+
"types": "dist/index.esm.d.ts",
2526
"author": "Alexey Vasiliev",
2627
"license": "MIT",
2728
"repository": "github:le0pard/cable-shared-worker",

‎rollup.config.js

+4-22
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import alias from '@rollup/plugin-alias'
22
import resolve from '@rollup/plugin-node-resolve'
33
import commonjs from '@rollup/plugin-commonjs'
44
import {babel} from '@rollup/plugin-babel'
5-
import terser from '@rollup/plugin-terser'
65
// packages
76
import webPkg from './packages/web/package.json'
87
import workerPkg from './packages/worker/package.json'
@@ -15,9 +14,9 @@ const bannersParams = {
1514
const LIBRARY_NAME = 'CableSW' // Library name
1615
const EXTERNAL = [] // external modules
1716
const GLOBALS = {} // https://rollupjs.org/guide/en/#outputglobals
18-
const OUTPUT_DIR = 'lib'
17+
const OUTPUT_DIR = 'dist'
1918

20-
const makeConfig = (env = 'development') => {
19+
const makeConfig = () => {
2120
const configs = Object.keys(bannersParams).map((name) => {
2221
const banner = `/*!
2322
* ${bannersParams[name].name}
@@ -30,7 +29,7 @@ const makeConfig = (env = 'development') => {
3029
* @license ${bannersParams[name].license}
3130
*/`
3231

33-
let config = {
32+
return {
3433
input: `packages/${name}/src/index.js`,
3534
external: EXTERNAL,
3635
output: [
@@ -72,28 +71,11 @@ const makeConfig = (env = 'development') => {
7271
})
7372
]
7473
}
75-
76-
if (env === 'production') {
77-
config.plugins.push(
78-
terser({
79-
sourceMap: true,
80-
output: {
81-
comments: /^!/
82-
}
83-
})
84-
)
85-
}
86-
87-
return config
8874
})
8975

9076
return configs
9177
}
9278

93-
export default (commandLineArgs) => {
94-
if (commandLineArgs.environment === 'BUILD:production') {
95-
return makeConfig('production')
96-
}
97-
79+
export default () => {
9880
return makeConfig()
9981
}

‎tsconfig.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"include": [
3+
"packages/web/dist/index.esm.js",
4+
"packages/worker/dist/index.esm.js"
5+
],
6+
"compilerOptions": {
7+
"allowJs": true,
8+
// Avoid extra work
9+
"checkJs": false,
10+
// Ensure ".d.ts" modules are generated
11+
"declaration": true,
12+
"declarationMap": true,
13+
// Prevent output to declaration directory
14+
"declarationDir": null,
15+
// Skip ".js" generation
16+
"emitDeclarationOnly": true,
17+
// Single file emission is impossible with this flag set
18+
"isolatedModules": false,
19+
// Generate single file
20+
// `System`, in contrast to `None`, permits the use of `import.meta`
21+
"module": "System",
22+
// Always emit
23+
"noEmit": false,
24+
// Skip code generation when error occurs
25+
"noEmitOnError": true,
26+
// Ignore errors in library type definitions
27+
"skipLibCheck": true,
28+
// Always strip internal exports
29+
"stripInternal": true
30+
}
31+
}

‎yarn.lock

+1,470-718
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.