From d13a4d852c44339dfa302443610ea2a8072e5eb3 Mon Sep 17 00:00:00 2001 From: Andreas Heissenberger Date: Tue, 13 Feb 2024 14:48:08 +0100 Subject: [PATCH 1/6] feat: Test bundling npm packages which provide environment depended code parts --- e2e/fixtures/ssr-target-bundle/README.md | 3 + e2e/fixtures/ssr-target-bundle/package.json | 23 +++++ .../ssr-target-bundle/src/components/App.tsx | 13 +++ .../src/components/Textarea.tsx | 10 +++ .../ssr-target-bundle/src/entries.tsx | 28 ++++++ e2e/fixtures/ssr-target-bundle/src/main.tsx | 17 ++++ e2e/fixtures/ssr-target-bundle/tsconfig.json | 16 ++++ e2e/ssr-target-bundle.spec.ts | 86 +++++++++++++++++++ 8 files changed, 196 insertions(+) create mode 100644 e2e/fixtures/ssr-target-bundle/README.md create mode 100644 e2e/fixtures/ssr-target-bundle/package.json create mode 100644 e2e/fixtures/ssr-target-bundle/src/components/App.tsx create mode 100644 e2e/fixtures/ssr-target-bundle/src/components/Textarea.tsx create mode 100644 e2e/fixtures/ssr-target-bundle/src/entries.tsx create mode 100644 e2e/fixtures/ssr-target-bundle/src/main.tsx create mode 100644 e2e/fixtures/ssr-target-bundle/tsconfig.json create mode 100644 e2e/ssr-target-bundle.spec.ts diff --git a/e2e/fixtures/ssr-target-bundle/README.md b/e2e/fixtures/ssr-target-bundle/README.md new file mode 100644 index 000000000..183341d89 --- /dev/null +++ b/e2e/fixtures/ssr-target-bundle/README.md @@ -0,0 +1,3 @@ +# SSR Bundling for NPM packages with environment depended code parts + +Choosing the right code based on the `export` section of the `react-textarea-autosize` module based on the backend server deployment target ('node' | 'webworker') and the client browser. No browser only code should be bundled with server only code. diff --git a/e2e/fixtures/ssr-target-bundle/package.json b/e2e/fixtures/ssr-target-bundle/package.json new file mode 100644 index 000000000..bbaebb271 --- /dev/null +++ b/e2e/fixtures/ssr-target-bundle/package.json @@ -0,0 +1,23 @@ +{ + "name": "ssr-basic", + "version": "0.1.0", + "type": "module", + "private": true, + "scripts": { + "dev": "waku dev --with-ssr", + "build": "waku build --with-ssr", + "start": "waku start --with-ssr" + }, + "dependencies": { + "react": "18.3.0-canary-4b2a1115a-20240202", + "react-dom": "18.3.0-canary-4b2a1115a-20240202", + "react-server-dom-webpack": "18.3.0-canary-4b2a1115a-20240202", + "react-textarea-autosize": "^8.5.3", + "waku": "0.19.2" + }, + "devDependencies": { + "@types/react": "18.2.55", + "@types/react-dom": "18.2.19", + "typescript": "5.3.3" + } +} diff --git a/e2e/fixtures/ssr-target-bundle/src/components/App.tsx b/e2e/fixtures/ssr-target-bundle/src/components/App.tsx new file mode 100644 index 000000000..904e52da3 --- /dev/null +++ b/e2e/fixtures/ssr-target-bundle/src/components/App.tsx @@ -0,0 +1,13 @@ +import { Textarea } from './Textarea.js'; + +const App = ({ name }: { name: string }) => { + return ( +
+ Waku example +

{name}

+