From c5d2322aae931b32d76129fed18dea0c9b642ad9 Mon Sep 17 00:00:00 2001 From: Fabien Arcellier Date: Mon, 29 Apr 2024 10:35:20 +0200 Subject: [PATCH 1/2] fix: Custom Components not loading with .cjs extension --- .gitignore | 1 - src/ui/.gitignore | 1 + src/ui/vite.config.custom.ts | 11 ++++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0c64092c5..926bde277 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,6 @@ docs/docs/.vitepress/cache/ docs/docs/.vitepress/temp/ ui/dist/ -ui/custom_components_dist/ build/ dist/ src/streamsync.egg-info/ diff --git a/src/ui/.gitignore b/src/ui/.gitignore index 0b2202b96..e7d44cf12 100644 --- a/src/ui/.gitignore +++ b/src/ui/.gitignore @@ -6,3 +6,4 @@ node_modules/ storybook-static/ *storybook.log +/custom_components_dist diff --git a/src/ui/vite.config.custom.ts b/src/ui/vite.config.custom.ts index 0aee7403e..9c9573018 100644 --- a/src/ui/vite.config.custom.ts +++ b/src/ui/vite.config.custom.ts @@ -20,7 +20,16 @@ export default defineConfig({ entry: ["./src/custom_components"], formats: ["umd"], name: "StreamsyncCustomComponentTemplates", - fileName: "templates", + fileName: (format, entryalias: string): string => { + /* + The umd file is generated with a cjs extension since transforming the streamsync package into a module + (https://github.com/streamsync-cloud/streamsync/issues/405). + + We use the generated file inside a browser, not a nodejs application. + The cjs extension is not adapted. We implement our own name builder. + */ + return "templates.umd.js"; + }, }, rollupOptions: { external: ["vue", "../injectionKeys"], From 879e5ba9105e2e7bbacdf3f755611a9c0c9e5188 Mon Sep 17 00:00:00 2001 From: Fabien Arcellier Date: Mon, 29 Apr 2024 10:40:07 +0200 Subject: [PATCH 2/2] fix: Custom Components not loading with .cjs extension * ignore generated files from ui directory in eslint --- src/ui/package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ui/package.json b/src/ui/package.json index d35f606bf..49918dc4a 100644 --- a/src/ui/package.json +++ b/src/ui/package.json @@ -6,8 +6,8 @@ "dev": "vite", "build": "vite build", "preview": "vite preview --port 5050", - "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path ../../.gitignore", - "lint:ci": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --ignore-path ../../.gitignore", + "lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --fix --ignore-path ../../.gitignore --ignore-path .gitignore", + "lint:ci": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs --ignore-path ../../.gitignore --ignore-path .gitignore", "codegen": "node tools/generator.mjs", "custom.dev": "vite --config vite.config.custom.ts", "custom.build": "vite build --config vite.config.custom.ts",