diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 78915995..27192237 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [18, 20] + node-version: [20] steps: - name: Checkout 🛎️ uses: actions/checkout@v4 diff --git a/package.json b/package.json index f2fc13a8..7bd64b0f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "lerna run build", "build:force": "lerna run build --skip-nx-cache", "clean": "lerna run clean", - "dev": "pnpm run --filter @boxslider/examples dev", + "dev": "pnpm run --filter=examples dev", "format": "prettier --write .", "lint": "prettier --check . && eslint", "prepare": "husky", @@ -59,5 +59,8 @@ "*.{md,html}": [ "prettier --write" ] + }, + "dependencies": { + "@types/node": "20" } } diff --git a/packages/components/build.js b/packages/components/build.js new file mode 100644 index 00000000..87f9b11c --- /dev/null +++ b/packages/components/build.js @@ -0,0 +1,15 @@ +import { join } from 'path' +import build from '../../scripts/build.js' + +const srcDir = join(import.meta.dirname, 'src') +const outDir = join(import.meta.dirname, 'dist') +const entryPoints = [ + 'index.ts', + 'Carousel.ts', + 'Cube.ts', + 'Fade.ts', + 'SliderControls.ts', + 'Tile.ts', +].map((entry) => join(srcDir, entry)) + +await build(entryPoints, outDir) diff --git a/packages/components/manifest.js b/packages/components/manifest.js deleted file mode 100644 index 14ded58f..00000000 --- a/packages/components/manifest.js +++ /dev/null @@ -1,7 +0,0 @@ -export const entries = [ - 'Carousel.ts', - 'Cube.ts', - 'Fade.ts', - 'SliderControls.ts', - 'Tile.ts', -] diff --git a/packages/components/package.json b/packages/components/package.json index d0e71234..9b8f084f 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -20,41 +20,21 @@ "exports": { ".": { "import": "./dist/esm/index.js", - "require": "./dist/cjs/index.cjs", + "require": "./dist/cjs/index.js", "types": "./dist/types/index.d.ts" }, - "./Carousel": { - "import": "./dist/esm/Carousel.js", - "require": "./dist/cjs/Carousel.cjs", - "types": "./dist/types/Carousel.d.ts" + "./*": { + "import": "./dist/esm/*.js", + "require": "./dist/cjs/*.js", + "types": "./dist/types/*.d.ts" }, - "./Cube": { - "import": "./dist/esm/Cube.js", - "require": "./dist/cjs/Cube.cjs", - "types": "./dist/types/Cube.d.ts" - }, - "./Fade": { - "import": "./dist/esm/Fade.js", - "require": "./dist/cjs/Fade.cjs", - "types": "./dist/types/Fade.d.ts" - }, - "./Tile": { - "import": "./dist/esm/Tile.js", - "require": "./dist/cjs/Tile.cjs", - "types": "./dist/types/Tile.d.ts" - }, - "./SliderControls": { - "import": "./dist/esm/SliderControls.js", - "require": "./dist/cjs/SliderControls.cjs", - "types": "./dist/types/SliderControls.d.ts" - }, - "./style/": "./src/style/" + "./style/*": "./src/style/*.css" }, - "main": "./dist/cjs/index.cjs", + "main": "./dist/cjs/index.cs", "types": "./dist/types/index.d.ts", "scripts": { "build": "pnpm run clean && pnpm run build:lib && pnpm run build:types", - "build:lib": "../../scripts/build.js", + "build:lib": "node build.js", "build:types": "tsc --project tsconfig.types.json --emitDeclarationOnly --outDir dist/types", "clean": "rm -rf dist && rm -f LICENSE", "dev": "vite", diff --git a/packages/react/build.js b/packages/react/build.js new file mode 100644 index 00000000..7f59065c --- /dev/null +++ b/packages/react/build.js @@ -0,0 +1,18 @@ +import { join } from 'path' +import build from '../../scripts/build.js' + +const srcDir = join(import.meta.dirname, 'src') +const outDir = join(import.meta.dirname, 'dist') +const entryPoints = [ + 'index.ts', + 'core.ts', + 'Carousel.tsx', + 'Cube.tsx', + 'Fade.tsx', + 'Tile.tsx', +].map((entry) => join(srcDir, entry)) + +await build(entryPoints, outDir, { + bundle: false, + packages: 'external', +}) diff --git a/packages/react/manifest.js b/packages/react/manifest.js deleted file mode 100644 index 0fa24df1..00000000 --- a/packages/react/manifest.js +++ /dev/null @@ -1,3 +0,0 @@ -export const entries = ['Carousel.tsx', 'Cube.tsx', 'Fade.tsx', 'Tile.tsx'] - -export const options = { packages: 'external' } diff --git a/packages/react/package.json b/packages/react/package.json index c87b3add..b5e73c8c 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -19,44 +19,27 @@ "exports": { ".": { "import": "./dist/esm/index.js", - "require": "./dist/cjs/index.cjs", + "require": "./dist/cjs/index.js", "types": "./dist/types/index.d.ts" }, - "./Carousel": { - "import": "./dist/esm/Carousel.js", - "require": "./dist/cjs/Carousel.cjs", - "types": "./dist/types/Carousel.d.ts" - }, - "./Cube": { - "import": "./dist/esm/Cube.js", - "require": "./dist/cjs/Cube.cjs", - "types": "./dist/types/Cube.d.ts" - }, - "./Fade": { - "import": "./dist/esm/Fade.js", - "require": "./dist/cjs/Fade.cjs", - "types": "./dist/types/Fade.d.ts" - }, - "./Tile": { - "import": "./dist/esm/Tile.js", - "require": "./dist/cjs/Tile.cjs", - "types": "./dist/types/Tile.d.ts" + "./*": { + "import": "./dist/esm/*.js", + "require": "./dist/cjs/*.js", + "types": "./dist/types/*.d.ts" } }, - "main": "./dist/cjs/index.cjs", + "main": "./dist/cjs/index.js", "types": "./dist/types/index.d.ts", "scripts": { "build": "pnpm run clean && pnpm run build:lib && pnpm run build:types", - "build:lib": "../../scripts/build.js", + "build:lib": "node build.js", "build:types": "tsc --project tsconfig.types.json --emitDeclarationOnly --outDir dist/types", "clean": "echo 'Cleaning' && rm -rf dist && rm -f LICENSE", "postbuild": "pnpm run types", "prepack": "cp ../../LICENSE ./" }, "dependencies": { - "@boxslider/components": "workspace:*" - }, - "devDependencies": { + "@boxslider/components": "workspace:*", "@boxslider/slider": "workspace:*" }, "peerDependencies": { diff --git a/packages/slider/build.js b/packages/slider/build.js new file mode 100644 index 00000000..ef1fff1d --- /dev/null +++ b/packages/slider/build.js @@ -0,0 +1,15 @@ +import { join } from 'path' +import build from '../../scripts/build.js' + +const srcDir = join(import.meta.dirname, 'src') +const outDir = join(import.meta.dirname, 'dist') +const entryPoints = [ + 'index.ts', + 'box-slider.ts', + 'effects/tile/tile-slider.ts', + 'effects/carousel-slider.ts', + 'effects/cube-slider.ts', + 'effects/fade-slider.ts', +].map((entry) => join(srcDir, entry)) + +await build(entryPoints, outDir) diff --git a/packages/slider/manifest.js b/packages/slider/manifest.js deleted file mode 100644 index 0c11aa7b..00000000 --- a/packages/slider/manifest.js +++ /dev/null @@ -1,7 +0,0 @@ -export const entries = [ - 'box-slider.ts', - 'effects/tile/tile-slider.ts', - 'effects/carousel-slider.ts', - 'effects/cube-slider.ts', - 'effects/fade-slider.ts', -] diff --git a/packages/slider/package.json b/packages/slider/package.json index d19cfb7e..53573b3e 100644 --- a/packages/slider/package.json +++ b/packages/slider/package.json @@ -54,7 +54,7 @@ "build": "pnpm run clean && pnpm run esbuild && pnpm run types", "clean": "rm -rf dist && rm -f LICENSE", "dev": "vite", - "esbuild": "../../scripts/build.js", + "esbuild": "node build.js", "prepack": "cp ../../LICENSE ./", "types": "tsc --project tsconfig.types.json --emitDeclarationOnly --outDir dist/types" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5d501353..990f47fb 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,12 +1,12 @@ lockfileVersion: '6.0' -settings: - autoInstallPeers: true - excludeLinksFromLockfile: false - importers: .: + dependencies: + '@types/node': + specifier: '20' + version: 20.11.30 devDependencies: '@commitlint/cli': specifier: ^19.2.1 @@ -55,7 +55,7 @@ importers: version: 9.1.0(eslint@8.57.0) eslint-config-react-app: specifier: ^7.0.1 - version: 7.0.1(@babel/plugin-syntax-flow@7.24.1)(@babel/plugin-transform-react-jsx@7.23.4)(eslint@8.57.0)(typescript@5.4.3) + version: 7.0.1(eslint@8.57.0)(typescript@5.4.3) eslint-plugin-react: specifier: ^7.34.1 version: 7.34.1(eslint@8.57.0) @@ -112,20 +112,13 @@ importers: version: link:../slider react-github-btn: specifier: ^1.4.0 - version: 1.4.0(react@18.2.0) + version: 1.4.0 packages/react: dependencies: '@boxslider/components': specifier: workspace:* version: link:../components - react: - specifier: '>=16.0.0' - version: 18.2.0 - react-dom: - specifier: '>=16.0.0' - version: 18.2.0(react@18.2.0) - devDependencies: '@boxslider/slider': specifier: workspace:* version: link:../slider @@ -136,10 +129,10 @@ importers: dependencies: lucide-react: specifier: ^0.363.0 - version: 0.363.0(react@18.2.0) + version: 0.363.0 react-syntax-highlighter: specifier: ^15.5.0 - version: 15.5.0(react@18.2.0) + version: 15.5.0 devDependencies: '@types/react-syntax-highlighter': specifier: ^15.5.6 @@ -2907,7 +2900,6 @@ packages: resolution: {integrity: sha512-dHM6ZxwlmuZaRmUPfv1p+KrdD1Dci04FbdEm/9wEMouFqxYoFl5aMkt0VMAUtYRQDyYvD41WJLukhq/ha3YuTw==} dependencies: undici-types: 5.26.5 - dev: true /@types/normalize-package-data@2.4.4: resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} @@ -4974,7 +4966,7 @@ packages: eslint: 8.57.0 dev: true - /eslint-config-react-app@7.0.1(@babel/plugin-syntax-flow@7.24.1)(@babel/plugin-transform-react-jsx@7.23.4)(eslint@8.57.0)(typescript@5.4.3): + /eslint-config-react-app@7.0.1(eslint@8.57.0)(typescript@5.4.3): resolution: {integrity: sha512-K6rNzvkIeHaTd8m/QEh1Zko0KI7BACWkkneSs6s9cKZC/J27X3eZR6Upt1jkmZ/4FK+XUOPPxMEN7+lbUXfSlA==} engines: {node: '>=14.0.0'} peerDependencies: @@ -4992,7 +4984,7 @@ packages: babel-preset-react-app: 10.0.1 confusing-browser-globals: 1.0.11 eslint: 8.57.0 - eslint-plugin-flowtype: 8.0.3(@babel/plugin-syntax-flow@7.24.1)(@babel/plugin-transform-react-jsx@7.23.4)(eslint@8.57.0) + eslint-plugin-flowtype: 8.0.3(eslint@8.57.0) eslint-plugin-import: 2.29.1(@typescript-eslint/parser@5.62.0)(eslint@8.57.0) eslint-plugin-jest: 25.7.0(@typescript-eslint/eslint-plugin@5.62.0)(eslint@8.57.0)(typescript@5.4.3) eslint-plugin-jsx-a11y: 6.8.0(eslint@8.57.0) @@ -5048,7 +5040,7 @@ packages: - supports-color dev: true - /eslint-plugin-flowtype@8.0.3(@babel/plugin-syntax-flow@7.24.1)(@babel/plugin-transform-react-jsx@7.23.4)(eslint@8.57.0): + /eslint-plugin-flowtype@8.0.3(eslint@8.57.0): resolution: {integrity: sha512-dX8l6qUL6O+fYPtpNRideCFSpmWOUVx5QcaGLVqe/vlDiBSe4vYljDWDETwnyFzpl7By/WVIu6rcrniCgH9BqQ==} engines: {node: '>=12.0.0'} peerDependencies: @@ -5056,8 +5048,6 @@ packages: '@babel/plugin-transform-react-jsx': ^7.14.9 eslint: ^8.1.0 dependencies: - '@babel/plugin-syntax-flow': 7.24.1(@babel/core@7.24.3) - '@babel/plugin-transform-react-jsx': 7.23.4(@babel/core@7.24.3) eslint: 8.57.0 lodash: 4.17.21 string-natural-compare: 3.0.1 @@ -6694,6 +6684,7 @@ packages: /js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + dev: true /js-tokens@8.0.3: resolution: {integrity: sha512-UfJMcSJc+SEXEl9lH/VLHSZbThQyLpw1vLO1Lb+j4RWDvG3N2f7yj3PVQA3cmkTBNldJ9eFnM+xEXxHIXrYiJw==} @@ -7183,6 +7174,7 @@ packages: hasBin: true dependencies: js-tokens: 4.0.0 + dev: true /loupe@2.3.7: resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==} @@ -7220,12 +7212,10 @@ packages: engines: {node: '>=12'} dev: true - /lucide-react@0.363.0(react@18.2.0): + /lucide-react@0.363.0: resolution: {integrity: sha512-AlsfPCsXQyQx7wwsIgzcKOL9LwC498LIMAo+c0Es5PkHJa33xwmYAkkSoKoJWWWSYQEStqu58/jT4tL2gi32uQ==} peerDependencies: react: ^16.5.1 || ^17.0.0 || ^18.0.0 - dependencies: - react: 18.2.0 dev: false /lz-string@1.5.0: @@ -8602,14 +8592,14 @@ packages: loose-envify: 1.4.0 react: 18.2.0 scheduler: 0.23.0 + dev: true - /react-github-btn@1.4.0(react@18.2.0): + /react-github-btn@1.4.0: resolution: {integrity: sha512-lV4FYClAfjWnBfv0iNlJUGhamDgIq6TayD0kPZED6VzHWdpcHmPfsYOZ/CFwLfPv4Zp+F4m8QKTj0oy2HjiGXg==} peerDependencies: react: '>=16.3.0' dependencies: github-buttons: 2.27.0 - react: 18.2.0 dev: false /react-is@16.13.1: @@ -8629,7 +8619,7 @@ packages: engines: {node: '>=0.10.0'} dev: true - /react-syntax-highlighter@15.5.0(react@18.2.0): + /react-syntax-highlighter@15.5.0: resolution: {integrity: sha512-+zq2myprEnQmH5yw6Gqc8lD55QHnpKaU8TOcFeC/Lg/MQSs8UknEA0JC4nTZGFAXC2J2Hyj/ijJ7NlabyPi2gg==} peerDependencies: react: '>= 0.14.0' @@ -8638,7 +8628,6 @@ packages: highlight.js: 10.7.3 lowlight: 1.20.0 prismjs: 1.29.0 - react: 18.2.0 refractor: 3.6.0 dev: false @@ -8647,6 +8636,7 @@ packages: engines: {node: '>=0.10.0'} dependencies: loose-envify: 1.4.0 + dev: true /read-cache@1.0.0: resolution: {integrity: sha512-Owdv/Ft7IjOgm/i0xvNDZ1LrRANRfew4b2prF3OWMQLxLfu3bS8FVhCsrSCMK4lR56Y9ya+AThoTpDCTxCmpRA==} @@ -9034,6 +9024,7 @@ packages: resolution: {integrity: sha512-CtuThmgHNg7zIZWAXi3AsyIzA3n4xx7aNyjwC2VJldO2LMVDhFK+63xGqq6CsJH4rTAt6/M+N4GhZiDYPx9eUw==} dependencies: loose-envify: 1.4.0 + dev: true /semver@5.7.2: resolution: {integrity: sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==} @@ -9875,7 +9866,6 @@ packages: /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - dev: true /unicode-canonical-property-names-ecmascript@2.0.0: resolution: {integrity: sha512-yY5PpDlfVIU5+y/BSCxAJRBIS1Zc2dDG3Ujq+sR0U+JjUevW2JhocOF+soROYDSaAezOzOKuyyixhD6mBknSmQ==} @@ -10451,3 +10441,7 @@ packages: resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} engines: {node: '>=12.20'} dev: true + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false diff --git a/scripts/build.js b/scripts/build.js index 2aa4ac48..3bd0aabb 100755 --- a/scripts/build.js +++ b/scripts/build.js @@ -1,40 +1,26 @@ -#!/usr/bin/env node - import { build } from 'esbuild' import { join } from 'path' -const srcDir = join(process.cwd(), 'src') -const distDir = join(process.cwd(), 'dist') - -import(join(process.cwd(), 'manifest.js')) - .then(({ entries, options: packageOptions }) => { - const builds = ['index.ts', ...entries].map((entry) => { - const options = { - entryPoints: [join(srcDir, entry)], - bundle: true, - platform: 'node', - target: 'esnext', - tsconfig: '../../tsconfig.json', - ...packageOptions, - } - - return Promise.all([ - build({ - ...options, - outfile: join(distDir, 'esm', entry.replace(/\.tsx?$/, '.js')), - format: 'esm', - }), - build({ - ...options, - outfile: join(distDir, 'cjs', entry.replace(/\.tsx?$/, '.cjs')), - format: 'cjs', - }), - ]) - }) +export default async function (entryPoints, outdir, options = {}) { + const buildOptions = { + entryPoints, + bundle: true, + platform: 'node', + target: 'esnext', + tsconfig: join(import.meta.dirname, '../tsconfig.json'), + ...options, + } - return Promise.all(builds) - }) - .catch((err) => { - console.error(err) - process.exit(1) - }) + await Promise.all([ + build({ + ...buildOptions, + outdir: join(outdir, 'esm'), + format: 'esm', + }), + build({ + ...buildOptions, + outdir: join(outdir, 'cjs'), + format: 'cjs', + }), + ]) +}