Prechádzať zdrojové kódy

build: Welcome ESM and Bye Bye UMD (#7441)

* build: Welcome ESM and Bye Bye UMD

* remove package

* create unbundled esm build

* update script for example

* fix typo

* dummy commit

* update autorelease script to build esm

* revert dummy commit

* move react, react-dom and testing library to dev dependencies

* remove entry.js, publicPath and yarn install:deps script

* fix

* upgrade esbuild to fix glob import error for locales

* remove webpack chunk names as thats not needed anymore

* marking the code sideeffects free

* make the library tree-shakeable and move fonts to fonts directory

* allow side effects for css, scss files

* remove tree-shaking

* comment code for tree shaking

* move to vite for example

* bye bye webpack

* ignore ts

* separate build and output dir

* use esbuild for creating bundle for example

* update output dir

* lint

* create browser dev build with source maps and prod with minification

* add dev and prod builds for bundler

* lint

* update script

* remove await

* load prod build

* create minified build in dist

* prod and dev builds using export field

* remove import.meta

* dummy

* define import.meta prod and dev

* fix

* export types

* add types field

* typo

* lint

* Update scripts/buildPackage.js

* move types inside export

* newline
Aakansha Doshi 1 rok pred
rodič
commit
a8064ba3ee
88 zmenil súbory, kde vykonal 487 pridanie a 853 odobranie
  1. 1 1
      .github/workflows/lint.yml
  2. 1 1
      .github/workflows/size-limit.yml
  3. 1 1
      .github/workflows/test-coverage-pr.yml
  4. 1 1
      .github/workflows/test.yml
  5. 0 3
      .gitignore
  6. 1 1
      excalidraw-app/collab/RoomDialog.scss
  7. 1 1
      excalidraw-app/index.html
  8. 1 3
      excalidraw-app/package.json
  9. 0 1
      package.json
  10. 2 2
      packages/excalidraw/.gitignore
  11. 0 1
      packages/excalidraw/components/App.tsx
  12. 1 1
      packages/excalidraw/components/Avatar.scss
  13. 1 1
      packages/excalidraw/components/Card.scss
  14. 1 1
      packages/excalidraw/components/CheckboxItem.scss
  15. 1 1
      packages/excalidraw/components/ColorPicker/ColorPicker.scss
  16. 1 1
      packages/excalidraw/components/ConfirmDialog.scss
  17. 1 1
      packages/excalidraw/components/ContextMenu.scss
  18. 1 1
      packages/excalidraw/components/Dialog.scss
  19. 1 1
      packages/excalidraw/components/ExportDialog.scss
  20. 1 1
      packages/excalidraw/components/FilledButton.scss
  21. 1 1
      packages/excalidraw/components/FixedSideContainer.scss
  22. 1 1
      packages/excalidraw/components/HelpDialog.scss
  23. 1 1
      packages/excalidraw/components/HintViewer.scss
  24. 1 1
      packages/excalidraw/components/IconPicker.scss
  25. 1 1
      packages/excalidraw/components/ImageExportDialog.scss
  26. 1 1
      packages/excalidraw/components/LayerUI.scss
  27. 1 1
      packages/excalidraw/components/LibraryUnit.scss
  28. 1 1
      packages/excalidraw/components/Modal.scss
  29. 1 1
      packages/excalidraw/components/OverwriteConfirm/OverwriteConfirm.scss
  30. 1 1
      packages/excalidraw/components/PasteChartDialog.scss
  31. 1 1
      packages/excalidraw/components/PublishLibrary.scss
  32. 1 1
      packages/excalidraw/components/RadioGroup.scss
  33. 1 1
      packages/excalidraw/components/ShareableLinkDialog.scss
  34. 1 1
      packages/excalidraw/components/Sidebar/Sidebar.scss
  35. 1 1
      packages/excalidraw/components/Sidebar/SidebarTrigger.scss
  36. 1 1
      packages/excalidraw/components/Stats.scss
  37. 1 1
      packages/excalidraw/components/Switch.scss
  38. 1 1
      packages/excalidraw/components/TTDDialog/TTDDialog.scss
  39. 1 3
      packages/excalidraw/components/TTDDialog/TTDDialog.tsx
  40. 1 1
      packages/excalidraw/components/TextField.scss
  41. 1 1
      packages/excalidraw/components/TextInput.scss
  42. 1 1
      packages/excalidraw/components/Toast.scss
  43. 1 1
      packages/excalidraw/components/ToolIcon.scss
  44. 1 1
      packages/excalidraw/components/Toolbar.scss
  45. 1 1
      packages/excalidraw/components/Tooltip.scss
  46. 1 1
      packages/excalidraw/components/dropdownMenu/DropdownMenu.scss
  47. 1 1
      packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.scss
  48. 1 1
      packages/excalidraw/css/styles.scss
  49. 2 4
      packages/excalidraw/data/blob.ts
  50. 1 1
      packages/excalidraw/data/index.ts
  51. 1 1
      packages/excalidraw/element/Hyperlink.scss
  52. 0 7
      packages/excalidraw/entry.js
  53. 0 0
      packages/excalidraw/env.cjs
  54. 4 5
      packages/excalidraw/example/App.tsx
  55. 2 3
      packages/excalidraw/example/CustomFooter.tsx
  56. 1 1
      packages/excalidraw/example/MobileFooter.tsx
  57. 4 3
      packages/excalidraw/example/index.tsx
  58. 2 2
      packages/excalidraw/example/initialData.tsx
  59. 7 4
      packages/excalidraw/example/public/index.html
  60. 4 2
      packages/excalidraw/example/sidebar/ExampleSidebar.tsx
  61. 1 3
      packages/excalidraw/i18n.ts
  62. 4 0
      packages/excalidraw/index.tsx
  63. 3 9
      packages/excalidraw/main.js
  64. 30 20
      packages/excalidraw/package.json
  65. 0 8
      packages/excalidraw/publicPath.js
  66. 1 1
      packages/excalidraw/scene/export.ts
  67. 0 1
      packages/excalidraw/tests/flip.test.tsx
  68. 1 1
      packages/excalidraw/tests/shortcuts.test.tsx
  69. 15 0
      packages/excalidraw/tsconfig.json
  70. 15 0
      packages/excalidraw/vite.config.mts
  71. 0 28
      packages/excalidraw/webpack.dev-server.config.js
  72. 0 108
      packages/excalidraw/webpack.dev.config.js
  73. 0 32
      packages/excalidraw/webpack.preact.config.js
  74. 0 131
      packages/excalidraw/webpack.prod.config.js
  75. 0 0
      public/fonts/Assistant-Bold.woff2
  76. 0 0
      public/fonts/Assistant-Medium.woff2
  77. 0 0
      public/fonts/Assistant-Regular.woff2
  78. 0 0
      public/fonts/Assistant-SemiBold.woff2
  79. 0 0
      public/fonts/Cascadia.ttf
  80. 0 0
      public/fonts/Cascadia.woff2
  81. 0 0
      public/fonts/FG_Virgil.ttf
  82. 0 0
      public/fonts/FG_Virgil.woff2
  83. 0 0
      public/fonts/Virgil.woff2
  84. 0 0
      public/fonts/fonts.css
  85. 5 3
      scripts/autorelease.js
  86. 35 0
      scripts/buildExample.mjs
  87. 135 0
      scripts/buildPackage.js
  88. 168 420
      yarn.lock

+ 1 - 1
.github/workflows/lint.yml

@@ -16,7 +16,7 @@ jobs:
 
       - name: Install and lint
         run: |
-          yarn install:deps
+          yarn install
           yarn test:other
           yarn test:code
           yarn test:typecheck

+ 1 - 1
.github/workflows/size-limit.yml

@@ -23,6 +23,6 @@ jobs:
       - uses: andresz1/size-limit-action@v1
         with:
           github_token: ${{ secrets.GITHUB_TOKEN }}
-          build_script: build:umd
+          build_script: build:esm
           skip_step: install
           directory: packages/excalidraw

+ 1 - 1
.github/workflows/test-coverage-pr.yml

@@ -16,7 +16,7 @@ jobs:
         with:
           node-version: "18.x"
       - name: "Install Deps"
-        run: yarn install:deps
+        run: yarn install
       - name: "Test Coverage"
         run: yarn test:coverage
       - name: "Report Coverage"

+ 1 - 1
.github/workflows/test.yml

@@ -13,5 +13,5 @@ jobs:
           node-version: 18.x
       - name: Install and test
         run: |
-          yarn install:deps
+          yarn install
           yarn test:app

+ 0 - 3
.gitignore

@@ -22,9 +22,6 @@ package-lock.json
 yarn-debug.log*
 yarn-error.log*
 packages/excalidraw/types
-packages/excalidraw/example/public/bundle.js
-packages/excalidraw/example/public/excalidraw-assets-dev
-packages/excalidraw/example/public/excalidraw.development.js
 coverage
 dev-dist
 html

+ 1 - 1
excalidraw-app/collab/RoomDialog.scss

@@ -1,4 +1,4 @@
-@import "../../packages/excalidraw/css/variables.module";
+@import "../../packages/excalidraw/css/variables.module.scss";
 
 .excalidraw {
   .RoomDialog {

+ 1 - 1
excalidraw-app/index.html

@@ -121,7 +121,7 @@
       crossorigin="anonymous"
     />
 
-    <link rel="stylesheet" href="/fonts.css" type="text/css" />
+    <link rel="stylesheet" href="/fonts/fonts.css" type="text/css" />
     <% if ("%VITE_APP_DEV_DISABLE_LIVE_RELOAD%"==="true" ) { %>
     <script>
       {

+ 1 - 3
excalidraw-app/package.json

@@ -21,9 +21,7 @@
   "engines": {
     "node": ">=18.0.0"
   },
-  "dependencies": {
-    "packages/excalidraw": "*"
-  },
+  "dependencies": {},
   "homepage": ".",
   "name": "excalidraw-app",
   "prettier": "@excalidraw/prettier-config",

+ 0 - 1
package.json

@@ -65,7 +65,6 @@
     "fix:code": "yarn test:code --fix",
     "fix:other": "yarn prettier --write",
     "fix": "yarn fix:other && yarn fix:code",
-    "install:deps": "yarn install --frozen-lockfile && yarn --frozen-lockfile --cwd ./excalidraw-app",
     "locales-coverage": "node scripts/build-locales-coverage.js",
     "locales-coverage:description": "node scripts/locales-coverage-description.js",
     "prepare": "husky install",

+ 2 - 2
packages/excalidraw/.gitignore

@@ -1,4 +1,4 @@
 node_modules
-dist
-example
 types
+bundle.js
+bundle.css

+ 0 - 1
packages/excalidraw/components/App.tsx

@@ -594,7 +594,6 @@ class App extends React.Component<AppProps, AppState> {
     };
 
     this.id = nanoid();
-
     this.library = new Library(this);
     this.actionManager = new ActionManager(
       this.syncActionResult,

+ 1 - 1
packages/excalidraw/components/Avatar.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .Avatar {

+ 1 - 1
packages/excalidraw/components/Card.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .Card {

+ 1 - 1
packages/excalidraw/components/CheckboxItem.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .Checkbox {

+ 1 - 1
packages/excalidraw/components/ColorPicker/ColorPicker.scss

@@ -1,4 +1,4 @@
-@import "../../css/variables.module";
+@import "../../css/variables.module.scss";
 
 .excalidraw {
   .focus-visible-none {

+ 1 - 1
packages/excalidraw/components/ConfirmDialog.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .confirm-dialog {

+ 1 - 1
packages/excalidraw/components/ContextMenu.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .context-menu {

+ 1 - 1
packages/excalidraw/components/Dialog.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .Dialog {

+ 1 - 1
packages/excalidraw/components/ExportDialog.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .ExportDialog__preview {

+ 1 - 1
packages/excalidraw/components/FilledButton.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .ExcButton {

+ 1 - 1
packages/excalidraw/components/FixedSideContainer.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .FixedSideContainer {

+ 1 - 1
packages/excalidraw/components/HelpDialog.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .HelpDialog {

+ 1 - 1
packages/excalidraw/components/HintViewer.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 // this is loosely based on the longest hint text
 $wide-viewport-width: 1000px;

+ 1 - 1
packages/excalidraw/components/IconPicker.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .picker-container {

+ 1 - 1
packages/excalidraw/components/ImageExportDialog.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   --ImageExportModal-preview-border: #d6d6d6;

+ 1 - 1
packages/excalidraw/components/LayerUI.scss

@@ -1,5 +1,5 @@
 @import "open-color/open-color";
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .layer-ui__wrapper.animate {

+ 1 - 1
packages/excalidraw/components/LibraryUnit.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .library-unit {

+ 1 - 1
packages/excalidraw/components/Modal.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   &.excalidraw-modal-container {

+ 1 - 1
packages/excalidraw/components/OverwriteConfirm/OverwriteConfirm.scss

@@ -1,4 +1,4 @@
-@import "../../css/variables.module";
+@import "../../css/variables.module.scss";
 
 .excalidraw {
   .OverwriteConfirm {

+ 1 - 1
packages/excalidraw/components/PasteChartDialog.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .PasteChartDialog {

+ 1 - 1
packages/excalidraw/components/PublishLibrary.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .publish-library {

+ 1 - 1
packages/excalidraw/components/RadioGroup.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   --RadioGroup-background: var(--island-bg-color);

+ 1 - 1
packages/excalidraw/components/ShareableLinkDialog.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .ShareableLinkDialog {

+ 1 - 1
packages/excalidraw/components/Sidebar/Sidebar.scss

@@ -1,5 +1,5 @@
 @import "open-color/open-color";
-@import "../../css/variables.module";
+@import "../../css/variables.module.scss";
 
 .excalidraw {
   .sidebar {

+ 1 - 1
packages/excalidraw/components/Sidebar/SidebarTrigger.scss

@@ -1,4 +1,4 @@
-@import "../../css/variables.module";
+@import "../../css/variables.module.scss";
 
 .excalidraw {
   .sidebar-trigger {

+ 1 - 1
packages/excalidraw/components/Stats.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .Stats {

+ 1 - 1
packages/excalidraw/components/Switch.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   --Switch-disabled-color: var(--color-border-outline);

+ 1 - 1
packages/excalidraw/components/TTDDialog/TTDDialog.scss

@@ -1,4 +1,4 @@
-@import "../../css/variables.module";
+@import "../../css/variables.module.scss";
 
 $verticalBreakpoint: 861px;
 

+ 1 - 3
packages/excalidraw/components/TTDDialog/TTDDialog.tsx

@@ -207,9 +207,7 @@ export const TTDDialogBase = withInternalFallback(
     const [mermaidToExcalidrawLib, setMermaidToExcalidrawLib] =
       useState<MermaidToExcalidrawLibProps>({
         loaded: false,
-        api: import(
-          /* webpackChunkName:"mermaid-to-excalidraw" */ "@excalidraw/mermaid-to-excalidraw"
-        ),
+        api: import("@excalidraw/mermaid-to-excalidraw"),
       });
 
     useEffect(() => {

+ 1 - 1
packages/excalidraw/components/TextField.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   --ExcTextField--color: var(--color-on-surface);

+ 1 - 1
packages/excalidraw/components/TextInput.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .TextInput {

+ 1 - 1
packages/excalidraw/components/Toast.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .Toast {

+ 1 - 1
packages/excalidraw/components/ToolIcon.scss

@@ -1,5 +1,5 @@
 @import "open-color/open-color.scss";
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .ToolIcon {

+ 1 - 1
packages/excalidraw/components/Toolbar.scss

@@ -1,5 +1,5 @@
 @import "open-color/open-color.scss";
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw {
   .App-toolbar {

+ 1 - 1
packages/excalidraw/components/Tooltip.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 // container in body where the actual tooltip is appended to
 .excalidraw-tooltip {

+ 1 - 1
packages/excalidraw/components/dropdownMenu/DropdownMenu.scss

@@ -1,4 +1,4 @@
-@import "../../css/variables.module";
+@import "../../css/variables.module.scss";
 
 .excalidraw {
   .dropdown-menu {

+ 1 - 1
packages/excalidraw/components/live-collaboration/LiveCollaborationTrigger.scss

@@ -1,4 +1,4 @@
-@import "../../css/variables.module";
+@import "../../css/variables.module.scss";
 
 .excalidraw {
   .collab-button {

+ 1 - 1
packages/excalidraw/css/styles.scss

@@ -1,4 +1,4 @@
-@import "./variables.module";
+@import "./variables.module.scss";
 @import "./theme";
 
 :root {

+ 2 - 4
packages/excalidraw/data/blob.ts

@@ -19,9 +19,7 @@ const parseFileContents = async (blob: Blob | File) => {
 
   if (blob.type === MIME_TYPES.png) {
     try {
-      return await (
-        await import(/* webpackChunkName: "image" */ "./image")
-      ).decodePngMetadata(blob);
+      return await (await import("./image")).decodePngMetadata(blob);
     } catch (error: any) {
       if (error.message === "INVALID") {
         throw new ImageSceneDataError(
@@ -49,7 +47,7 @@ const parseFileContents = async (blob: Blob | File) => {
     if (blob.type === MIME_TYPES.svg) {
       try {
         return await (
-          await import(/* webpackChunkName: "image" */ "./image")
+          await import("./image")
         ).decodeSvgMetadata({
           svg: contents,
         });

+ 1 - 1
packages/excalidraw/data/index.ts

@@ -144,7 +144,7 @@ export const exportCanvas = async (
     let blob = await canvasToBlob(tempCanvas);
     if (appState.exportEmbedScene) {
       blob = await (
-        await import(/* webpackChunkName: "image" */ "./image")
+        await import("./image")
       ).encodePngMetadata({
         blob,
         metadata: serializeAsJSON(elements, appState, files, "local"),

+ 1 - 1
packages/excalidraw/element/Hyperlink.scss

@@ -1,4 +1,4 @@
-@import "../css/variables.module";
+@import "../css/variables.module.scss";
 
 .excalidraw-hyperlinkContainer {
   display: flex;

+ 0 - 7
packages/excalidraw/entry.js

@@ -1,7 +0,0 @@
-import "./publicPath";
-import polyfill from "./polyfill";
-
-import "../../public/fonts.css";
-
-polyfill();
-export * from "./index";

+ 0 - 0
packages/excalidraw/env.js → packages/excalidraw/env.cjs


+ 4 - 5
packages/excalidraw/example/App.tsx

@@ -1,5 +1,3 @@
-import { useEffect, useState, useRef, useCallback } from "react";
-
 import ExampleSidebar from "./sidebar/ExampleSidebar";
 
 import type * as TExcalidraw from "../index";
@@ -17,7 +15,7 @@ import { EVENT, ROUNDNESS } from "../constants";
 import { distance2d } from "../math";
 import { fileOpen } from "../data/filesystem";
 import { loadSceneOrLibraryFromBlob } from "../../utils";
-import {
+import type {
   AppState,
   BinaryFileData,
   ExcalidrawImperativeAPI,
@@ -26,7 +24,7 @@ import {
   LibraryItems,
   PointerDownState as ExcalidrawPointerDownState,
 } from "../types";
-import { NonDeletedExcalidrawElement, Theme } from "../element/types";
+import type { NonDeletedExcalidrawElement, Theme } from "../element/types";
 import { ImportedLibraryData } from "../data/types";
 import CustomFooter from "./CustomFooter";
 import MobileFooter from "./MobileFooter";
@@ -57,6 +55,8 @@ type PointerDownState = {
   };
 };
 
+const { useEffect, useState, useRef, useCallback } = window.React;
+
 // This is so that we use the bundled excalidraw.development.js file instead
 // of the actual source code
 const {
@@ -89,7 +89,6 @@ export interface AppProps {
   useCustom: (api: ExcalidrawImperativeAPI | null, customArgs?: any[]) => void;
   customArgs?: any[];
 }
-
 export default function App({ appTitle, useCustom, customArgs }: AppProps) {
   const appRef = useRef<any>(null);
   const [viewModeEnabled, setViewModeEnabled] = useState(false);

+ 2 - 3
packages/excalidraw/example/CustomFooter.tsx

@@ -1,7 +1,6 @@
-import { ExcalidrawImperativeAPI } from "../types";
-import { MIME_TYPES } from "../entry";
-import { Button } from "../components/Button";
+import type { ExcalidrawImperativeAPI } from "../types";
 
+const { Button, MIME_TYPES } = window.ExcalidrawLib;
 const COMMENT_SVG = (
   <svg
     xmlns="http://www.w3.org/2000/svg"

+ 1 - 1
packages/excalidraw/example/MobileFooter.tsx

@@ -1,4 +1,4 @@
-import { ExcalidrawImperativeAPI } from "../types";
+import type { ExcalidrawImperativeAPI } from "../types";
 import CustomFooter from "./CustomFooter";
 const { useDevice, Footer } = window.ExcalidrawLib;
 

+ 4 - 3
packages/excalidraw/example/index.tsx

@@ -1,8 +1,9 @@
-import { StrictMode } from "react";
-import { createRoot } from "react-dom/client";
-
 import App from "./App";
 
+const { StrictMode } = window.React;
+//@ts-ignore
+const { createRoot } = window.ReactDOM;
+
 const rootElement = document.getElementById("root")!;
 const root = createRoot(rootElement);
 

+ 2 - 2
packages/excalidraw/example/initialData.tsx

@@ -1,5 +1,5 @@
-import { ExcalidrawElementSkeleton } from "../data/transform";
-import { FileId } from "../element/types";
+import type { ExcalidrawElementSkeleton } from "../data/transform";
+import type { FileId } from "../element/types";
 
 const elements: ExcalidrawElementSkeleton[] = [
   {

+ 7 - 4
packages/excalidraw/example/public/index.html

@@ -12,6 +12,8 @@
     <script>
       window.name = "codesandbox";
     </script>
+    <link rel="stylesheet" href="/dist/browser/dev/index.css" />
+    <link rel="stylesheet" href="bundle.css" />
   </head>
 
   <body>
@@ -19,11 +21,12 @@
     <div id="root"></div>
     <script src="https://unpkg.com/[email protected]/umd/react.development.js"></script>
     <script src="https://unpkg.com/[email protected]/umd/react-dom.development.js"></script>
-
     <!-- This is so that we use the bundled excalidraw.development.js file instead
     of the actual source code -->
-    <script src="./excalidraw.development.js"></script>
-
-    <script src="./bundle.js"></script>
+    <script type="module">
+      import * as ExcalidrawLib from "/dist/browser/dev/index.js";
+      window.ExcalidrawLib = ExcalidrawLib;
+    </script>
+    <script type="module" src="bundle.js"></script>
   </body>
 </html>

+ 4 - 2
packages/excalidraw/example/sidebar/ExampleSidebar.tsx

@@ -1,7 +1,9 @@
-import React, { useState } from "react";
 import "./ExampleSidebar.scss";
+
+const React = window.React;
+
 export default function Sidebar({ children }: { children: React.ReactNode }) {
-  const [open, setOpen] = useState(false);
+  const [open, setOpen] = React.useState(false);
 
   return (
     <>

+ 1 - 3
packages/excalidraw/i18n.ts

@@ -96,9 +96,7 @@ export const setLanguage = async (lang: Language) => {
     currentLangData = {};
   } else {
     try {
-      currentLangData = await import(
-        /* webpackChunkName: "locales/[request]" */ `./locales/${currentLang.code}.json`
-      );
+      currentLangData = await import(`./locales/${currentLang.code}.json`);
     } catch (error: any) {
       console.error(`Failed to load language ${lang.code}:`, error.message);
       currentLangData = fallbackLangData;

+ 4 - 0
packages/excalidraw/index.tsx

@@ -5,6 +5,8 @@ import { isShallowEqual } from "./utils";
 
 import "./css/app.scss";
 import "./css/styles.scss";
+import "../../public/fonts/fonts.css";
+import polyfill from "./polyfill";
 
 import { AppProps, ExcalidrawProps } from "./types";
 import { defaultLang } from "./i18n";
@@ -16,6 +18,8 @@ import MainMenu from "./components/main-menu/MainMenu";
 import WelcomeScreen from "./components/welcome-screen/WelcomeScreen";
 import LiveCollaborationTrigger from "./components/live-collaboration/LiveCollaborationTrigger";
 
+polyfill();
+
 const ExcalidrawBase = (props: ExcalidrawProps) => {
   const {
     onChange,

+ 3 - 9
packages/excalidraw/main.js

@@ -1,11 +1,5 @@
-if (process.env.IS_PREACT === "true") {
-  if (process.env.NODE_ENV === "production") {
-    module.exports = require("./dist/excalidraw-with-preact.production.min.js");
-  } else {
-    module.exports = require("./dist/excalidraw-with-preact.development.js");
-  }
-} else if (process.env.NODE_ENV === "production") {
-  module.exports = require("./dist/excalidraw.production.min.js");
+if (process.env.NODE_ENV !== "development") {
+  import("./dist/dev/index.js");
 } else {
-  module.exports = require("./dist/excalidraw.development.js");
+  import("./dist/prod/index.js");
 }

+ 30 - 20
packages/excalidraw/package.json

@@ -1,11 +1,23 @@
 {
   "name": "@excalidraw/excalidraw",
   "version": "0.17.1",
-  "main": "main.js",
-  "types": "types/excalidraw/index.d.ts",
+  "main": "./dist/prod/index.js",
+  "type": "module",
+  "module": "./dist/prod/index.js",
+  "exports": {
+    ".": {
+      "development": "./dist/dev/index.js",
+      "default": "./dist/prod/index.js",
+      "types": "./dist/excalidraw/index.d.ts"
+    },
+    "./index.css": {
+      "development": "./dist/dev/index.css",
+      "default": "./dist/prod/index.css"
+    }
+  },
+  "types": "./dist/excalidraw/index.d.ts",
   "files": [
-    "dist/*",
-    "types/*"
+    "dist/*"
   ],
   "publishConfig": {
     "access": "public"
@@ -50,15 +62,11 @@
     "@excalidraw/random-username": "1.1.0",
     "@radix-ui/react-popover": "1.0.3",
     "@radix-ui/react-tabs": "1.0.2",
-    "@testing-library/jest-dom": "5.16.2",
-    "@testing-library/react": "12.1.5",
     "@tldraw/vec": "1.7.1",
     "browser-fs-access": "0.29.1",
     "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",
     "image-blob-reduce": "3.0.1",
     "jotai": "1.13.1",
     "lodash.throttle": "4.1.1",
@@ -95,30 +103,32 @@
     "cross-env": "7.0.3",
     "css-loader": "6.7.1",
     "dotenv": "16.0.1",
+    "esbuild": "0.19.10",
+    "esbuild-plugin-external-global": "1.0.1",
+    "esbuild-sass-plugin": "2.16.0",
+    "eslint-plugin-react": "7.32.2",
+    "fake-indexeddb": "3.1.7",
     "import-meta-loader": "1.1.0",
     "mini-css-extract-plugin": "2.6.1",
     "postcss-loader": "7.0.1",
+    "react": "18.2.0",
+    "react-dom": "18.2.0",
     "sass-loader": "13.0.2",
     "size-limit": "9.0.0",
     "style-loader": "3.3.3",
-    "terser-webpack-plugin": "5.3.3",
+    "@testing-library/jest-dom": "5.16.2",
+    "@testing-library/react": "12.1.5",
     "ts-loader": "9.3.1",
-    "typescript": "4.9.4",
-    "webpack": "5.76.0",
-    "webpack-bundle-analyzer": "4.5.0",
-    "webpack-cli": "4.10.0",
-    "webpack-dev-server": "4.9.3",
-    "webpack-merge": "5.8.0"
+    "typescript": "4.9.4"
   },
   "bugs": "https://github.com/excalidraw/excalidraw/issues",
   "homepage": "https://github.com/excalidraw/excalidraw/tree/master/packages/excalidraw",
   "scripts": {
-    "gen:types": "tsc --project tsconfig-types.json",
-    "build:umd": "rm -rf dist && cross-env NODE_ENV=production webpack --config webpack.prod.config.js && cross-env NODE_ENV=development webpack --config webpack.dev.config.js && cross-env NODE_ENV=development webpack --config webpack.preact.config.js && cross-env NODE_ENV=production webpack --config webpack.preact.config.js && yarn gen:types",
-    "build:umd:withAnalyzer": "cross-env NODE_ENV=production ANALYZER=true webpack --config webpack.prod.config.js",
+    "gen:types": "rm -rf types && tsc",
+    "build:esm": "rm -rf dist && node ../../scripts/buildPackage.js && yarn gen:types",
     "pack": "yarn build:umd && yarn pack",
-    "start": "webpack serve --config webpack.dev-server.config.js",
-    "build:example": "EXAMPLE=true webpack --config webpack.dev-server.config.js && yarn gen:types",
+    "start": "node ../../scripts/buildExample.mjs && vite",
+    "build:example": "node ../../scripts/buildExample.mjs",
     "size": "yarn build:umd && size-limit"
   }
 }

+ 0 - 8
packages/excalidraw/publicPath.js

@@ -1,8 +0,0 @@
-import { ENV } from "./constants";
-if (process.env.NODE_ENV !== ENV.TEST) {
-  /* eslint-disable */
-  /* global __webpack_public_path__:writable */
-  __webpack_public_path__ =
-    window.EXCALIDRAW_ASSET_PATH ||
-    `https://unpkg.com/${process.env.VITE_PKG_NAME}@${process.env.VITE_PKG_VERSION}/dist/`;
-}

+ 1 - 1
packages/excalidraw/scene/export.ts

@@ -327,7 +327,7 @@ export const exportToSvg = async (
   if (exportEmbedScene) {
     try {
       metadata = await (
-        await import(/* webpackChunkName: "image" */ "../data/image")
+        await import("../data/image")
       ).encodeSvgMetadata({
         // when embedding scene, we want to embed the origionally supplied
         // elements which don't contain the temp frame labels.

+ 0 - 1
packages/excalidraw/tests/flip.test.tsx

@@ -198,7 +198,6 @@ const checkElementsBoundingBox = async (
 
   const [x12, y12, x22, y22] = getElementAbsoluteCoords(element2);
 
-  debugger;
   await waitFor(() => {
     // Check if width and height did not change
     expect(x2 - x1).toBeCloseTo(x22 - x12, -1);

+ 1 - 1
packages/excalidraw/tests/shortcuts.test.tsx

@@ -1,5 +1,5 @@
 import { KEYS } from "../keys";
-import { Excalidraw } from "../entry";
+import { Excalidraw } from "../index";
 import { API } from "./helpers/api";
 import { Keyboard } from "./helpers/ui";
 import { fireEvent, render, waitFor } from "./test-utils";

+ 15 - 0
packages/excalidraw/tsconfig.json

@@ -0,0 +1,15 @@
+{
+  "exclude": ["**/*.test.*", "tests", "types", "example", "dist"],
+  "compilerOptions": {
+    "target": "ESNext",
+    "strict": true,
+    "outDir": "dist",
+    "skipLibCheck": true,
+    "declaration": true,
+    "allowSyntheticDefaultImports": true,
+    "module": "ESNext",
+    "moduleResolution": "Node",
+    "resolveJsonModule": true,
+    "jsx": "react-jsx"
+  }
+}

+ 15 - 0
packages/excalidraw/vite.config.mts

@@ -0,0 +1,15 @@
+import { defineConfig, loadEnv } from "vite";
+import react from "@vitejs/plugin-react";
+
+// To load .env.local variables
+const envVars = loadEnv("", `../../`);
+// https://vitejs.dev/config/
+export default defineConfig({
+  root: "example/public",
+  server: {
+    port: 3001,
+    // open the browser
+    open: true,
+  },
+  publicDir: "public",
+});

+ 0 - 28
packages/excalidraw/webpack.dev-server.config.js

@@ -1,28 +0,0 @@
-const path = require("path");
-const { merge } = require("webpack-merge");
-
-const devConfig = require("./webpack.dev.config");
-
-const devServerConfig = {
-  entry: {
-    bundle: "./example/index.tsx",
-  },
-  // Server Configuration options
-  devServer: {
-    port: 3001,
-    host: "localhost",
-    hot: true,
-    compress: true,
-    static: {
-      directory: path.join(__dirname, "./example/public"),
-    },
-    client: {
-      progress: true,
-      logging: "info",
-      overlay: true, //Shows a full-screen overlay in the browser when there are compiler errors or warnings.
-    },
-    open: ["./"],
-  },
-};
-
-module.exports = merge(devServerConfig, devConfig);

+ 0 - 108
packages/excalidraw/webpack.dev.config.js

@@ -1,108 +0,0 @@
-const path = require("path");
-const webpack = require("webpack");
-const autoprefixer = require("autoprefixer");
-const { parseEnvVariables } = require("./env");
-const outputDir = process.env.EXAMPLE === "true" ? "example/public" : "dist";
-
-module.exports = {
-  mode: "development",
-  devtool: false,
-  entry: {
-    "excalidraw.development": "./entry.js",
-  },
-  output: {
-    path: path.resolve(__dirname, outputDir),
-    library: "ExcalidrawLib",
-    libraryTarget: "umd",
-    filename: "[name].js",
-    chunkFilename: "excalidraw-assets-dev/[name]-[contenthash].js",
-    assetModuleFilename: "excalidraw-assets-dev/[name][ext]",
-    publicPath: "",
-  },
-  resolve: {
-    extensions: [".js", ".ts", ".tsx", ".css", ".scss"],
-  },
-  module: {
-    rules: [
-      {
-        test: /\.(sa|sc|c)ss$/,
-        exclude: /node_modules/,
-        use: [
-          "style-loader",
-          { loader: "css-loader" },
-          {
-            loader: "postcss-loader",
-            options: {
-              postcssOptions: {
-                plugins: [autoprefixer()],
-              },
-            },
-          },
-          "sass-loader",
-        ],
-      },
-      // So that type module works with webpack
-      // https://github.com/webpack/webpack/issues/11467#issuecomment-691873586
-      {
-        test: /\.m?js/,
-        resolve: {
-          fullySpecified: false,
-        },
-      },
-      {
-        test: /\.(ts|tsx|js|jsx|mjs)$/,
-        exclude:
-          /node_modules[\\/](?!(browser-fs-access|canvas-roundrect-polyfill))/,
-        use: [
-          {
-            loader: "import-meta-loader",
-          },
-          {
-            loader: "ts-loader",
-            options: {
-              transpileOnly: true,
-              configFile: path.resolve(__dirname, "../tsconfig.dev.json"),
-            },
-          },
-        ],
-      },
-      {
-        test: /\.(woff|woff2|eot|ttf|otf)$/,
-        type: "asset/resource",
-      },
-    ],
-  },
-  optimization: {
-    splitChunks: {
-      chunks: "async",
-      cacheGroups: {
-        vendors: {
-          test: /[\\/]node_modules[\\/]/,
-          name: "vendor",
-        },
-      },
-    },
-  },
-  plugins: [
-    new webpack.EvalSourceMapDevToolPlugin({ exclude: /vendor/ }),
-    new webpack.DefinePlugin({
-      "process.env": parseEnvVariables(
-        path.resolve(__dirname, "../../.env.development"),
-      ),
-    }),
-  ],
-  externals: {
-    react: {
-      root: "React",
-      commonjs2: "react",
-      commonjs: "react",
-      amd: "react",
-    },
-    "react-dom": {
-      root: "ReactDOM",
-      commonjs2: "react-dom",
-      commonjs: "react-dom",
-      amd: "react-dom",
-    },
-  },
-};

+ 0 - 32
packages/excalidraw/webpack.preact.config.js

@@ -1,32 +0,0 @@
-const prodConfig = require("./webpack.prod.config");
-const devConfig = require("./webpack.dev.config");
-
-const isProd = process.env.NODE_ENV === "production";
-
-const config = isProd ? prodConfig : devConfig;
-const outputFile = isProd
-  ? "excalidraw-with-preact.production.min"
-  : "excalidraw-with-preact.development";
-
-const preactWebpackConfig = {
-  ...config,
-  entry: {
-    [outputFile]: "./entry.js",
-  },
-  externals: {
-    ...config.externals,
-    "react-dom/client": {
-      root: "ReactDOMClient",
-      commonjs2: "react-dom/client",
-      commonjs: "react-dom/client",
-      amd: "react-dom/client",
-    },
-    "react/jsx-runtime": {
-      root: "ReactJSXRuntime",
-      commonjs2: "react/jsx-runtime",
-      commonjs: "react/jsx-runtime",
-      amd: "react/jsx-runtime",
-    },
-  },
-};
-module.exports = preactWebpackConfig;

+ 0 - 131
packages/excalidraw/webpack.prod.config.js

@@ -1,131 +0,0 @@
-const path = require("path");
-const webpack = require("webpack");
-const autoprefixer = require("autoprefixer");
-const { parseEnvVariables } = require("./env");
-const TerserPlugin = require("terser-webpack-plugin");
-const BundleAnalyzerPlugin =
-  require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
-
-module.exports = {
-  mode: "production",
-  entry: {
-    "excalidraw.production.min": "./entry.js",
-  },
-  output: {
-    path: path.resolve(__dirname, "dist"),
-    library: "ExcalidrawLib",
-    libraryTarget: "umd",
-    filename: "[name].js",
-    chunkFilename: "excalidraw-assets/[name]-[contenthash].js",
-    assetModuleFilename: "excalidraw-assets/[name][ext]",
-    publicPath: "",
-  },
-  resolve: {
-    extensions: [".js", ".ts", ".tsx", ".css", ".scss"],
-  },
-  module: {
-    rules: [
-      {
-        test: /\.(sa|sc|c)ss$/,
-        exclude: /node_modules/,
-        use: [
-          "style-loader",
-          {
-            loader: "css-loader",
-          },
-          {
-            loader: "postcss-loader",
-            options: {
-              postcssOptions: {
-                plugins: [autoprefixer()],
-              },
-            },
-          },
-          "sass-loader",
-        ],
-      },
-      // So that type module works with webpack
-      // https://github.com/webpack/webpack/issues/11467#issuecomment-691873586
-      {
-        test: /\.m?js/,
-        resolve: {
-          fullySpecified: false,
-        },
-      },
-      {
-        test: /\.(ts|tsx|js|jsx|mjs)$/,
-        exclude:
-          /node_modules[\\/](?!(browser-fs-access|canvas-roundrect-polyfill))/,
-        use: [
-          {
-            loader: "import-meta-loader",
-          },
-          {
-            loader: "ts-loader",
-            options: {
-              transpileOnly: true,
-              configFile: path.resolve(__dirname, "../tsconfig.prod.json"),
-            },
-          },
-          {
-            loader: "babel-loader",
-            options: {
-              presets: [
-                "@babel/preset-env",
-                ["@babel/preset-react", { runtime: "automatic" }],
-                "@babel/preset-typescript",
-              ],
-              plugins: [
-                "transform-class-properties",
-                "@babel/plugin-transform-runtime",
-              ],
-            },
-          },
-        ],
-      },
-      {
-        test: /\.(woff|woff2|eot|ttf|otf)$/,
-        type: "asset/resource",
-      },
-    ],
-  },
-  optimization: {
-    minimize: true,
-    minimizer: [
-      new TerserPlugin({
-        test: /\.js($|\?)/i,
-      }),
-    ],
-    splitChunks: {
-      chunks: "async",
-      cacheGroups: {
-        vendors: {
-          test: /[\\/]node_modules[\\/]/,
-          name: "vendor",
-        },
-      },
-    },
-  },
-  plugins: [
-    ...(process.env.ANALYZER === "true" ? [new BundleAnalyzerPlugin()] : []),
-    new webpack.DefinePlugin({
-      "process.env": parseEnvVariables(
-        path.resolve(__dirname, "../../.env.production"),
-      ),
-    }),
-  ],
-  externals: {
-    react: {
-      root: "React",
-      commonjs2: "react",
-      commonjs: "react",
-      amd: "react",
-    },
-    "react-dom": {
-      root: "ReactDOM",
-      commonjs2: "react-dom",
-      commonjs: "react-dom",
-      amd: "react-dom",
-    },
-  },
-};

+ 0 - 0
public/Assistant-Bold.woff2 → public/fonts/Assistant-Bold.woff2


+ 0 - 0
public/Assistant-Medium.woff2 → public/fonts/Assistant-Medium.woff2


+ 0 - 0
public/Assistant-Regular.woff2 → public/fonts/Assistant-Regular.woff2


+ 0 - 0
public/Assistant-SemiBold.woff2 → public/fonts/Assistant-SemiBold.woff2


+ 0 - 0
public/Cascadia.ttf → public/fonts/Cascadia.ttf


+ 0 - 0
public/Cascadia.woff2 → public/fonts/Cascadia.woff2


+ 0 - 0
public/FG_Virgil.ttf → public/fonts/FG_Virgil.ttf


+ 0 - 0
public/FG_Virgil.woff2 → public/fonts/FG_Virgil.woff2


+ 0 - 0
public/Virgil.woff2 → public/fonts/Virgil.woff2


+ 0 - 0
public/fonts.css → public/fonts/fonts.css


+ 5 - 3
scripts/autorelease.js

@@ -16,8 +16,7 @@ const publish = () => {
 
   try {
     execSync(`yarn  --frozen-lockfile`);
-    execSync(`yarn --frozen-lockfile`, { cwd: excalidrawDir });
-    execSync(`yarn run build:umd`, { cwd: excalidrawDir });
+    execSync(`yarn run build:esm`, { cwd: excalidrawDir });
     execSync(`yarn --cwd ${excalidrawDir} publish --tag ${tag}`);
     console.info(`Published ${pkg.name}@${tag}🎉`);
     core.setOutput(
@@ -41,7 +40,10 @@ exec(`git diff --name-only HEAD^ HEAD`, async (error, stdout, stderr) => {
   const changedFiles = stdout.trim().split("\n");
 
   const excalidrawPackageFiles = changedFiles.filter((file) => {
-    return file.indexOf("packages/excalidraw") >= 0;
+    return (
+      file.indexOf("packages/excalidraw") >= 0 ||
+      file.indexOf("buildPackage.js") > 0
+    );
   });
   if (!excalidrawPackageFiles.length) {
     console.info("Skipping release as no valid diff found");

+ 35 - 0
scripts/buildExample.mjs

@@ -0,0 +1,35 @@
+import * as esbuild from "esbuild";
+import { sassPlugin } from "esbuild-sass-plugin";
+import { execSync } from "child_process";
+
+const createDevBuild = async () => {
+  return await esbuild.build({
+    entryPoints: ["example/index.tsx"],
+    outfile: "example/public/bundle.js",
+    define: {
+      "import.meta.env": "{}",
+    },
+    bundle: true,
+    format: "esm",
+    plugins: [sassPlugin()],
+    loader: {
+      ".woff2": "dataurl",
+      ".html": "copy",
+    },
+  });
+};
+
+const startServer = async (ctx) => {
+  await ctx.serve({
+    servedir: "example/public",
+    port: 5001,
+  });
+};
+execSync(
+  `rm -rf example/public/dist && yarn build:esm && cp -r dist example/public`,
+);
+
+const ctx = await createDevBuild();
+
+// await startServer(ctx);
+// console.info("Hosted at port http://localhost:5001!!");

+ 135 - 0
scripts/buildPackage.js

@@ -0,0 +1,135 @@
+const { build } = require("esbuild");
+const { sassPlugin } = require("esbuild-sass-plugin");
+const { externalGlobalPlugin } = require("esbuild-plugin-external-global");
+// Will be used later for treeshaking
+//const fs = require("fs");
+// const path = require("path");
+
+// function getFiles(dir, files = []) {
+//   const fileList = fs.readdirSync(dir);
+//   for (const file of fileList) {
+//     const name = `${dir}/${file}`;
+//     if (
+//       name.includes("node_modules") ||
+//       name.includes("config") ||
+//       name.includes("package.json") ||
+//       name.includes("main.js") ||
+//       name.includes("index-node.ts") ||
+//       name.endsWith(".d.ts")
+//     ) {
+//       continue;
+//     }
+
+//     if (fs.statSync(name).isDirectory()) {
+//       getFiles(name, files);
+//     } else if (
+//       !(
+//         name.match(/\.(sa|sc|c)ss$/) ||
+//         name.match(/\.(woff|woff2|eot|ttf|otf)$/) ||
+//         name.match(/locales\/[^/]+\.json$/)
+//       )
+//     ) {
+//       continue;
+//     } else {
+//       files.push(name);
+//     }
+//   }
+//   return files;
+// }
+
+const browserConfig = {
+  entryPoints: ["index.tsx"],
+  bundle: true,
+  format: "esm",
+  plugins: [
+    sassPlugin(),
+    externalGlobalPlugin({
+      react: "React",
+      "react-dom": "ReactDOM",
+    }),
+  ],
+  splitting: true,
+  loader: {
+    ".woff2": "copy",
+    ".ttf": "copy",
+  },
+};
+const createESMBrowserBuild = async () => {
+  // Development unminified build with source maps
+  await build({
+    ...browserConfig,
+    outdir: "dist/browser/dev",
+    sourcemap: true,
+    chunkNames: "excalidraw-assets-dev/[name]-[hash]",
+    define: {
+      "import.meta.env": JSON.stringify({ DEV: true }),
+    },
+  });
+
+  // production minified build without sourcemaps
+  await build({
+    ...browserConfig,
+    outdir: "dist/browser/prod",
+    minify: true,
+    chunkNames: "excalidraw-assets/[name]-[hash]",
+    define: {
+      "import.meta.env": JSON.stringify({ PROD: true }),
+    },
+  });
+};
+
+// const BASE_PATH = `${path.resolve(`${__dirname}/..`)}`;
+// const filesinExcalidrawPackage = [
+//   ...getFiles(`${BASE_PATH}/packages/excalidraw`),
+//   `${BASE_PATH}/packages/utils/export.ts`,
+//   `${BASE_PATH}/packages/utils/bbox.ts`,
+//   ...getFiles(`${BASE_PATH}/public/fonts`),
+// ];
+
+// const filesToTransform = filesinExcalidrawPackage.filter((file) => {
+//   return !(
+//     file.includes("/__tests__/") ||
+//     file.includes(".test.") ||
+//     file.includes("/tests/") ||
+//     file.includes("example")
+//   );
+// });
+
+const rawConfig = {
+  entryPoints: ["index.tsx"],
+  bundle: true,
+  format: "esm",
+  plugins: [sassPlugin()],
+
+  loader: {
+    ".woff2": "copy",
+    ".ttf": "copy",
+    ".json": "copy",
+  },
+  packages: "external",
+};
+
+const createESMRawBuild = async () => {
+  // Development unminified build with source maps
+  await build({
+    ...rawConfig,
+    sourcemap: true,
+    outdir: "dist/dev",
+    define: {
+      "import.meta.env": JSON.stringify({ DEV: true }),
+    },
+  });
+
+  // production minified build without sourcemaps
+  await build({
+    ...rawConfig,
+    minify: true,
+    outdir: "dist/prod",
+    define: {
+      "import.meta.env": JSON.stringify({ PROD: true }),
+    },
+  });
+};
+
+createESMRawBuild();
+createESMBrowserBuild();

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 168 - 420
yarn.lock


Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov