Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server Error in AFFiNE when upgrading to 0.3.0-alpha.8 #304

Closed
himself65 opened this issue Dec 14, 2022 · 5 comments
Closed

Server Error in AFFiNE when upgrading to 0.3.0-alpha.8 #304

himself65 opened this issue Dec 14, 2022 · 5 comments
Labels
mod:infra Environment related issues and discussions type:bug Something isn't working

Comments

@himself65
Copy link
Contributor

himself65 commented Dec 14, 2022

Server Error
SyntaxError: Named export 'Text' not found. The requested module '@blocksuite/store' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@blocksuite/store';
const { Utils: Di, Text: Bo, BaseBlockModel: Rn, Signal: je } = pkg;

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
<unknown>
file:///home/himself65/Code/AFFiNE/node_modules/.pnpm/@blocksuite+blocks@0.3.0-alpha.8/node_modules/@blocksuite/blocks/dist/index.js (1)
ModuleJob._instantiate
node:internal/modules/esm/module_job (123:21)
async ModuleJob.run
node:internal/modules/esm/module_job (189:5)
async ESMLoader.import
node:internal/modules/esm/loader (530:24)
async importModuleDynamicallyWrapper
node:internal/vm/module (438:15)
@himself65
Copy link
Contributor Author

Subject: [PATCH] chore: bump version
---
Index: packages/app/src/components/edgeless-toolbar/index.tsx
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/packages/app/src/components/edgeless-toolbar/index.tsx b/packages/app/src/components/edgeless-toolbar/index.tsx
--- a/packages/app/src/components/edgeless-toolbar/index.tsx	(revision 88d421f2d6790aae328de70905e8583e8db12758)
+++ b/packages/app/src/components/edgeless-toolbar/index.tsx	(date 1670992045566)
@@ -17,7 +17,7 @@
 import { Tooltip } from '@/ui/tooltip';
 import Slide from '@mui/material/Slide';
 import { useEditor } from '@/components/editor-provider';
-import { createEvent } from '@blocksuite/blocks';
+import { createEvent ,TDShapeType, ColorStyle } from '@blocksuite/blocks';
 
 const toolbarList1 = [
   {
@@ -48,8 +48,8 @@
       window.dispatchEvent(
         createEvent('affine.switch-mouse-mode', {
           type: 'shape',
-          shape: 'rectangle',
-          color: 'black',
+          shape: TDShapeType.Rectangle,
+          color: ColorStyle.Black,
         })
       );
     },
Index: pnpm-lock.yaml
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
--- a/pnpm-lock.yaml	(revision 88d421f2d6790aae328de70905e8583e8db12758)
+++ b/pnpm-lock.yaml	(date 1670992045578)
@@ -30,9 +30,9 @@
 
   packages/app:
     specifiers:
-      '@blocksuite/blocks': 0.3.0-alpha.4
-      '@blocksuite/editor': 0.3.0-alpha.4
-      '@blocksuite/store': 0.3.0-alpha.4
+      '@blocksuite/blocks': 0.3.0-alpha.8
+      '@blocksuite/editor': 0.3.0-alpha.8
+      '@blocksuite/store': 0.3.0-alpha.8
       '@emotion/css': ^11.10.0
       '@emotion/react': ^11.10.4
       '@emotion/server': ^11.10.0
@@ -60,9 +60,9 @@
       react-dom: 18.2.0
       typescript: 4.8.3
     dependencies:
-      '@blocksuite/blocks': 0.3.0-alpha.4
-      '@blocksuite/editor': 0.3.0-alpha.4
-      '@blocksuite/store': 0.3.0-alpha.4
+      '@blocksuite/blocks': 0.3.0-alpha.8
+      '@blocksuite/editor': 0.3.0-alpha.8
+      '@blocksuite/store': 0.3.0-alpha.8
       '@emotion/css': 11.10.0
       '@emotion/react': 11.10.4_w5j4k42lgipnm43s3brx6h3c34
       '@emotion/server': 11.10.0_@emotion+css@11.10.0
@@ -472,12 +472,15 @@
     resolution: {integrity: sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==}
     dev: true
 
-  /@blocksuite/blocks/0.3.0-alpha.4:
-    resolution: {integrity: sha512-ij/kKW5ahJQPKMZe2UjwJwvcPNQFQ09/KoRIfFRwBdTBisPGtlSUwunDMlFFoY7CbnH4E+cpg+6XjcJDQniDBw==}
+  /@blocksuite/blocks/0.3.0-alpha.8:
+    resolution: {integrity: sha512-Q7md4N1H0lTMG0nX1PnAdSlTjBfNX4nFLlcX3SrdgjSM9QOu0G6E6OvfHHHCj4SJPnzyHH5xb6Lb0jU9Lpas6Q==}
     dependencies:
-      '@blocksuite/store': 0.3.0-alpha.4
+      '@blocksuite/store': 0.3.0-alpha.8
+      '@tldraw/intersect': 1.8.0
+      '@tldraw/vec': 1.8.0
       hotkeys-js: 3.10.0
       lit: 2.4.0
+      perfect-freehand: 1.2.0
       quill: 1.3.7
       quill-cursors: 4.0.0
     transitivePeerDependencies:
@@ -486,11 +489,11 @@
       - utf-8-validate
     dev: false
 
-  /@blocksuite/editor/0.3.0-alpha.4:
-    resolution: {integrity: sha512-qTNFFIhqQqGT/qwQvUVmgv+EgiBnHB4G5NCPCKn5pdHXM3vrihsY3yG33YVFc1M7+ZwJsfw6sNbtkv+Ih62aaw==}
+  /@blocksuite/editor/0.3.0-alpha.8:
+    resolution: {integrity: sha512-Sx5E69LMZkUcc37q2PLXAnNTHy9okn/UFBfcWG8i5LO/T8QpYJgbllZGJDx7A3qP8Uz+BQyhgI5gp8S/dnra7g==}
     dependencies:
-      '@blocksuite/blocks': 0.3.0-alpha.4
-      '@blocksuite/store': 0.3.0-alpha.4
+      '@blocksuite/blocks': 0.3.0-alpha.8
+      '@blocksuite/store': 0.3.0-alpha.8
       lit: 2.4.0
       marked: 4.1.1
       turndown: 7.1.1
@@ -500,12 +503,15 @@
       - utf-8-validate
     dev: false
 
-  /@blocksuite/store/0.3.0-alpha.4:
-    resolution: {integrity: sha512-hLXFiTf1e4qdX9T0uU+SsBwYWMLqU3ILTxALHRWCxSgKs4/qw7pu24c/XT9L+AAUWFMbNH4MnAK+lrCBiOS1wg==}
+  /@blocksuite/store/0.3.0-alpha.8:
+    resolution: {integrity: sha512-u63FWZSiYID8++tEIaQZ5FSj7NZu9XM2ZdTaTU+7PDEwucK5Gqo8+YrEC9gVl+2jkSW5cp43pxf2kZolUgkyYg==}
     dependencies:
+      buffer: 6.0.3
       flexsearch: 0.7.21
       idb-keyval: 6.2.0
+      ky: 0.32.2
       lib0: 0.2.52
+      sha3: 2.1.4
       y-indexeddb: 9.0.9_yjs@13.5.41
       y-protocols: 1.0.5
       y-webrtc: 10.2.3
@@ -1469,6 +1475,16 @@
     dependencies:
       tslib: 2.4.0
     dev: false
+
+  /@tldraw/intersect/1.8.0:
+    resolution: {integrity: sha512-0UarshNpyq2+O4o0xHMJIBgF0E630mes5CkMoO+D5xgYppSBIkeqYDcv0ujsmAhMKX1O6Y0ShuuHeflBEULUoQ==}
+    dependencies:
+      '@tldraw/vec': 1.8.0
+    dev: false
+
+  /@tldraw/vec/1.8.0:
+    resolution: {integrity: sha512-GiS5Df3CzXY/fPBFcM0CKFERZfI4Cg1X33VPZX+NLo7Fwm/h9zu/aU24N1mG75Q9LuMnwKm7woxKr8BiUXGYCg==}
+    dev: false
 
   /@types/babel__core/7.1.20:
     resolution: {integrity: sha512-PVb6Bg2QuscZ30FvOU7z4guG6c926D9YRvOxEaelzndpMsvP+YM74Q/dAFASpg2l6+XLalxSGxcq/lrgYWZtyQ==}
@@ -2495,7 +2511,7 @@
       eslint-import-resolver-webpack:
         optional: true
     dependencies:
-      '@typescript-eslint/parser': 5.38.0_76twfck5d7crjqrmw4yltga7zm
+      '@typescript-eslint/parser': 5.38.0_tg6quxtr5dyl3tikvj7rwonxxi
       debug: 3.2.7
       eslint: 8.22.0
       eslint-import-resolver-node: 0.3.6
@@ -2514,7 +2530,7 @@
       '@typescript-eslint/parser':
         optional: true
     dependencies:
-      '@typescript-eslint/parser': 5.38.0_76twfck5d7crjqrmw4yltga7zm
+      '@typescript-eslint/parser': 5.38.0_tg6quxtr5dyl3tikvj7rwonxxi
       array-includes: 3.1.5
       array.prototype.flat: 1.3.0
       debug: 2.6.9
@@ -3763,6 +3779,11 @@
     engines: {node: '>=6'}
     dev: true
 
+  /ky/0.32.2:
+    resolution: {integrity: sha512-eBJeF6IXNwX5rksdwBrE2rIJrU2d84GoTvdM7OmmTIwUVXEMd72wIwvT+nyhrqtv7AzbSNsWz7yRsHgVhj1uog==}
+    engines: {node: '>=14.16'}
+    dev: false
+
   /language-subtag-registry/0.3.22:
     resolution: {integrity: sha512-tN0MCzyWnoz/4nHS6uxdlFWoUZT7ABptwKPQ52Ea7URk6vll88bWBVhodtnlfEuCcKWNGoc+uGbw1cwa9IKh/w==}
     dev: true
@@ -4326,6 +4347,10 @@
     resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==}
     engines: {node: '>=8'}
 
+  /perfect-freehand/1.2.0:
+    resolution: {integrity: sha512-h/0ikF1M3phW7CwpZ5MMvKnfpHficWoOEyr//KVNTxV4F6deRK1eYMtHyBKEAKFK0aXIEUK9oBvlF6PNXMDsAw==}
+    dev: false
+
   /picocolors/1.0.0:
     resolution: {integrity: sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==}
 
@@ -4620,6 +4645,12 @@
       lru-cache: 6.0.0
     dev: true
 
+  /sha3/2.1.4:
+    resolution: {integrity: sha512-S8cNxbyb0UGUM2VhRD4Poe5N58gJnJsLJ5vC7FYWGUmGhcsj4++WaIOBFVDxlG0W3To6xBuiRh+i0Qp2oNCOtg==}
+    dependencies:
+      buffer: 6.0.3
+    dev: false
+
   /shebang-command/2.0.0:
     resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==}
     engines: {node: '>=8'}
Index: packages/app/package.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/packages/app/package.json b/packages/app/package.json
--- a/packages/app/package.json	(revision 88d421f2d6790aae328de70905e8583e8db12758)
+++ b/packages/app/package.json	(date 1670992045570)
@@ -9,9 +9,9 @@
     "lint": "next lint"
   },
   "dependencies": {
-    "@blocksuite/blocks": "0.3.0-alpha.4",
-    "@blocksuite/editor": "0.3.0-alpha.4",
-    "@blocksuite/store": "0.3.0-alpha.4",
+    "@blocksuite/blocks": "0.3.0-alpha.8",
+    "@blocksuite/editor": "0.3.0-alpha.8",
+    "@blocksuite/store": "0.3.0-alpha.8",
     "@emotion/css": "^11.10.0",
     "@emotion/react": "^11.10.4",
     "@emotion/server": "^11.10.0",
Index: packages/app/tsconfig.json
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/packages/app/tsconfig.json b/packages/app/tsconfig.json
--- a/packages/app/tsconfig.json	(revision 88d421f2d6790aae328de70905e8583e8db12758)
+++ b/packages/app/tsconfig.json	(date 1670992134524)
@@ -17,7 +17,8 @@
     "experimentalDecorators": true,
     "baseUrl": ".",
     "paths": {
-      "@/*": ["src/*"]
+      "@/*": ["src/*"],
+      "@toeverything/pathfinder-logger": ["../logger/src/index"]
     }
   },
   "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
Index: packages/app/src/components/editor.tsx
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/packages/app/src/components/editor.tsx b/packages/app/src/components/editor.tsx
--- a/packages/app/src/components/editor.tsx	(revision 88d421f2d6790aae328de70905e8583e8db12758)
+++ b/packages/app/src/components/editor.tsx	(date 1670992331786)
@@ -16,18 +16,27 @@
       return;
     }
     const workspace = new Workspace({});
-    const page = workspace.createPage('page0').register(BlockSchema);
-    const editor = createEditor(page);
-    containerElement.current.appendChild(editor);
-    if (ref) {
-      if ('current' in ref) {
-        ref.current = editor;
-      } else {
-        ref(editor);
-      }
-    }
+    workspace.register(BlockSchema);
+    let editor: EditorContainer | null = null
+    workspace.signals.pageAdded.once(pageId => {
+      const page = workspace.getPage(pageId);
+      if (!page) {
+        return
+      }
+      editor = createEditor(page);
+      containerElement.current?.appendChild(editor);
+      if (ref) {
+        if ('current' in ref) {
+          ref.current = editor;
+        } else {
+          ref(editor);
+        }
+      }
+    });
+    const page = workspace.createPage('page0');
+
     return () => {
-      editor.remove();
+      editor?.remove();
     };
   }, [ref]);
   return <div id="editor" style={{ height: '100%' }} ref={containerElement} />;

@himself65 himself65 changed the title Server Error in AFFiNE in 3.0.0-alpha.8 Server Error in AFFiNE when upgrading to 3.0.0-alpha.8 Dec 14, 2022
@doodlewind
Copy link
Member

doodlewind commented Dec 14, 2022

Does this mean import { Text } from '@blocksuite/store' doesn't work? A workaround would be using new page.Text, this is prepared for E2E testing, since we can't import ESM module inside evaluate scripts.

@doodlewind doodlewind changed the title Server Error in AFFiNE when upgrading to 3.0.0-alpha.8 Server Error in AFFiNE when upgrading to 0.3.0-alpha.8 Dec 14, 2022
@doodlewind
Copy link
Member

Does this happen in previous alpha versions?

@doodlewind doodlewind added type:bug Something isn't working mod:infra Environment related issues and discussions labels Dec 14, 2022
@himself65
Copy link
Contributor Author

occurs when import { createEvent } from '@blocksuite/blocks';

@himself65
Copy link
Contributor Author

I think this is a future, not a bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mod:infra Environment related issues and discussions type:bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants