mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
feat: typescript node next support (#10661)
This commit is contained in:
parent
cc65c2bac2
commit
47cb9e1f76
4
auto/auto.d.ts
vendored
4
auto/auto.d.ts
vendored
@ -1,4 +1,4 @@
|
||||
import {Chart} from '../dist/types';
|
||||
import {Chart} from '../dist/types.js';
|
||||
|
||||
export * from '../dist/types';
|
||||
export * from '../dist/types.js';
|
||||
export default Chart;
|
||||
|
||||
2
helpers/helpers.d.ts
vendored
2
helpers/helpers.d.ts
vendored
@ -1 +1 @@
|
||||
export * from '../dist/helpers/types';
|
||||
export * from '../dist/helpers.js';
|
||||
|
||||
26
package.json
26
package.json
@ -13,9 +13,18 @@
|
||||
"unpkg": "./dist/chart.umd.js",
|
||||
"main": "./dist/chart.js",
|
||||
"exports": {
|
||||
".": "./dist/chart.js",
|
||||
"./auto": "./auto/auto.js",
|
||||
"./helpers": "./helpers/helpers.js"
|
||||
".": {
|
||||
"import": "./dist/chart.js",
|
||||
"types": "./dist/types.d.ts"
|
||||
},
|
||||
"./auto": {
|
||||
"import": "./auto/auto.js",
|
||||
"types": "./auto/auto.d.ts"
|
||||
},
|
||||
"./helpers": {
|
||||
"import": "./helpers/helpers.js",
|
||||
"types": "./helpers/helpers.d.ts"
|
||||
}
|
||||
},
|
||||
"types": "./dist/types.d.ts",
|
||||
"keywords": [
|
||||
@ -36,20 +45,18 @@
|
||||
"files": [
|
||||
"auto/**",
|
||||
"dist/**",
|
||||
"types/**",
|
||||
"helpers/**"
|
||||
],
|
||||
"scripts": {
|
||||
"autobuild": "rollup -c -w",
|
||||
"emitDeclarations": "tsc --emitDeclarationOnly",
|
||||
"build": "rollup -c && npm run emitDeclarations",
|
||||
"build": "tsc --noEmit && rollup -c",
|
||||
"dev": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers chrome --grep",
|
||||
"dev:ff": "karma start ./karma.conf.cjs --auto-watch --no-single-run --browsers firefox --grep",
|
||||
"docs": "pnpm run build && pnpm --filter \"./docs/**\" build",
|
||||
"docs:dev": "pnpm run build && pnpm --filter \"./docs/**\" dev",
|
||||
"lint-js": "eslint \"src/**/*.{js,ts}\" \"test/**/*.js\" \"docs/**/*.js\"",
|
||||
"lint-md": "eslint \"**/*.md\"",
|
||||
"lint-types": "eslint \"types/**/*.ts\" && pnpm run build && node types/tests/autogen.js && tsc -p types/tests/",
|
||||
"lint-types": "eslint \"types/**/*.ts\" && pnpm build && node types/tests/autogen.js && tsc -p types/tests/",
|
||||
"lint": "concurrently \"pnpm:lint-*\"",
|
||||
"test-size": "size-limit",
|
||||
"test": "pnpm lint && pnpm test-ci",
|
||||
@ -100,6 +107,7 @@
|
||||
"pixelmatch": "^5.3.0",
|
||||
"rollup": "^2.77.2",
|
||||
"rollup-plugin-cleanup": "^3.2.1",
|
||||
"rollup-plugin-dts": "^4.2.2",
|
||||
"rollup-plugin-istanbul": "^3.0.0",
|
||||
"rollup-plugin-swc3": "^0.3.0",
|
||||
"rollup-plugin-terser": "^7.0.2",
|
||||
@ -116,7 +124,9 @@
|
||||
"html-entities": "1.4.0"
|
||||
},
|
||||
"peerDependencyRules": {
|
||||
"ignoreMissing": ["chart.js"]
|
||||
"ignoreMissing": [
|
||||
"chart.js"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
49
pnpm-lock.yaml
generated
49
pnpm-lock.yaml
generated
@ -49,6 +49,7 @@ importers:
|
||||
pixelmatch: ^5.3.0
|
||||
rollup: ^2.77.2
|
||||
rollup-plugin-cleanup: ^3.2.1
|
||||
rollup-plugin-dts: ^4.2.2
|
||||
rollup-plugin-istanbul: ^3.0.0
|
||||
rollup-plugin-swc3: ^0.3.0
|
||||
rollup-plugin-terser: ^7.0.2
|
||||
@ -98,6 +99,7 @@ importers:
|
||||
pixelmatch: 5.3.0
|
||||
rollup: 2.77.2
|
||||
rollup-plugin-cleanup: 3.2.1_rollup@2.77.2
|
||||
rollup-plugin-dts: 4.2.2_oo3i3f3qmqiztdz5qgxrrjmd5e
|
||||
rollup-plugin-istanbul: 3.0.0_rollup@2.77.2
|
||||
rollup-plugin-swc3: 0.3.0_niznp7c4dpiumotw6saahmrjuy
|
||||
rollup-plugin-terser: 7.0.2_rollup@2.77.2
|
||||
@ -179,6 +181,28 @@ importers:
|
||||
typescript: 4.7.4
|
||||
web-vitals: 2.1.4
|
||||
|
||||
test/integration/typescript-node:
|
||||
specifiers:
|
||||
chart.js: workspace:*
|
||||
ts-expect: ^1.3.0
|
||||
typescript: ^4.7.4
|
||||
dependencies:
|
||||
chart.js: link:../../..
|
||||
typescript: 4.7.4
|
||||
devDependencies:
|
||||
ts-expect: 1.3.0
|
||||
|
||||
test/integration/typescript-node-next:
|
||||
specifiers:
|
||||
chart.js: workspace:*
|
||||
ts-expect: ^1.3.0
|
||||
typescript: ^4.7.4
|
||||
dependencies:
|
||||
chart.js: link:../../..
|
||||
typescript: 4.7.4
|
||||
devDependencies:
|
||||
ts-expect: 1.3.0
|
||||
|
||||
packages:
|
||||
|
||||
/@ampproject/remapping/2.2.0:
|
||||
@ -10646,6 +10670,13 @@ packages:
|
||||
dependencies:
|
||||
sourcemap-codec: 1.4.8
|
||||
|
||||
/magic-string/0.26.3:
|
||||
resolution: {integrity: sha512-u1Po0NDyFcwdg2nzHT88wSK0+Rih0N1M+Ph1Sp08k8yvFFU3KR72wryS7e1qMPJypt99WB7fIFVCA92mQrMjrg==}
|
||||
engines: {node: '>=12'}
|
||||
dependencies:
|
||||
sourcemap-codec: 1.4.8
|
||||
dev: true
|
||||
|
||||
/make-dir/2.1.0:
|
||||
resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==}
|
||||
engines: {node: '>=6'}
|
||||
@ -13803,6 +13834,20 @@ packages:
|
||||
rollup-pluginutils: 2.8.2
|
||||
dev: true
|
||||
|
||||
/rollup-plugin-dts/4.2.2_oo3i3f3qmqiztdz5qgxrrjmd5e:
|
||||
resolution: {integrity: sha512-A3g6Rogyko/PXeKoUlkjxkP++8UDVpgA7C+Tdl77Xj4fgEaIjPSnxRmR53EzvoYy97VMVwLAOcWJudaVAuxneQ==}
|
||||
engines: {node: '>=v12.22.11'}
|
||||
peerDependencies:
|
||||
rollup: ^2.55
|
||||
typescript: ^4.1
|
||||
dependencies:
|
||||
magic-string: 0.26.3
|
||||
rollup: 2.77.2
|
||||
typescript: 4.7.4
|
||||
optionalDependencies:
|
||||
'@babel/code-frame': 7.18.6
|
||||
dev: true
|
||||
|
||||
/rollup-plugin-istanbul/3.0.0_rollup@2.77.2:
|
||||
resolution: {integrity: sha512-z8kD2A57qTcxgqjbJ8cZBBE/IGYk+iJtE42sCaZjrSe/uBEUq5jJYvQwquJ+Acfko1LMYww4EJfeMJmc0GttpQ==}
|
||||
peerDependencies:
|
||||
@ -15235,6 +15280,10 @@ packages:
|
||||
resolution: {integrity: sha512-c3zayb8/kWWpycWYg87P71E1S1ZL6b6IJxfb5fvsUgsf0S2MVGaDhDXXjDMpdCpfWXqptc+4mXwmiy1ypXqRAA==}
|
||||
dev: false
|
||||
|
||||
/ts-expect/1.3.0:
|
||||
resolution: {integrity: sha512-e4g0EJtAjk64xgnFPD6kTBUtpnMVzDrMb12N1YZV0VvSlhnVT3SGxiYTLdGy8Q5cYHOIC/FAHmZ10eGrAguicQ==}
|
||||
dev: true
|
||||
|
||||
/tsconfig-paths/3.14.1:
|
||||
resolution: {integrity: sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==}
|
||||
dependencies:
|
||||
|
||||
@ -3,6 +3,7 @@ import json from '@rollup/plugin-json';
|
||||
import resolve from '@rollup/plugin-node-resolve';
|
||||
import {swc} from 'rollup-plugin-swc3';
|
||||
import {terser} from 'rollup-plugin-terser';
|
||||
import dts from 'rollup-plugin-dts';
|
||||
import {readFileSync} from 'fs';
|
||||
|
||||
const {version, homepage} = JSON.parse(readFileSync('./package.json'));
|
||||
@ -76,5 +77,22 @@ export default [
|
||||
indent: false,
|
||||
sourcemap: true,
|
||||
},
|
||||
},
|
||||
|
||||
// Types
|
||||
// dist/types.d.ts
|
||||
// dist/helpers.d.ts
|
||||
{
|
||||
input: {
|
||||
'dist/types': 'src/types.ts',
|
||||
'dist/helpers': 'src/helpers/types.ts'
|
||||
},
|
||||
plugins: [dts()],
|
||||
output: {
|
||||
dir: './',
|
||||
chunkFileNames: 'dist/chunks/[name].d.ts',
|
||||
entryFileNames: '[name].d.ts',
|
||||
format: 'es'
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
15
test/integration/typescript-node-next/package.json
Normal file
15
test/integration/typescript-node-next/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "chart.js should work in node next typescript project",
|
||||
"dependencies": {
|
||||
"chart.js": "workspace:*",
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-expect": "^1.3.0"
|
||||
}
|
||||
}
|
||||
9
test/integration/typescript-node-next/src/index.ts
Normal file
9
test/integration/typescript-node-next/src/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any, no-console */
|
||||
import {Chart} from 'chart.js';
|
||||
import AutoChart from 'chart.js/auto';
|
||||
import {debounce} from 'chart.js/helpers';
|
||||
import {TypeOf, expectType} from 'ts-expect';
|
||||
|
||||
expectType<TypeOf<typeof Chart.register, any>>(false);
|
||||
expectType<TypeOf<typeof AutoChart.register, any>>(false);
|
||||
expectType<TypeOf<typeof debounce, any>>(false);
|
||||
10
test/integration/typescript-node-next/tsconfig.json
Normal file
10
test/integration/typescript-node-next/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "NodeNext",
|
||||
"noEmit": true,
|
||||
"lib": ["es2018", "DOM"]
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*.ts",
|
||||
]
|
||||
}
|
||||
15
test/integration/typescript-node/package.json
Normal file
15
test/integration/typescript-node/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"description": "chart.js should work in node typescript project",
|
||||
"dependencies": {
|
||||
"chart.js": "workspace:*",
|
||||
"typescript": "^4.7.4"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tsc"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ts-expect": "^1.3.0"
|
||||
}
|
||||
}
|
||||
9
test/integration/typescript-node/src/index.ts
Normal file
9
test/integration/typescript-node/src/index.ts
Normal file
@ -0,0 +1,9 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any, no-console */
|
||||
import {Chart} from 'chart.js';
|
||||
import AutoChart from 'chart.js/auto';
|
||||
import {debounce} from 'chart.js/helpers';
|
||||
import {TypeOf, expectType} from 'ts-expect';
|
||||
|
||||
expectType<TypeOf<typeof Chart.register, any>>(false);
|
||||
expectType<TypeOf<typeof AutoChart.register, any>>(false);
|
||||
expectType<TypeOf<typeof debounce, any>>(false);
|
||||
10
test/integration/typescript-node/tsconfig.json
Normal file
10
test/integration/typescript-node/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"moduleResolution": "Node",
|
||||
"noEmit": true,
|
||||
"lib": ["es2018", "DOM"]
|
||||
},
|
||||
"include": [
|
||||
"./src/**/*.ts",
|
||||
]
|
||||
}
|
||||
@ -10,7 +10,7 @@ let fd;
|
||||
try {
|
||||
const fn = path.resolve(__dirname, 'autogen_helpers.ts');
|
||||
fd = fs.openSync(fn, 'w+');
|
||||
fs.writeSync(fd, 'import * as helpers from \'../../src/helpers/types\';\n\n');
|
||||
fs.writeSync(fd, 'import * as helpers from \'../../dist/helpers\';\n\n');
|
||||
|
||||
fs.writeSync(fd, 'const testKeys: unknown[] = [];\n');
|
||||
for (const key of Object.keys(helpers)) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user