Skip to content

Commit

Permalink
Rollup build
Browse files Browse the repository at this point in the history
  • Loading branch information
platypii committed May 28, 2024
1 parent 6b0a520 commit 8a4152d
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
7 changes: 7 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript"
]
}
2 changes: 2 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"eslint:recommended"
],
"rules": {
"comma-spacing": "error",
"comma-dangle": ["error", "always-multiline"],
"no-multi-spaces": "error",
"no-trailing-spaces": "error",
"no-var": "error",
Expand Down
15 changes: 14 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,31 @@
"type": "module",
"types": "dist/hightable.d.ts",
"scripts": {
"build": "tsc",
"build": "rollup -c",
"coverage": "vitest run --coverage --coverage.include=src",
"demo": "http-server -o",
"lint": "eslint src/**/*.{ts,tsx}",
"test": "vitest run"
},
"devDependencies": {
"@babel/core": "7.24.6",
"@babel/preset-env": "7.24.6",
"@babel/preset-react": "7.24.6",
"@babel/preset-typescript": "7.24.6",
"@rollup/plugin-babel": "6.0.4",
"@rollup/plugin-commonjs": "25.0.8",
"@rollup/plugin-node-resolve": "15.2.3",
"@rollup/plugin-replace": "5.0.5",
"@rollup/plugin-terser": "0.4.4",
"@rollup/plugin-typescript": "11.1.6",
"@types/node": "20.12.12",
"@types/react": "18.3.3",
"@types/react-dom": "18.3.0",
"@typescript-eslint/eslint-plugin": "7.11.0",
"@vitest/coverage-v8": "1.6.0",
"eslint": "8.57.0",
"http-server": "14.1.1",
"tslib": "2.6.2",
"typescript": "5.4.5",
"vitest": "1.6.0"
},
Expand Down
33 changes: 33 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import resolve from '@rollup/plugin-node-resolve'
import babel from '@rollup/plugin-babel'
import commonjs from '@rollup/plugin-commonjs'
import replace from '@rollup/plugin-replace'
import terser from '@rollup/plugin-terser'
import typescript from '@rollup/plugin-typescript'

export default {
input: 'src/hightable.tsx',
output: {
file: 'dist/hightable.min.js',
name: 'HighTable',
globals: {
react: 'React',
'react-dom': 'ReactDOM',
},
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'), // or 'development' based on your build environment
preventAssignment: true,
}),
resolve(),
commonjs(),
typescript(),
babel({
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-typescript'],
babelHelpers: 'bundled',
}),
terser(),
],
// external: ['react', 'react-dom'],
}
5 changes: 3 additions & 2 deletions test/package.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ describe('package.json', () => {
expect(packageJson.license).toBe('MIT')
})
it('should have precise dependency versions', () => {
const { devDependencies } = packageJson
Object.values(devDependencies).forEach(version => {
const { devDependencies, peerDependencies } = packageJson
const allDependencies = { ...devDependencies, ...peerDependencies }
Object.values(allDependencies).forEach(version => {
expect(version).toMatch(/^\d+\.\d+\.\d+$/)
})
})
Expand Down

0 comments on commit 8a4152d

Please sign in to comment.