From d69fc91954ecf86faa5b635ed6cb6383e8a07add Mon Sep 17 00:00:00 2001 From: Ben Papillon Date: Thu, 7 Dec 2023 15:42:06 -0500 Subject: [PATCH] CommonJS --- .github/workflows/main.yml | 16 ++++++++++++---- .github/workflows/merge_request.yml | 16 +++++++++++++--- package.json | 19 ++++++++++++------- 3 files changed, 37 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9290862b..5e4d9ccf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -45,8 +45,8 @@ jobs: - name: Deploy browser build run: | - aws s3 cp --acl=public-read dist/browser.js s3://$S3_BUCKET/js/schematic.js - aws s3 cp --acl=public-read dist/browser.js s3://$S3_BUCKET/js/schematic.${{ steps.package.outputs.version }}.js + aws s3 cp --acl=public-read dist/schematic.browser.js s3://$S3_BUCKET/js/schematic.js + aws s3 cp --acl=public-read dist/schematic.browser.js s3://$S3_BUCKET/js/schematic.${{ steps.package.outputs.version }}.js aws configure set preview.cloudfront true aws cloudfront create-invalidation --distribution-id ${{ env.CDN_DISTRIBUTION_ID }} --paths "/js/schematic.js" "/js/schematic.${{ steps.package.outputs.version }}.js" @@ -68,10 +68,18 @@ jobs: uses: borales/actions-yarn@v4 with: cmd: install - - name: Build + - name: Build CJS uses: borales/actions-yarn@v4 with: - cmd: build:npm + cmd: build:cjs + - name: Build ESM + uses: borales/actions-yarn@v4 + with: + cmd: build:esm + - name: Build types + uses: borales/actions-yarn@v4 + with: + cmd: build:types - name: Set up .npmrc run: touch .npmrc && echo "//npm.pkg.github.com/:_authToken=$AUTH_TOKEN" > .npmrc env: diff --git a/.github/workflows/merge_request.yml b/.github/workflows/merge_request.yml index 1335022a..c231e353 100644 --- a/.github/workflows/merge_request.yml +++ b/.github/workflows/merge_request.yml @@ -20,12 +20,22 @@ jobs: with: cmd: install - - name: Browser Build + - name: Build browser bundle uses: borales/actions-yarn@v4 with: cmd: build:browser - - name: NPM Build + - name: Build ESM uses: borales/actions-yarn@v4 with: - cmd: build:npm + cmd: build:esm + + - name: Build CJS + uses: borales/actions-yarn@v4 + with: + cmd: build:cjs + + - name: Build types + uses: borales/actions-yarn@v4 + with: + cmd: build:types diff --git a/package.json b/package.json index f3883ec9..eea52b54 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,8 @@ { + "name": "@schematichq/schematic-js", + "main": "dist/schematic.cjs.js", + "module": "dist/schematic.esm.js", + "browser": "dist/schematic.browser.js", "author": "Ben Papillon ", "dependencies": { "@types/uuid": "^9.0.2", @@ -10,22 +14,23 @@ "typescript": "^5.0.2" }, "files": [ - "dist/schematic.js", + "dist/schematic.cjs.js", + "dist/schematic.esm.js", + "dist/schematic.browser.js", "dist/schematic.d.ts" ], "license": "MIT", - "main": "dist/schematic.js", - "modules": false, - "name": "@schematichq/schematic-js", "publishConfig": { "@schematichq:registry": "https://npm.pkg.github.com" }, "repository": "git@github.com:SchematicHQ/schematic-js.git", "scripts": { - "build:npm": "npx esbuild src/index.ts --bundle --outfile=dist/schematic.js --platform=neutral && npx tsc && npx api-extractor run", - "build:browser": "npx esbuild src/browser.ts --bundle --minify --outfile=dist/browser.js --platform=browser", + "build:browser": "npx esbuild src/browser.ts --bundle --minify --outfile=dist/schematic.browser.js --platform=browser", + "build:cjs": "npx esbuild src/index.ts --bundle --format=cjs --outfile=dist/schematic.cjs.js --platform=neutral", + "build:esm": "npx esbuild src/index.ts --bundle --format=esm --outfile=dist/schematic.esm.js --platform=neutral", + "build:types": "npx tsc && npx api-extractor run", "clean": "rm -rf dist" }, "types": "dist/schematic.d.ts", - "version": "0.0.4" + "version": "0.0.5" }