Skip to content

Virtual whiteboard for sketching hand-drawn like diagrams

build: export only named exports from the package (#5045)

Aakansha Doshi96c87f920ade
diff --git a/src/packages/excalidraw/CHANGELOG.md b/src/packages/excalidraw/CHANGELOG.md
index f782646115..dec98d79ef 100644
--- a/src/packages/excalidraw/CHANGELOG.md
+++ b/src/packages/excalidraw/CHANGELOG.md
@@ -38,6 +38,26 @@ You will need to pass `activeTool.locked` instead of `elementType` from now onwa
You will need to pass `activeTool` instead of `elementType` from now onwards in `appState`
+### Build
+
+- Use only named exports [#5045](https://github.com/excalidraw/excalidraw/pull/5045).
+
+#### BREAKING CHANGE
+
+You will need to import the named export from now onwards to use the component
+
+Using bundler :point_down:
+
+```js
+import { Excalidraw } from "@excalidraw/excalidraw";
+```
+
+In Browser :point_down:
+
+```js
+React.createElement(ExcalidrawLib.Excalidraw, opts);
+```
+
## 0.11.0 (2022-02-17)
## Excalidraw API
diff --git a/src/packages/excalidraw/README_NEXT.md b/src/packages/excalidraw/README_NEXT.md
index 95a4c73e6a..5536787a09 100644
--- a/src/packages/excalidraw/README_NEXT.md
+++ b/src/packages/excalidraw/README_NEXT.md
@@ -48,7 +48,7 @@ If you are using a Web bundler (for instance, Webpack), you can import it as an
```js
import React, { useEffect, useState, useRef } from "react";
-import Excalidraw from "@excalidraw/excalidraw-next";
+import { Excalidraw } from "@excalidraw/excalidraw-next";
import InitialData from "./initialData";
import "./styles.scss";
@@ -328,7 +328,7 @@ const App = () => {
className: "excalidraw-wrapper",
ref: excalidrawWrapperRef,
},
- React.createElement(Excalidraw.default, {
+ React.createElement(ExcalidrawLib.Excalidraw, {
initialData: InitialData,
onChange: (elements, state) =>
console.log("Elements :", elements, "State : ", state),
diff --git a/src/packages/excalidraw/entry.js b/src/packages/excalidraw/entry.js
index 8a0d08d9b8..8915a1255d 100644
--- a/src/packages/excalidraw/entry.js
+++ b/src/packages/excalidraw/entry.js
@@ -2,5 +2,5 @@ import Excalidraw from "./index";
import "../../../public/fonts.css";
-export default Excalidraw;
+export { Excalidraw };
export * from "./index";
diff --git a/src/packages/excalidraw/example/App.js b/src/packages/excalidraw/example/App.js
index cca5706952..55bb9462fd 100644
--- a/src/packages/excalidraw/example/App.js
+++ b/src/packages/excalidraw/example/App.js
@@ -9,9 +9,9 @@ import { MIME_TYPES } from "../../../constants";
// This is so that we use the bundled excalidraw.development.js file instead
// of the actual source code
-const { exportToCanvas, exportToSvg, exportToBlob } = window.Excalidraw;
-const Excalidraw = window.Excalidraw.default;
+const { exportToCanvas, exportToSvg, exportToBlob, Excalidraw } =
+ window.ExcalidrawLib;
const resolvablePromise = () => {
let resolve;
let reject;
diff --git a/src/packages/excalidraw/webpack.dev.config.js b/src/packages/excalidraw/webpack.dev.config.js
index 4f193031f5..fb752e24d6 100644
--- a/src/packages/excalidraw/webpack.dev.config.js
+++ b/src/packages/excalidraw/webpack.dev.config.js
@@ -12,7 +12,7 @@ module.exports = {
},
output: {
path: path.resolve(__dirname, outputDir),
- library: "Excalidraw",
+ library: "ExcalidrawLib",
libraryTarget: "umd",
filename: "[name].js",
chunkFilename: "excalidraw-assets-dev/[name]-[contenthash].js",
diff --git a/src/packages/excalidraw/webpack.prod.config.js b/src/packages/excalidraw/webpack.prod.config.js
index 92ab36f4a6..00c57d83d7 100644
--- a/src/packages/excalidraw/webpack.prod.config.js
+++ b/src/packages/excalidraw/webpack.prod.config.js
@@ -13,7 +13,7 @@ module.exports = {
},
output: {
path: path.resolve(__dirname, "dist"),
- library: "Excalidraw",
+ library: "ExcalidrawLib",
libraryTarget: "umd",
filename: "[name].js",
chunkFilename: "excalidraw-assets/[name]-[contenthash].js",