(
}
/**
- * Roate a point by [angle] degree.
+ * Rotate a point by [angle] degree.
*
* @param point The point to rotate
* @param center The point to rotate around, the center point
diff --git a/packages/math/polygon.ts b/packages/math/src/polygon.ts
similarity index 100%
rename from packages/math/polygon.ts
rename to packages/math/src/polygon.ts
diff --git a/packages/math/range.ts b/packages/math/src/range.ts
similarity index 97%
rename from packages/math/range.ts
rename to packages/math/src/range.ts
index dee3d7edf..1b292344e 100644
--- a/packages/math/range.ts
+++ b/packages/math/src/range.ts
@@ -1,4 +1,4 @@
-import { toBrandedType } from "@excalidraw/excalidraw/utils";
+import { toBrandedType } from "@excalidraw/common";
import type { InclusiveRange } from "./types";
diff --git a/packages/math/rectangle.ts b/packages/math/src/rectangle.ts
similarity index 100%
rename from packages/math/rectangle.ts
rename to packages/math/src/rectangle.ts
diff --git a/packages/math/segment.ts b/packages/math/src/segment.ts
similarity index 100%
rename from packages/math/segment.ts
rename to packages/math/src/segment.ts
diff --git a/packages/math/triangle.ts b/packages/math/src/triangle.ts
similarity index 100%
rename from packages/math/triangle.ts
rename to packages/math/src/triangle.ts
diff --git a/packages/math/types.ts b/packages/math/src/types.ts
similarity index 100%
rename from packages/math/types.ts
rename to packages/math/src/types.ts
diff --git a/packages/math/utils.ts b/packages/math/src/utils.ts
similarity index 100%
rename from packages/math/utils.ts
rename to packages/math/src/utils.ts
diff --git a/packages/math/vector.ts b/packages/math/src/vector.ts
similarity index 100%
rename from packages/math/vector.ts
rename to packages/math/src/vector.ts
diff --git a/packages/math/curve.test.ts b/packages/math/tests/curve.test.ts
similarity index 94%
rename from packages/math/curve.test.ts
rename to packages/math/tests/curve.test.ts
index 8d60a7346..739562096 100644
--- a/packages/math/curve.test.ts
+++ b/packages/math/tests/curve.test.ts
@@ -1,13 +1,13 @@
-import "../utils/test-utils";
+import "@excalidraw/utils/test-utils";
import {
curve,
curveClosestPoint,
curveIntersectLineSegment,
curvePointDistance,
-} from "./curve";
-import { pointFrom } from "./point";
-import { lineSegment } from "./segment";
+} from "../src/curve";
+import { pointFrom } from "../src/point";
+import { lineSegment } from "../src/segment";
describe("Math curve", () => {
describe("line segment intersection", () => {
diff --git a/packages/math/ellipse.test.ts b/packages/math/tests/ellipse.test.ts
similarity index 94%
rename from packages/math/ellipse.test.ts
rename to packages/math/tests/ellipse.test.ts
index bcaab2a5d..4fa0d4e59 100644
--- a/packages/math/ellipse.test.ts
+++ b/packages/math/tests/ellipse.test.ts
@@ -4,12 +4,12 @@ import {
ellipseIncludesPoint,
ellipseTouchesPoint,
ellipseLineIntersectionPoints,
-} from "./ellipse";
-import { line } from "./line";
-import { pointFrom } from "./point";
-import { lineSegment } from "./segment";
+} from "../src/ellipse";
+import { line } from "../src/line";
+import { pointFrom } from "../src/point";
+import { lineSegment } from "../src/segment";
-import type { Ellipse, GlobalPoint } from "./types";
+import type { Ellipse, GlobalPoint } from "../src/types";
describe("point and ellipse", () => {
it("point on ellipse", () => {
diff --git a/packages/math/line.test.ts b/packages/math/tests/line.test.ts
similarity index 88%
rename from packages/math/line.test.ts
rename to packages/math/tests/line.test.ts
index 0e6bb1cc8..c8915a466 100644
--- a/packages/math/line.test.ts
+++ b/packages/math/tests/line.test.ts
@@ -1,5 +1,5 @@
-import { line, linesIntersectAt } from "./line";
-import { pointFrom } from "./point";
+import { line, linesIntersectAt } from "../src/line";
+import { pointFrom } from "../src/point";
describe("line-line intersections", () => {
it("should correctly detect intersection at origin", () => {
diff --git a/packages/math/point.test.ts b/packages/math/tests/point.test.ts
similarity index 84%
rename from packages/math/point.test.ts
rename to packages/math/tests/point.test.ts
index 0ed59ee9a..3f3ee15cd 100644
--- a/packages/math/point.test.ts
+++ b/packages/math/tests/point.test.ts
@@ -1,6 +1,6 @@
-import { pointFrom, pointRotateRads } from "./point";
+import { pointFrom, pointRotateRads } from "../src/point";
-import type { Radians } from "./types";
+import type { Radians } from "../src/types";
describe("rotate", () => {
it("should rotate over (x2, y2) and return the rotated coordinates for (x1, y1)", () => {
diff --git a/packages/math/range.test.ts b/packages/math/tests/range.test.ts
similarity index 99%
rename from packages/math/range.test.ts
rename to packages/math/tests/range.test.ts
index fb4b6a38d..9808f77f4 100644
--- a/packages/math/range.test.ts
+++ b/packages/math/tests/range.test.ts
@@ -1,4 +1,4 @@
-import { rangeInclusive, rangeIntersection, rangesOverlap } from "./range";
+import { rangeInclusive, rangeIntersection, rangesOverlap } from "../src/range";
describe("range overlap", () => {
const range1_4 = rangeInclusive(1, 4);
diff --git a/packages/math/segment.test.ts b/packages/math/tests/segment.test.ts
similarity index 82%
rename from packages/math/segment.test.ts
rename to packages/math/tests/segment.test.ts
index 4237a3c85..6b29bba59 100644
--- a/packages/math/segment.test.ts
+++ b/packages/math/tests/segment.test.ts
@@ -1,5 +1,5 @@
-import { pointFrom } from "./point";
-import { lineSegment, lineSegmentIntersectionPoints } from "./segment";
+import { pointFrom } from "../src/point";
+import { lineSegment, lineSegmentIntersectionPoints } from "../src/segment";
describe("line-segment intersections", () => {
it("should correctly detect intersection", () => {
diff --git a/packages/math/vector.test.ts b/packages/math/tests/vector.test.ts
similarity index 88%
rename from packages/math/vector.test.ts
rename to packages/math/tests/vector.test.ts
index 145c90953..820f60400 100644
--- a/packages/math/vector.test.ts
+++ b/packages/math/tests/vector.test.ts
@@ -1,4 +1,4 @@
-import { isVector } from ".";
+import { isVector } from "../src/vector";
describe("Vector", () => {
test("isVector", () => {
diff --git a/packages/math/tsconfig.json b/packages/math/tsconfig.json
index f61b8d0af..6450145b1 100644
--- a/packages/math/tsconfig.json
+++ b/packages/math/tsconfig.json
@@ -1,24 +1,8 @@
{
+ "extends": "../tsconfig.base.json",
"compilerOptions": {
- "outDir": "./dist/types",
- "target": "ESNext",
- "strict": true,
- "skipLibCheck": true,
- "declaration": true,
- "allowSyntheticDefaultImports": true,
- "module": "ESNext",
- "moduleResolution": "Node",
- "resolveJsonModule": true,
- "jsx": "react-jsx",
- "emitDeclarationOnly": true,
- "paths": {
- "@excalidraw/excalidraw": ["../excalidraw/index.tsx"],
- "@excalidraw/utils": ["../utils/index.ts"],
- "@excalidraw/math": ["../math/index.ts"],
- "@excalidraw/excalidraw/*": ["../excalidraw/*"],
- "@excalidraw/utils/*": ["../utils/*"],
- "@excalidraw/math/*": ["../math/*"]
- }
+ "outDir": "./dist/types"
},
+ "include": ["src/**/*", "global.d.ts"],
"exclude": ["**/*.test.*", "tests", "types", "examples", "dist"]
}
diff --git a/packages/tsconfig.base.json b/packages/tsconfig.base.json
new file mode 100644
index 000000000..b1d145ad8
--- /dev/null
+++ b/packages/tsconfig.base.json
@@ -0,0 +1,26 @@
+{
+ "compilerOptions": {
+ "target": "ESNext",
+ "strict": true,
+ "skipLibCheck": true,
+ "declaration": true,
+ "allowSyntheticDefaultImports": true,
+ "module": "ESNext",
+ "moduleResolution": "Node",
+ "resolveJsonModule": true,
+ "jsx": "react-jsx",
+ "emitDeclarationOnly": true,
+ "paths": {
+ "@excalidraw/common": ["./common/src/index.ts"],
+ "@excalidraw/common/*": ["./common/src/*"],
+ "@excalidraw/element": ["./element/src/index.ts"],
+ "@excalidraw/element/*": ["./element/src/*"],
+ "@excalidraw/excalidraw": ["./excalidraw/index.tsx"],
+ "@excalidraw/excalidraw/*": ["./excalidraw/*"],
+ "@excalidraw/math": ["./math/src/index.ts"],
+ "@excalidraw/math/*": ["./math/src/*"],
+ "@excalidraw/utils": ["./utils/src/index.ts"],
+ "@excalidraw/utils/*": ["./utils/src/*"]
+ }
+ }
+}
diff --git a/packages/utils/package.json b/packages/utils/package.json
index ddda1e7d6..ca3eee23e 100644
--- a/packages/utils/package.json
+++ b/packages/utils/package.json
@@ -2,18 +2,18 @@
"name": "@excalidraw/utils",
"version": "0.1.2",
"type": "module",
- "types": "./dist/types/utils/index.d.ts",
+ "types": "./dist/types/utils/src/index.d.ts",
"main": "./dist/prod/index.js",
"module": "./dist/prod/index.js",
"exports": {
".": {
- "types": "./dist/types/utils/index.d.ts",
+ "types": "./dist/types/utils/src/index.d.ts",
"development": "./dist/dev/index.js",
"production": "./dist/prod/index.js",
"default": "./dist/prod/index.js"
},
"./*": {
- "types": "./../utils/dist/types/utils/*"
+ "types": "./../utils/dist/types/utils/src/*.d.ts"
}
},
"files": [
diff --git a/packages/utils/bbox.ts b/packages/utils/src/bbox.ts
similarity index 96%
rename from packages/utils/bbox.ts
rename to packages/utils/src/bbox.ts
index 61c75a668..a56128156 100644
--- a/packages/utils/bbox.ts
+++ b/packages/utils/src/bbox.ts
@@ -5,7 +5,7 @@ import {
type LocalPoint,
} from "@excalidraw/math";
-import type { Bounds } from "@excalidraw/excalidraw/element/bounds";
+import type { Bounds } from "@excalidraw/element/bounds";
export type LineSegment = [P, P];
diff --git a/packages/utils/collision.ts b/packages/utils/src/collision.ts
similarity index 96%
rename from packages/utils/collision.ts
rename to packages/utils/src/collision.ts
index f90019418..b7c155f66 100644
--- a/packages/utils/collision.ts
+++ b/packages/utils/src/collision.ts
@@ -12,13 +12,9 @@ import {
import type { Curve } from "@excalidraw/math";
-import {
- pointInEllipse,
- pointOnEllipse,
- type GeometricShape,
-} from "./geometry/shape";
+import { pointInEllipse, pointOnEllipse } from "./shape";
-import type { Polycurve, Polyline } from "./geometry/shape";
+import type { Polycurve, Polyline, GeometricShape } from "./shape";
// check if the given point is considered on the given shape's border
export const isPointOnShape = (
diff --git a/packages/utils/export.ts b/packages/utils/src/export.ts
similarity index 98%
rename from packages/utils/export.ts
rename to packages/utils/src/export.ts
index 6de25c62b..4559fe1af 100644
--- a/packages/utils/export.ts
+++ b/packages/utils/src/export.ts
@@ -1,10 +1,10 @@
+import { MIME_TYPES } from "@excalidraw/common";
import { getDefaultAppState } from "@excalidraw/excalidraw/appState";
import {
copyBlobToClipboardAsPng,
copyTextToSystemClipboard,
copyToClipboard,
} from "@excalidraw/excalidraw/clipboard";
-import { MIME_TYPES } from "@excalidraw/excalidraw/constants";
import { encodePngMetadata } from "@excalidraw/excalidraw/data/image";
import { serializeAsJSON } from "@excalidraw/excalidraw/data/json";
import { restore } from "@excalidraw/excalidraw/data/restore";
@@ -17,7 +17,7 @@ import type {
ExcalidrawElement,
ExcalidrawFrameLikeElement,
NonDeleted,
-} from "@excalidraw/excalidraw/element/types";
+} from "@excalidraw/element/types";
import type { AppState, BinaryFiles } from "@excalidraw/excalidraw/types";
export { MIME_TYPES };
diff --git a/packages/utils/index.ts b/packages/utils/src/index.ts
similarity index 52%
rename from packages/utils/index.ts
rename to packages/utils/src/index.ts
index 2a929134e..58830b356 100644
--- a/packages/utils/index.ts
+++ b/packages/utils/src/index.ts
@@ -1,4 +1,4 @@
export * from "./export";
export * from "./withinBounds";
export * from "./bbox";
-export { getCommonBounds } from "@excalidraw/excalidraw/element/bounds";
+export { getCommonBounds } from "@excalidraw/element/bounds";
diff --git a/packages/utils/geometry/shape.ts b/packages/utils/src/shape.ts
similarity index 98%
rename from packages/utils/geometry/shape.ts
rename to packages/utils/src/shape.ts
index ea3cde3f6..b750c232e 100644
--- a/packages/utils/geometry/shape.ts
+++ b/packages/utils/src/shape.ts
@@ -11,9 +11,9 @@
* also included in this file are methods for converting an Excalidraw element or a Drawable from roughjs
* to pure shapes
*/
+import { pointsOnBezierCurves } from "points-on-curve";
-import { getElementAbsoluteCoords } from "@excalidraw/excalidraw/element";
-import { invariant } from "@excalidraw/excalidraw/utils";
+import { invariant } from "@excalidraw/common";
import {
curve,
lineSegment,
@@ -33,7 +33,8 @@ import {
type GlobalPoint,
type LocalPoint,
} from "@excalidraw/math";
-import { pointsOnBezierCurves } from "points-on-curve";
+
+import { getElementAbsoluteCoords } from "@excalidraw/element/bounds";
import type {
ElementsMap,
@@ -50,7 +51,7 @@ import type {
ExcalidrawRectangleElement,
ExcalidrawSelectionElement,
ExcalidrawTextElement,
-} from "@excalidraw/excalidraw/element/types";
+} from "@excalidraw/element/types";
import type { Curve, LineSegment, Polygon, Radians } from "@excalidraw/math";
import type { Drawable, Op } from "roughjs/bin/core";
diff --git a/packages/utils/test-utils.ts b/packages/utils/src/test-utils.ts
similarity index 100%
rename from packages/utils/test-utils.ts
rename to packages/utils/src/test-utils.ts
diff --git a/packages/utils/withinBounds.ts b/packages/utils/src/withinBounds.ts
similarity index 94%
rename from packages/utils/withinBounds.ts
rename to packages/utils/src/withinBounds.ts
index 71bc78969..0e1cf38a6 100644
--- a/packages/utils/withinBounds.ts
+++ b/packages/utils/src/withinBounds.ts
@@ -1,12 +1,12 @@
-import { getElementBounds } from "@excalidraw/excalidraw/element/bounds";
+import { arrayToMap } from "@excalidraw/common";
+import { getElementBounds } from "@excalidraw/element/bounds";
import {
isArrowElement,
isExcalidrawElement,
isFreeDrawElement,
isLinearElement,
isTextElement,
-} from "@excalidraw/excalidraw/element/typeChecks";
-import { arrayToMap } from "@excalidraw/excalidraw/utils";
+} from "@excalidraw/element/typeChecks";
import {
rangeIncludesValue,
pointFrom,
@@ -14,13 +14,13 @@ import {
rangeInclusive,
} from "@excalidraw/math";
-import type { Bounds } from "@excalidraw/excalidraw/element/bounds";
+import type { Bounds } from "@excalidraw/element/bounds";
import type {
ExcalidrawElement,
ExcalidrawFreeDrawElement,
ExcalidrawLinearElement,
NonDeletedExcalidrawElement,
-} from "@excalidraw/excalidraw/element/types";
+} from "@excalidraw/element/types";
import type { LocalPoint } from "@excalidraw/math";
type Element = NonDeletedExcalidrawElement;
diff --git a/packages/utils/__snapshots__/export.test.ts.snap b/packages/utils/tests/__snapshots__/export.test.ts.snap
similarity index 100%
rename from packages/utils/__snapshots__/export.test.ts.snap
rename to packages/utils/tests/__snapshots__/export.test.ts.snap
diff --git a/packages/utils/__snapshots__/utils.test.ts.snap b/packages/utils/tests/__snapshots__/utils.test.ts.snap
similarity index 100%
rename from packages/utils/__snapshots__/utils.test.ts.snap
rename to packages/utils/tests/__snapshots__/utils.test.ts.snap
diff --git a/packages/utils/collision.test.ts b/packages/utils/tests/collision.test.ts
similarity index 96%
rename from packages/utils/collision.test.ts
rename to packages/utils/tests/collision.test.ts
index 24f96e985..35bc28b34 100644
--- a/packages/utils/collision.test.ts
+++ b/packages/utils/tests/collision.test.ts
@@ -9,9 +9,9 @@ import {
import type { Curve, Degrees, GlobalPoint } from "@excalidraw/math";
-import { pointOnCurve, pointOnPolyline } from "./collision";
+import { pointOnCurve, pointOnPolyline } from "../src/collision";
-import type { Polyline } from "./geometry/shape";
+import type { Polyline } from "../src/shape";
describe("point and curve", () => {
const c: Curve = curve(
diff --git a/packages/utils/export.test.ts b/packages/utils/tests/export.test.ts
similarity index 97%
rename from packages/utils/export.test.ts
rename to packages/utils/tests/export.test.ts
index 86bbe80b7..47b9398ab 100644
--- a/packages/utils/export.test.ts
+++ b/packages/utils/tests/export.test.ts
@@ -1,9 +1,9 @@
-import { MIME_TYPES } from "@excalidraw/excalidraw/constants";
+import { MIME_TYPES } from "@excalidraw/common";
import * as mockedSceneExportUtils from "@excalidraw/excalidraw/scene/export";
import { diagramFactory } from "@excalidraw/excalidraw/tests/fixtures/diagramFixture";
import { vi } from "vitest";
-import * as utils from ".";
+import * as utils from "../src";
const exportToSvgSpy = vi.spyOn(mockedSceneExportUtils, "exportToSvg");
diff --git a/packages/utils/geometry/geometry.test.ts b/packages/utils/tests/geometry.test.ts
similarity index 98%
rename from packages/utils/geometry/geometry.test.ts
rename to packages/utils/tests/geometry.test.ts
index 6ddab71b0..8a2f95d3f 100644
--- a/packages/utils/geometry/geometry.test.ts
+++ b/packages/utils/tests/geometry.test.ts
@@ -15,7 +15,7 @@ import type {
Radians,
} from "@excalidraw/math";
-import { pointInEllipse, pointOnEllipse, type Ellipse } from "./shape";
+import { pointInEllipse, pointOnEllipse, type Ellipse } from "../src/shape";
describe("point and line", () => {
// const l: Line = line(point(1, 0), point(1, 2));
diff --git a/packages/utils/utils.unmocked.test.ts b/packages/utils/tests/utils.unmocked.test.ts
similarity index 98%
rename from packages/utils/utils.unmocked.test.ts
rename to packages/utils/tests/utils.unmocked.test.ts
index 417eabda1..b77bc37d1 100644
--- a/packages/utils/utils.unmocked.test.ts
+++ b/packages/utils/tests/utils.unmocked.test.ts
@@ -4,7 +4,7 @@ import { API } from "@excalidraw/excalidraw/tests/helpers/api";
import type { ImportedDataState } from "@excalidraw/excalidraw/data/types";
-import * as utils from "./index";
+import * as utils from "../src";
// NOTE this test file is using the actual API, unmocked. Hence splitting it
// from the other test file, because I couldn't figure out how to test
diff --git a/packages/utils/withinBounds.test.ts b/packages/utils/tests/withinBounds.test.ts
similarity index 98%
rename from packages/utils/withinBounds.test.ts
rename to packages/utils/tests/withinBounds.test.ts
index b07d0bc33..d1af75de8 100644
--- a/packages/utils/withinBounds.test.ts
+++ b/packages/utils/tests/withinBounds.test.ts
@@ -1,12 +1,12 @@
import { API } from "@excalidraw/excalidraw/tests/helpers/api";
-import type { Bounds } from "@excalidraw/excalidraw/element/bounds";
+import type { Bounds } from "@excalidraw/element/bounds";
import {
elementPartiallyOverlapsWithOrContainsBBox,
elementsOverlappingBBox,
isElementInsideBBox,
-} from "./withinBounds";
+} from "../src/withinBounds";
const makeElement = (x: number, y: number, width: number, height: number) =>
API.createElement({
diff --git a/packages/utils/tsconfig.json b/packages/utils/tsconfig.json
index f61b8d0af..6450145b1 100644
--- a/packages/utils/tsconfig.json
+++ b/packages/utils/tsconfig.json
@@ -1,24 +1,8 @@
{
+ "extends": "../tsconfig.base.json",
"compilerOptions": {
- "outDir": "./dist/types",
- "target": "ESNext",
- "strict": true,
- "skipLibCheck": true,
- "declaration": true,
- "allowSyntheticDefaultImports": true,
- "module": "ESNext",
- "moduleResolution": "Node",
- "resolveJsonModule": true,
- "jsx": "react-jsx",
- "emitDeclarationOnly": true,
- "paths": {
- "@excalidraw/excalidraw": ["../excalidraw/index.tsx"],
- "@excalidraw/utils": ["../utils/index.ts"],
- "@excalidraw/math": ["../math/index.ts"],
- "@excalidraw/excalidraw/*": ["../excalidraw/*"],
- "@excalidraw/utils/*": ["../utils/*"],
- "@excalidraw/math/*": ["../math/*"]
- }
+ "outDir": "./dist/types"
},
+ "include": ["src/**/*", "global.d.ts"],
"exclude": ["**/*.test.*", "tests", "types", "examples", "dist"]
}
diff --git a/scripts/buildMath.js b/scripts/buildBase.js
similarity index 77%
rename from scripts/buildMath.js
rename to scripts/buildBase.js
index ba421b48c..336b49823 100644
--- a/scripts/buildMath.js
+++ b/scripts/buildBase.js
@@ -1,27 +1,27 @@
const path = require("path");
const { build } = require("esbuild");
-const { sassPlugin } = require("esbuild-sass-plugin");
// contains all dependencies bundled inside
const getConfig = (outdir) => ({
outdir,
bundle: true,
format: "esm",
- entryPoints: ["index.ts"],
+ entryPoints: ["src/index.ts"],
entryNames: "[name]",
assetNames: "[dir]/[name]",
alias: {
+ "@excalidraw/common": path.resolve(__dirname, "../packages/common/src"),
+ "@excalidraw/element": path.resolve(__dirname, "../packages/element/src"),
"@excalidraw/excalidraw": path.resolve(__dirname, "../packages/excalidraw"),
- "@excalidraw/utils": path.resolve(__dirname, "../packages/utils"),
- "@excalidraw/math": path.resolve(__dirname, "../packages/math"),
+ "@excalidraw/math": path.resolve(__dirname, "../packages/math/src"),
+ "@excalidraw/utils": path.resolve(__dirname, "../packages/utils/src"),
},
});
function buildDev(config) {
return build({
...config,
- plugins: [sassPlugin()],
sourcemap: true,
define: {
"import.meta.env": JSON.stringify({ DEV: true }),
@@ -32,7 +32,6 @@ function buildDev(config) {
function buildProd(config) {
return build({
...config,
- plugins: [sassPlugin()],
minify: true,
define: {
"import.meta.env": JSON.stringify({ PROD: true }),
@@ -42,10 +41,10 @@ function buildProd(config) {
const createESMRawBuild = async () => {
// development unminified build with source maps
- buildDev(getConfig("dist/dev"));
+ await buildDev(getConfig("dist/dev"));
// production minified build without sourcemaps
- buildProd(getConfig("dist/prod"));
+ await buildProd(getConfig("dist/prod"));
};
(async () => {
diff --git a/scripts/buildPackage.js b/scripts/buildPackage.js
index 3dd15eeca..baf20615f 100644
--- a/scripts/buildPackage.js
+++ b/scripts/buildPackage.js
@@ -28,9 +28,11 @@ const getConfig = (outdir) => ({
assetNames: "[dir]/[name]",
chunkNames: "[dir]/[name]-[hash]",
alias: {
+ "@excalidraw/common": path.resolve(__dirname, "../packages/common/src"),
+ "@excalidraw/element": path.resolve(__dirname, "../packages/element/src"),
"@excalidraw/excalidraw": path.resolve(__dirname, "../packages/excalidraw"),
- "@excalidraw/utils": path.resolve(__dirname, "../packages/utils"),
- "@excalidraw/math": path.resolve(__dirname, "../packages/math"),
+ "@excalidraw/math": path.resolve(__dirname, "../packages/math/src"),
+ "@excalidraw/utils": path.resolve(__dirname, "../packages/utils/src"),
},
loader: {
".woff2": "file",
diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js
index b5718f57e..1cf3ffbaa 100644
--- a/scripts/buildUtils.js
+++ b/scripts/buildUtils.js
@@ -10,13 +10,15 @@ const getConfig = (outdir) => ({
outdir,
bundle: true,
format: "esm",
- entryPoints: ["index.ts"],
+ entryPoints: ["src/index.ts"],
entryNames: "[name]",
assetNames: "[dir]/[name]",
alias: {
+ "@excalidraw/common": path.resolve(__dirname, "../packages/common/src"),
+ "@excalidraw/element": path.resolve(__dirname, "../packages/element/src"),
"@excalidraw/excalidraw": path.resolve(__dirname, "../packages/excalidraw"),
- "@excalidraw/utils": path.resolve(__dirname, "../packages/utils"),
- "@excalidraw/math": path.resolve(__dirname, "../packages/math"),
+ "@excalidraw/math": path.resolve(__dirname, "../packages/math/src"),
+ "@excalidraw/utils": path.resolve(__dirname, "../packages/utils/src"),
},
});
@@ -49,10 +51,10 @@ function buildProd(config) {
const createESMRawBuild = async () => {
// development unminified build with source maps
- buildDev(getConfig("dist/dev"));
+ await buildDev(getConfig("dist/dev"));
// production minified build without sourcemaps
- buildProd(getConfig("dist/prod"));
+ await buildProd(getConfig("dist/prod"));
};
(async () => {
diff --git a/tsconfig.json b/tsconfig.json
index 3eded705f..45a29dd61 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -19,12 +19,16 @@
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
+ "@excalidraw/common": ["./packages/common/src/index.ts"],
+ "@excalidraw/common/*": ["./packages/common/src/*"],
"@excalidraw/excalidraw": ["./packages/excalidraw/index.tsx"],
- "@excalidraw/utils": ["./packages/utils/index.ts"],
- "@excalidraw/math": ["./packages/math/index.ts"],
"@excalidraw/excalidraw/*": ["./packages/excalidraw/*"],
- "@excalidraw/utils/*": ["./packages/utils/*"],
- "@excalidraw/math/*": ["./packages/math/*"]
+ "@excalidraw/element": ["./packages/element/src/index.ts"],
+ "@excalidraw/element/*": ["./packages/element/src/*"],
+ "@excalidraw/math": ["./packages/math/src/index.ts"],
+ "@excalidraw/math/*": ["./packages/math/src/*"],
+ "@excalidraw/utils": ["./packages/utils/src/index.ts"],
+ "@excalidraw/utils/*": ["./packages/utils/src/*"]
}
},
"include": ["packages", "excalidraw-app"],
diff --git a/vitest.config.mts b/vitest.config.mts
index f9d7d255e..353f84ccf 100644
--- a/vitest.config.mts
+++ b/vitest.config.mts
@@ -5,6 +5,22 @@ import { defineConfig } from "vitest/config";
export default defineConfig({
resolve: {
alias: [
+ {
+ find: /^@excalidraw\/common$/,
+ replacement: path.resolve(__dirname, "./packages/common/src/index.ts"),
+ },
+ {
+ find: /^@excalidraw\/common\/(.*?)/,
+ replacement: path.resolve(__dirname, "./packages/common/src/$1"),
+ },
+ {
+ find: /^@excalidraw\/element$/,
+ replacement: path.resolve(__dirname, "./packages/element/src/index.ts"),
+ },
+ {
+ find: /^@excalidraw\/element\/(.*?)/,
+ replacement: path.resolve(__dirname, "./packages/element/src/$1"),
+ },
{
find: /^@excalidraw\/excalidraw$/,
replacement: path.resolve(__dirname, "./packages/excalidraw/index.tsx"),
@@ -13,21 +29,21 @@ export default defineConfig({
find: /^@excalidraw\/excalidraw\/(.*?)/,
replacement: path.resolve(__dirname, "./packages/excalidraw/$1"),
},
- {
- find: /^@excalidraw\/utils$/,
- replacement: path.resolve(__dirname, "./packages/utils/index.ts"),
- },
- {
- find: /^@excalidraw\/utils\/(.*?)/,
- replacement: path.resolve(__dirname, "./packages/utils/$1"),
- },
{
find: /^@excalidraw\/math$/,
- replacement: path.resolve(__dirname, "./packages/math/index.ts"),
+ replacement: path.resolve(__dirname, "./packages/math/src/index.ts"),
},
{
find: /^@excalidraw\/math\/(.*?)/,
- replacement: path.resolve(__dirname, "./packages/math/$1"),
+ replacement: path.resolve(__dirname, "./packages/math/src/$1"),
+ },
+ {
+ find: /^@excalidraw\/utils$/,
+ replacement: path.resolve(__dirname, "./packages/utils/src/index.ts"),
+ },
+ {
+ find: /^@excalidraw\/utils\/(.*?)/,
+ replacement: path.resolve(__dirname, "./packages/utils/src/$1"),
},
],
},