diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index 2ec3033e..4d58b34d 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -8,19 +8,7 @@ on: pull_request: jobs: - test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions/setup-node@v2 - with: - node-version: '17' - - run: npm install --ignore-scripts - - run: npm run lint - - deploy: - needs: test - if: github.ref == 'refs/heads/master' || 'refs/heads/asyncglk' + test-and-deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -29,6 +17,8 @@ jobs: - uses: actions/setup-node@v2 with: node-version: '17' + - run: npm install --ignore-scripts + - run: npm run lint - name: Get Emglken commit ref id: emglken-ref run: echo "::set-output name=ref::$(git submodule status src/upstream/emglken | cut -c 2-13)" @@ -38,18 +28,18 @@ jobs: with: path: src/upstream/emglken/build key: emglken-${{ steps.emglken-ref.outputs.ref }} - - run: npm install --ignore-scripts - run: npm run link-local-emglken - name: Build AsyncGlk - if: github.ref == 'refs/heads/asyncglk' + if: github.ref == 'refs/heads/testing' run: cd src/upstream/asyncglk && npm install && npx tsc - name: Build Emglken if: steps.cache-emglken.outputs.cache-hit != 'true' run: cd src/upstream/emglken && npm run build - run: npm run gulp - name: Package Parchment for Inform 7 - if: github.ref == 'refs/heads/master' - run: npm run inform7 + run: ./tools/package-inform7.sh + - name: Check browser compatibility + run: ./tools/check-compat.sh - run: cp tools/deploy.gitignore .gitignore - name: Deploy to Pages 🚀 if: github.ref == 'refs/heads/master' @@ -58,7 +48,7 @@ jobs: branch: gh-pages folder: . - name: Deploy to testing site 🚀 - if: github.ref == 'refs/heads/asyncglk' + if: github.ref == 'refs/heads/testing' uses: JamesIves/github-pages-deploy-action@v4 with: branch: gh-pages diff --git a/gulpfile.esm.js b/gulpfile.js similarity index 100% rename from gulpfile.esm.js rename to gulpfile.js diff --git a/package.json b/package.json index 49850786..ccf3dcc1 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "url": "https://github.com/curiousdannii/parchment/issues" }, "homepage": "https://github.com/curiousdannii/parchment#readme", + "type": "module", "dependencies": { "emglken": "^0.3.3", "jquery": "^3.6.0", @@ -22,7 +23,7 @@ "@rollup/plugin-alias": "^3.1.8", "@rollup/stream": "^2.0.0", "eslint": "^8.3.0", - "esm": "^3.2.25", + "eslint-plugin-compat": "^4.0.0", "gulp": "^4.0.2", "gulp-clean-css": "^4.3.0", "gulp-cli": "^2.3.0", @@ -34,6 +35,7 @@ "vinyl-source-stream": "^2.0.0" }, "scripts": { + "check-compat": "tools/check-compat.sh", "gulp": "gulp", "inform7": "tools/package-inform7.sh", "link-local-emglken": "npm link ./src/upstream/emglken", @@ -41,5 +43,11 @@ "prepare": "gulp", "prestart": "gulp", "start": "gulp serve" - } + }, + "browserslist": [ + "> 0.2% and supports es6-module", + "last 2 versions and supports es6-module", + "Firefox ESR", + "not dead" + ] } diff --git a/tools/browser-compat/.eslintrc.cjs b/tools/browser-compat/.eslintrc.cjs new file mode 100644 index 00000000..d3bd054f --- /dev/null +++ b/tools/browser-compat/.eslintrc.cjs @@ -0,0 +1,13 @@ +module.exports = { + extends: 'plugin:compat/recommended', + parserOptions: { + ecmaVersion: 12, + sourceType: 'module', + }, + root: true, + settings: { + polyfills: [ + "WebAssembly.instantiateStreaming", + ] + } +} \ No newline at end of file diff --git a/tools/browser-compat/inform7/package.json b/tools/browser-compat/inform7/package.json new file mode 100644 index 00000000..8430413e --- /dev/null +++ b/tools/browser-compat/inform7/package.json @@ -0,0 +1,7 @@ +{ + "name": "parchment-for-inform7", + "browserslist": [ + "defaults", + "not IE <= 12" + ] +} \ No newline at end of file diff --git a/tools/check-compat.sh b/tools/check-compat.sh new file mode 100755 index 00000000..9762db44 --- /dev/null +++ b/tools/check-compat.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +cd "$(dirname "$0")/.." + +cp -r tools/browser-compat/. dist/ + +cd dist +npx eslint web +cd inform7 +npx eslint . \ No newline at end of file diff --git a/tools/deploy.gitignore b/tools/deploy.gitignore index c6c9fdca..bca980b6 100644 --- a/tools/deploy.gitignore +++ b/tools/deploy.gitignore @@ -1,9 +1,11 @@ -.eslintrc.js +.eslintrc.*js .gitmodules +dist/**/package.json dist/inform7/Parchment* -gulpfile.esm.js +gulpfile.js node_modules package-lock.json src tools/*.sh +tools/browser-compat tools/deploy.gitignore \ No newline at end of file