From 8104068bd5b9142f12a2d480f5d6998f49582764 Mon Sep 17 00:00:00 2001 From: Aakansha Doshi Date: Wed, 26 Jul 2023 22:34:06 +0530 Subject: [PATCH] =?UTF-8?q?revert:=20"build:=20Migrate=20to=20Vite=20?= =?UTF-8?q?=F0=9F=9A=80"=20(#6814)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Revert "build: Migrate to Vite 🚀 (#6713)" This reverts commit e93bbc577613a6de6bb43c40c3b57286b4994ca5. --- .env.development | 22 +- .env.production | 16 +- .github/workflows/autorelease-excalidraw.yml | 4 +- .github/workflows/autorelease-preview.yml | 4 +- .github/workflows/lint.yml | 4 +- .github/workflows/locales-coverage.yml | 4 +- .github/workflows/sentry-production.yml | 4 +- .github/workflows/test.yml | 4 +- .gitignore | 2 - package.json | 65 +- index.html => public/index.html | 24 +- .../workbox/workbox-background-sync.prod.js | 2 + .../workbox/workbox-broadcast-update.prod.js | 2 + .../workbox-cacheable-response.prod.js | 2 + public/workbox/workbox-core.prod.js | 2 + public/workbox/workbox-expiration.prod.js | 2 + .../workbox-navigation-preload.prod.js | 2 + public/workbox/workbox-offline-ga.prod.js | 2 + public/workbox/workbox-precaching.prod.js | 2 + public/workbox/workbox-range-requests.prod.js | 2 + public/workbox/workbox-routing.prod.js | 2 + public/workbox/workbox-strategies.prod.js | 2 + public/workbox/workbox-streams.prod.js | 2 + public/workbox/workbox-sw.js | 2 + public/workbox/workbox-window.prod.es5.mjs | 2 + public/workbox/workbox-window.prod.mjs | 2 + public/workbox/workbox-window.prod.umd.js | 2 + src/analytics.ts | 2 +- src/charts.ts | 5 +- src/components/App.test.tsx | 3 +- src/components/App.tsx | 13 +- src/components/LibraryMenuBrowseButton.tsx | 2 +- src/components/PublishLibrary.tsx | 2 +- src/components/Sidebar/Sidebar.test.tsx | 3 +- src/components/Sidebar/Sidebar.tsx | 2 +- .../__snapshots__/App.test.tsx.snap | 4 +- src/element/newElement.ts | 2 +- src/element/sizeHelpers.test.ts | 18 +- src/element/textWysiwyg.test.tsx | 24 +- src/excalidraw-app/collab/Collab.tsx | 10 +- .../components/AppWelcomeScreen.tsx | 4 +- .../components/ExcalidrawPlusAppLink.tsx | 4 +- src/excalidraw-app/data/firebase.ts | 6 +- src/excalidraw-app/data/index.ts | 10 +- src/excalidraw-app/pwa.ts | 31 + src/excalidraw-app/sentry.ts | 4 +- src/global.d.ts | 10 + src/i18n.ts | 5 +- src/index.tsx | 3 +- src/packages/excalidraw/env.js | 6 +- src/packages/excalidraw/package.json | 1 - src/packages/excalidraw/publicPath.js | 2 +- src/packages/excalidraw/webpack.dev.config.js | 3 - .../excalidraw/webpack.prod.config.js | 3 - src/packages/excalidraw/yarn.lock | 5 - src/renderer/renderElement.ts | 2 +- src/scene/export.ts | 7 +- src/service-worker.ts | 147 + src/serviceWorkerRegistration.ts | 162 + src/setupTests.ts | 13 +- src/tests/MobileMenu.test.tsx | 11 +- .../__snapshots__/MobileMenu.test.tsx.snap | 4 +- src/tests/__snapshots__/charts.test.tsx.snap | 12 +- .../__snapshots__/contextmenu.test.tsx.snap | 2362 +++---- .../__snapshots__/dragCreate.test.tsx.snap | 62 +- src/tests/__snapshots__/export.test.tsx.snap | 4 +- .../linearElementEditor.test.tsx.snap | 6 +- src/tests/__snapshots__/move.test.tsx.snap | 68 +- .../multiPointCreate.test.tsx.snap | 38 +- .../regressionTests.test.tsx.snap | 5436 +++++++-------- .../__snapshots__/selection.test.tsx.snap | 54 +- src/tests/appState.test.tsx | 1 - src/tests/clipboard.test.tsx | 9 +- src/tests/collab.test.tsx | 40 +- src/tests/contextmenu.test.tsx | 3 +- .../data/__snapshots__/restore.test.ts.snap | 114 +- src/tests/data/restore.test.ts | 11 +- src/tests/dragCreate.test.tsx | 3 +- src/tests/fitToContent.test.tsx | 5 +- src/tests/flip.test.tsx | 25 +- src/tests/library.test.tsx | 15 +- src/tests/linearElementEditor.test.tsx | 301 +- src/tests/move.test.tsx | 3 +- src/tests/multiPointCreate.test.tsx | 3 +- .../__snapshots__/excalidraw.test.tsx.snap | 6 +- .../packages/__snapshots__/utils.test.ts.snap | 22 +- src/tests/packages/excalidraw.test.tsx | 10 +- src/tests/packages/utils.test.ts | 30 +- src/tests/regressionTests.test.tsx | 4 +- src/tests/resize.test.tsx | 3 +- .../scene/__snapshots__/export.test.ts.snap | 10 +- src/tests/scene/export.test.ts | 2 +- src/tests/selection.test.tsx | 3 +- src/utils.ts | 4 +- src/vite-env.d.ts | 52 - tsconfig-types.json | 3 +- tsconfig.json | 6 +- vite.config.ts | 163 - vitest.config.ts | 9 - yarn.lock | 6150 +++++++++++++---- 100 files changed, 9758 insertions(+), 6012 deletions(-) rename index.html => public/index.html (91%) create mode 100644 public/workbox/workbox-background-sync.prod.js create mode 100644 public/workbox/workbox-broadcast-update.prod.js create mode 100644 public/workbox/workbox-cacheable-response.prod.js create mode 100644 public/workbox/workbox-core.prod.js create mode 100644 public/workbox/workbox-expiration.prod.js create mode 100644 public/workbox/workbox-navigation-preload.prod.js create mode 100644 public/workbox/workbox-offline-ga.prod.js create mode 100644 public/workbox/workbox-precaching.prod.js create mode 100644 public/workbox/workbox-range-requests.prod.js create mode 100644 public/workbox/workbox-routing.prod.js create mode 100644 public/workbox/workbox-strategies.prod.js create mode 100644 public/workbox/workbox-streams.prod.js create mode 100644 public/workbox/workbox-sw.js create mode 100644 public/workbox/workbox-window.prod.es5.mjs create mode 100644 public/workbox/workbox-window.prod.mjs create mode 100644 public/workbox/workbox-window.prod.umd.js create mode 100644 src/excalidraw-app/pwa.ts create mode 100644 src/service-worker.ts create mode 100644 src/serviceWorkerRegistration.ts delete mode 100644 src/vite-env.d.ts delete mode 100644 vite.config.ts delete mode 100644 vitest.config.ts diff --git a/.env.development b/.env.development index eb640e55..c56b62b3 100644 --- a/.env.development +++ b/.env.development @@ -1,30 +1,30 @@ -VITE_APP_BACKEND_V2_GET_URL=https://json-dev.excalidraw.com/api/v2/ -VITE_APP_BACKEND_V2_POST_URL=https://json-dev.excalidraw.com/api/v2/post/ +REACT_APP_BACKEND_V2_GET_URL=https://json-dev.excalidraw.com/api/v2/ +REACT_APP_BACKEND_V2_POST_URL=https://json-dev.excalidraw.com/api/v2/post/ -VITE_APP_LIBRARY_URL=https://libraries.excalidraw.com -VITE_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries +REACT_APP_LIBRARY_URL=https://libraries.excalidraw.com +REACT_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries # collaboration WebSocket server (https://github.com/excalidraw/excalidraw-room) -VITE_APP_WS_SERVER_URL=http://localhost:3002 +REACT_APP_WS_SERVER_URL=http://localhost:3002 # set this only if using the collaboration workflow we use on excalidraw.com -VITE_APP_PORTAL_URL= +REACT_APP_PORTAL_URL= -VITE_APP_FIREBASE_CONFIG='{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}' +REACT_APP_FIREBASE_CONFIG='{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}' # put these in your .env.local, or make sure you don't commit! # must be lowercase `true` when turned on # # whether to enable Service Workers in development -VITE_APP_DEV_ENABLE_SW= +REACT_APP_DEV_ENABLE_SW= # whether to disable live reload / HMR. Usuaully what you want to do when # debugging Service Workers. -VITE_APP_DEV_DISABLE_LIVE_RELOAD= -VITE_APP_DISABLE_TRACKING=true +REACT_APP_DEV_DISABLE_LIVE_RELOAD= +REACT_APP_DISABLE_TRACKING=true FAST_REFRESH=false #Debug flags # To enable bounding box for text containers -VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX= +REACT_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX= diff --git a/.env.production b/.env.production index e3ece6df..b86aa4bc 100644 --- a/.env.production +++ b/.env.production @@ -1,15 +1,15 @@ REACT_APP_BACKEND_V2_GET_URL=https://json.excalidraw.com/api/v2/ REACT_APP_BACKEND_V2_POST_URL=https://json.excalidraw.com/api/v2/post/ -VITE_APP_LIBRARY_URL=https://libraries.excalidraw.com -VITE_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries +REACT_APP_LIBRARY_URL=https://libraries.excalidraw.com +REACT_APP_LIBRARY_BACKEND=https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries -VITE_APP_PORTAL_URL=https://portal.excalidraw.com +REACT_APP_PORTAL_URL=https://portal.excalidraw.com # Fill to set socket server URL used for collaboration. -# Meant for forks only: excalidraw.com uses custom VITE_APP_PORTAL_URL flow -VITE_APP_WS_SERVER_URL= +# Meant for forks only: excalidraw.com uses custom REACT_APP_PORTAL_URL flow +REACT_APP_WS_SERVER_URL= -VITE_APP_FIREBASE_CONFIG='{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}' +REACT_APP_FIREBASE_CONFIG='{"apiKey":"AIzaSyAd15pYlMci_xIp9ko6wkEsDzAAA0Dn0RU","authDomain":"excalidraw-room-persistence.firebaseapp.com","databaseURL":"https://excalidraw-room-persistence.firebaseio.com","projectId":"excalidraw-room-persistence","storageBucket":"excalidraw-room-persistence.appspot.com","messagingSenderId":"654800341332","appId":"1:654800341332:web:4a692de832b55bd57ce0c1"}' -VITE_APP_PLUS_APP=https://app.excalidraw.com -VITE_APP_DISABLE_TRACKING= +REACT_APP_PLUS_APP=https://app.excalidraw.com +REACT_APP_DISABLE_TRACKING= diff --git a/.github/workflows/autorelease-excalidraw.yml b/.github/workflows/autorelease-excalidraw.yml index 4eaeb11f..ad0a0a7e 100644 --- a/.github/workflows/autorelease-excalidraw.yml +++ b/.github/workflows/autorelease-excalidraw.yml @@ -12,10 +12,10 @@ jobs: - uses: actions/checkout@v2 with: fetch-depth: 2 - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Set up publish access run: | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} diff --git a/.github/workflows/autorelease-preview.yml b/.github/workflows/autorelease-preview.yml index bcd50188..8fe7f40b 100644 --- a/.github/workflows/autorelease-preview.yml +++ b/.github/workflows/autorelease-preview.yml @@ -32,10 +32,10 @@ jobs: with: ref: ${{ steps.sha.outputs.result }} fetch-depth: 2 - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Set up publish access run: | npm config set //registry.npmjs.org/:_authToken ${NPM_TOKEN} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index d42f8f63..77d2ef4d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Install and lint run: | diff --git a/.github/workflows/locales-coverage.yml b/.github/workflows/locales-coverage.yml index 822af06e..924dc9e9 100644 --- a/.github/workflows/locales-coverage.yml +++ b/.github/workflows/locales-coverage.yml @@ -14,10 +14,10 @@ jobs: with: token: ${{ secrets.PUSH_TRANSLATIONS_COVERAGE_PAT }} - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Create report file run: | diff --git a/.github/workflows/sentry-production.yml b/.github/workflows/sentry-production.yml index cea4cf63..6f53f91e 100644 --- a/.github/workflows/sentry-production.yml +++ b/.github/workflows/sentry-production.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Install and build run: | yarn --frozen-lockfile diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5c4584e8..b64ea473 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -7,10 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - name: Setup Node.js 18.x + - name: Setup Node.js 14.x uses: actions/setup-node@v2 with: - node-version: 18.x + node-version: 14.x - name: Install and test run: | yarn --frozen-lockfile diff --git a/.gitignore b/.gitignore index 6e430f4e..e637a8c0 100644 --- a/.gitignore +++ b/.gitignore @@ -26,5 +26,3 @@ src/packages/excalidraw/example/public/bundle.js src/packages/excalidraw/example/public/excalidraw-assets-dev src/packages/excalidraw/example/public/excalidraw.development.js coverage -dev-dist -html diff --git a/package.json b/package.json index 162a8ebb..d1198fa2 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ "canvas-roundrect-polyfill": "0.0.1", "clsx": "1.1.1", "cross-env": "7.0.3", - "eslint-plugin-react": "7.32.2", "fake-indexeddb": "3.1.7", "firebase": "8.3.3", "i18next-browser-languagedetector": "6.1.4", @@ -52,13 +51,26 @@ "pwacompat": "2.0.17", "react": "18.2.0", "react-dom": "18.2.0", + "react-scripts": "5.0.1", "roughjs": "4.5.2", "sass": "1.51.0", "socket.io-client": "2.3.1", - "tunnel-rat": "0.1.2" + "tunnel-rat": "0.1.2", + "workbox-background-sync": "^6.5.4", + "workbox-broadcast-update": "^6.5.4", + "workbox-cacheable-response": "^6.5.4", + "workbox-core": "^6.5.4", + "workbox-expiration": "^6.5.4", + "workbox-google-analytics": "^6.5.4", + "workbox-navigation-preload": "^6.5.4", + "workbox-precaching": "^6.5.4", + "workbox-range-requests": "^6.5.4", + "workbox-routing": "^6.5.4", + "workbox-strategies": "^6.5.4", + "workbox-streams": "^6.5.4" }, "devDependencies": { - "@excalidraw/eslint-config": "1.0.3", + "@excalidraw/eslint-config": "1.0.0", "@excalidraw/prettier-config": "1.0.2", "@types/chai": "4.3.0", "@types/jest": "27.4.0", @@ -69,42 +81,48 @@ "@types/react-dom": "18.0.6", "@types/resize-observer-browser": "0.1.7", "@types/socket.io-client": "1.4.36", - "@vitejs/plugin-react": "3.1.0", - "@vitest/ui": "0.32.2", "chai": "4.3.6", "dotenv": "16.0.1", "eslint-config-prettier": "8.5.0", - "eslint-config-react-app": "7.0.1", "eslint-plugin-prettier": "3.3.1", "http-server": "14.1.1", "husky": "7.0.4", - "jsdom": "22.1.0", + "jest-canvas-mock": "2.4.0", "lint-staged": "12.3.7", "pepjs": "0.5.3", "prettier": "2.6.2", "rewire": "6.0.0", - "typescript": "4.9.4", - "vite": "4.4.2", - "vite-plugin-ejs": "1.6.4", - "vite-plugin-eslint": "1.8.1", - "vite-plugin-pwa": "0.16.4", - "vite-plugin-svgr": "2.4.0", - "vitest": "0.32.2", - "vitest-canvas-mock": "0.3.2" + "typescript": "4.9.4" }, "engines": { - "node": ">=18.0.0" + "node": ">=14.0.0" }, "homepage": ".", + "jest": { + "collectCoverageFrom": [ + "src/**/*.{js,jsx,ts,tsx}" + ], + "coveragePathIgnorePatterns": [ + "/locales", + "/src/packages/excalidraw/dist/", + "/src/packages/excalidraw/types", + "/src/packages/excalidraw/example" + ], + "transformIgnorePatterns": [ + "node_modules/(?!(roughjs|points-on-curve|path-data-parser|points-on-path|browser-fs-access|canvas-roundrect-polyfill)/)" + ], + "resetMocks": false + }, "name": "excalidraw", "prettier": "@excalidraw/prettier-config", "private": true, "scripts": { "build-node": "node ./scripts/build-node.js", - "build:app:docker": "cross-env REACT_APP_DISABLE_SENTRY=true REACT_APP_DISABLE_TRACKING=true vite build", - "build:app": "cross-env REACT_APP_GIT_SHA=$VERCEL_GIT_COMMIT_SHA vite build", + "build:app:docker": "cross-env REACT_APP_DISABLE_SENTRY=true REACT_APP_DISABLE_TRACKING=true react-scripts build", + "build:app": "cross-env REACT_APP_GIT_SHA=$VERCEL_GIT_COMMIT_SHA react-scripts build", "build:version": "node ./scripts/build-version.js", "build": "yarn build:app && yarn build:version", + "eject": "react-scripts eject", "fix:code": "yarn test:code --fix", "fix:other": "yarn prettier --write", "fix": "yarn fix:other && yarn fix:code", @@ -112,20 +130,19 @@ "locales-coverage:description": "node scripts/locales-coverage-description.js", "prepare": "husky install", "prettier": "prettier \"**/*.{css,scss,json,md,html,yml}\" --ignore-path=.eslintignore", - "start": "vite --port 3000", + "start": "react-scripts start", "start:production": "npm run build && npx http-server build -a localhost -p 5001 -o", "test:all": "yarn test:typecheck && yarn test:code && yarn test:other && yarn test:app --watchAll=false", - "test:app": "vitest --config vitest.config.ts", + "test:app": "react-scripts test --passWithNoTests", "test:code": "eslint --max-warnings=0 --ext .js,.ts,.tsx .", + "test:debug": "react-scripts --inspect-brk test --runInBand --no-cache", "test:other": "yarn prettier --list-different", "test:typecheck": "tsc", - "test:update": "yarn test:app --update --watch=false", + "test:update": "yarn test:app --updateSnapshot --watchAll=false", "test": "yarn test:app", - "test:coverage": "vitest --coverage --watchAll", - "test:ui": "yarn test --ui", + "test:coverage": "react-scripts test --passWithNoTests --coverage --watchAll", "autorelease": "node scripts/autorelease.js", "prerelease": "node scripts/prerelease.js", - "build:preview": "yarn build && vite preview --port 5000", "release": "node scripts/release.js" } } diff --git a/index.html b/public/index.html similarity index 91% rename from index.html rename to public/index.html index cbdc7706..5509ded8 100644 --- a/index.html +++ b/public/index.html @@ -78,7 +78,8 @@ } - <% if ("%PROD%" === "true") { %> + + <% if (process.env.NODE_ENV === "production") { %> <% } %> - + - - <% if ("%VITE_APP_DEV_DISABLE_LIVE_RELOAD%"==="true" ) { %> + + + + <% if (process.env.REACT_APP_DEV_DISABLE_LIVE_RELOAD==="true" ) { %> - <% if ("%VITE_APP_DEV_DISABLE_LIVE_RELOAD%" !== 'true') { %> + <% if (process.env.REACT_APP_DISABLE_TRACKING !== 'true') { %>