diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index f9054ff..7dd0fed 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -32,3 +32,25 @@ jobs: - run: npm run release ${{ github.ref_name }} env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + release: + needs: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 20 + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm run build + - uses: actions/create-release@v1 + with: + draft: false + prerelease: false + release_name: ${{ steps.version.outputs.version }} + tag_name: ${{ github.ref }} + asset_path: ./cdn/doom-reactive-state.global.js + asset_name: doom-reactive-state.global.js + asset_content_type: application/javascript + env: + GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file diff --git a/.gitignore b/.gitignore index 8686ccf..7fdf289 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ dist build .DS_Store .parcel-cache -coverage \ No newline at end of file +coverage +cdn \ No newline at end of file diff --git a/.npmignore b/.npmignore index 886ffbf..109f205 100644 --- a/.npmignore +++ b/.npmignore @@ -4,4 +4,5 @@ dist build .DS_Store .parcel-cache -coverage \ No newline at end of file +coverage +cdn \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index e862f83..7b1b1a9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -519,6 +519,18 @@ "node": ">=6.0.0" } }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz", + "integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==", + "dev": true, + "optional": true, + "peer": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25" + } + }, "node_modules/@jridgewell/sourcemap-codec": { "version": "1.4.15", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz", @@ -1056,6 +1068,14 @@ "node": ">=8" } }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "optional": true, + "peer": true + }, "node_modules/bundle-require": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-4.0.2.tgz", @@ -2679,6 +2699,18 @@ "node": ">=0.10.0" } }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "optional": true, + "peer": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, "node_modules/stackback": { "version": "0.0.2", "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", @@ -2885,6 +2917,34 @@ "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==", "dev": true }, + "node_modules/terser": { + "version": "5.30.0", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.30.0.tgz", + "integrity": "sha512-Y/SblUl5kEyEFzhMAQdsxVHh+utAxd4IuRNJzKywY/4uzSogh3G219jqbDDxYu4MXO9CzY3tSEqmZvW6AoEDJw==", + "dev": true, + "optional": true, + "peer": true, + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "optional": true, + "peer": true + }, "node_modules/test-exclude": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", diff --git a/package.json b/package.json index 2de4df5..85e6b37 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "test": "vitest", "coverage": "vitest --coverage", "dev": "vite", - "build": "rm -rf dist && tsup ./src", + "build": "rm -rf dist && rm -rf cdn && tsup", "release": "npm run build && ./publish.sh $1" }, "author": "Alessio Coser", diff --git a/tsup.config.ts b/tsup.config.ts index 9120685..484b15c 100644 --- a/tsup.config.ts +++ b/tsup.config.ts @@ -1,12 +1,29 @@ -import { defineConfig } from 'tsup' +import { defineConfig } from "tsup"; -export default defineConfig({ - target: 'es2020', - format: ['cjs', 'esm'], - splitting: false, - sourcemap: true, - clean: true, - minify: true, - dts: true, - treeshake: true, -}) \ No newline at end of file +export default defineConfig([ + { + entryPoints: { "index": "src/index.ts" }, + target: "es2020", + format: ["cjs", "esm"], + splitting: false, + sourcemap: true, + clean: true, + minify: true, + dts: true, + treeshake: true, + outDir: "dist", + }, + { + entryPoints: { "doom-reactive-state": "src/index.ts" }, + target: "es2020", + format: ["iife"], + splitting: false, + sourcemap: false, + clean: true, + minify: true, + dts: false, + treeshake: true, + outDir: "cdn", + globalName: "doom", + }, +]);