Skip to content

Commit c0c5593

Browse files
committed
refactor: rename bundler-shared to element-bundler with compatibility shim
Clarify the IIFE-only scope of the bundler package and migrate internal consumers to the new package name while preserving backward compatibility for existing bundler-shared imports. Made-with: Cursor
1 parent 016097c commit c0c5593

23 files changed

Lines changed: 171 additions & 47 deletions

File tree

apps/element-demo/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66

77
- Updated dependencies [e131840]
88
- @pie-element/element-player@0.1.1
9-
- @pie-element/bundler-shared@0.1.1
9+
- @pie-element/element-bundler@0.1.1

apps/element-demo/DEPENDENCIES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The demo app is designed to work with PIE elements loaded as ESM web components.
88

99
Only two packages are needed at runtime:
1010

11-
- `@pie-element/bundler-shared` - Bundler infrastructure for IIFE operation
11+
- `@pie-element/element-bundler` - Bundler infrastructure for IIFE operation
1212
- `@pie-element/element-player` - Web component that loads and renders elements
1313

1414
### Why so minimal?
@@ -85,4 +85,4 @@ Currently the demo only supports local development mode. To support production C
8585
3. Configure CDN URL (e.g., `https://esm.sh` or `https://unpkg.com`)
8686
4. All element dependencies resolve automatically through CDN
8787

88-
At that point, only `@pie-element/element-player` would be needed as a runtime dependency (bundler-shared is only for IIFE mode).
88+
At that point, only `@pie-element/element-player` would be needed as a runtime dependency (`@pie-element/element-bundler` is only for IIFE mode).

apps/element-demo/DEV_BUNDLER.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ The element demo supports both player modes:
77

88
When `player=iife`, bundling is local-only.
99

10+
The local IIFE path uses `@pie-element/element-bundler`.
11+
ESM mode does not require `@pie-element/element-bundler`.
12+
1013
## dev:demo
1114

1215
Use the CLI command:
@@ -108,4 +111,3 @@ Source maps policy:
108111
- keep parity versions as control
109112
- upgrade in a branch/canary path
110113
- compare build success, output behavior, and runtime compatibility across representative element sets
111-

apps/element-demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"test:e2e:debug": "playwright test --debug"
2222
},
2323
"dependencies": {
24-
"@pie-element/bundler-shared": "workspace:*",
24+
"@pie-element/element-bundler": "workspace:*",
2525
"@pie-element/element-theme-daisyui": "workspace:*",
2626
"@pie-element/element-player": "workspace:*",
2727
"@tiptap/core": "3.18.0",

apps/element-demo/scripts/test-iife-bundle-contract.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs';
22
import { join } from 'node:path';
3-
import { Bundler, mkDependencyHash, type BuildBundleName } from '@pie-element/bundler-shared';
3+
import { Bundler, mkDependencyHash, type BuildBundleName } from '@pie-element/element-bundler';
44
import { loadReactElementMatrix } from '../src/lib/testing/react-element-matrix';
55
import { createWorkspaceCacheSalt } from '../src/lib/testing/workspace-fingerprint';
66

apps/element-demo/src/routes/api/bundle/+server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66

77
import { json } from '@sveltejs/kit';
88
import type { RequestHandler } from './$types';
9-
import { Bundler } from '@pie-element/bundler-shared';
10-
import type { BuildBundleName } from '@pie-element/bundler-shared';
9+
import { Bundler } from '@pie-element/element-bundler';
10+
import type { BuildBundleName } from '@pie-element/element-bundler';
1111
import { join } from 'node:path';
1212
import { mkdirSync, rmSync, existsSync, writeFileSync } from 'node:fs';
13-
import { mkBundleCacheKey } from '@pie-element/bundler-shared';
13+
import { mkBundleCacheKey } from '@pie-element/element-bundler';
1414
import { createOrJoinBuild, emitBuildEvent, getBuildSnapshot } from './build-state';
1515
import { createWorkspaceCacheSaltForDependencies } from '$lib/testing/workspace-fingerprint';
1616

apps/element-demo/src/routes/api/bundle/build-state.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type {
33
BuildRequest,
44
BuildResult,
55
BuildStage,
6-
} from '@pie-element/bundler-shared';
6+
} from '@pie-element/element-bundler';
77

88
export interface BuildSnapshot {
99
buildId: string;

bun.lock

Lines changed: 23 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/BUNDLER_SERVICE.md

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ This bundler service creates IIFE (Immediately Invoked Function Expression) bund
88

99
## Architecture
1010

11-
```
11+
```text
1212
┌─────────────────────────────────────────────────────────┐
1313
│ pie-elements-ng │
1414
├─────────────────────────────────────────────────────────┤
1515
│ │
1616
│ ┌──────────────────────────────────────────────────┐ │
17-
│ │ @pie-element/bundler-shared │ │
17+
│ │ @pie-element/element-bundler │ │
1818
│ │ (Framework-agnostic bundler) │ │
1919
│ │ │ │
2020
│ │ • Webpack 5 configuration │ │
@@ -50,7 +50,8 @@ This bundler service creates IIFE (Immediately Invoked Function Expression) bund
5050
## Created Files
5151

5252
### Core Bundler Package
53-
- `packages/shared/bundler-shared/package.json` - Package configuration
53+
54+
- `packages/shared/bundler-shared/package.json` - Package configuration for `@pie-element/element-bundler`
5455
- `packages/shared/bundler-shared/src/index.ts` - Main Bundler class
5556
- `packages/shared/bundler-shared/src/types.ts` - TypeScript types
5657
- `packages/shared/bundler-shared/src/installer.ts` - Package installer
@@ -61,6 +62,7 @@ This bundler service creates IIFE (Immediately Invoked Function Expression) bund
6162
- `packages/shared/bundler-shared/README.md` - Documentation
6263

6364
### SvelteKit Integration
65+
6466
- `apps/element-demo/src/routes/api/bundle/+server.ts` - API endpoint
6567
- `apps/element-demo/src/routes/bundler/+page.svelte` - Test UI
6668

@@ -74,11 +76,12 @@ bun run dev
7476

7577
### 2. Navigate to the Bundler UI
7678

77-
Open http://localhost:5173/bundler
79+
Open [http://localhost:5173/bundler](http://localhost:5173/bundler)
7880

7981
### 3. Build a Bundle
8082

8183
Enter an element name and version:
84+
8285
- Element: `@pie-element/multiple-choice`
8386
- Version: `0.1.0`
8487

@@ -87,6 +90,7 @@ Click "Build Bundle" and wait for the build to complete (~30-60 seconds).
8790
### 4. Use the Bundle
8891

8992
The bundles will be available at:
93+
9094
- Player: `/bundles/{hash}/player.js`
9195
- Client Player: `/bundles/{hash}/client-player.js`
9296
- Editor: `/bundles/{hash}/editor.js`
@@ -108,6 +112,7 @@ Load them in your HTML:
108112
Build a bundle from dependencies.
109113

110114
**Request:**
115+
111116
```json
112117
{
113118
"dependencies": [
@@ -120,6 +125,7 @@ Build a bundle from dependencies.
120125
```
121126

122127
**Response:**
128+
123129
```json
124130
{
125131
"success": true,
@@ -139,6 +145,7 @@ Build a bundle from dependencies.
139145
Check if a bundle exists.
140146

141147
**Response:**
148+
142149
```json
143150
{
144151
"exists": true,
@@ -148,7 +155,7 @@ Check if a bundle exists.
148155
"editor": "/bundles/1234567890/editor.js"
149156
}
150157
}
151-
```
158+
```text
152159

153160
## How It Works
154161

@@ -165,7 +172,7 @@ Check if a bundle exists.
165172

166173
The bundler handles different versions of `@pie-lib` packages per element:
167174

168-
```
175+
```text
169176
Element A uses @pie-lib/math-rendering@4.0.0
170177
Element B uses @pie-lib/math-rendering@4.1.0
171178
```
@@ -175,20 +182,22 @@ The `NormalModuleReplacementPlugin` detects which element is importing and resol
175182
## Benefits
176183

177184
### vs pie-api-aws Bundler
185+
178186
-**Self-contained** - No Lambda, Temporal, SNS, or CloudWatch
179187
-**Open source** - Fully available in this repo
180188
-**Testable** - Easy to test locally
181189
-**Simpler** - ~600 lines vs ~5000 lines
182190
-**Framework agnostic** - Can be used in any Node.js environment
183191

184192
### vs Pre-publishing IIFE Bundles
193+
185194
-**On-demand** - Build only what's needed
186195
-**Flexible** - Combine any elements and versions
187196
-**Space efficient** - Don't store all combinations
188197

189198
## Reusability
190199

191-
The `@pie-element/bundler-shared` package is framework-agnostic and can be used in:
200+
The `@pie-element/element-bundler` package is framework-agnostic and can be used in:
192201

193202
- ✅ SvelteKit (current implementation)
194203
- ✅ Express/Fastify/Hono
@@ -200,7 +209,7 @@ Example with Express:
200209

201210
```typescript
202211
import express from 'express';
203-
import { Bundler } from '@pie-element/bundler-shared';
212+
import { Bundler } from '@pie-element/element-bundler';
204213

205214
const app = express();
206215
const bundler = new Bundler('./public/bundles');
@@ -224,8 +233,8 @@ Potential additions:
224233

225234
## Comparison with Upstream
226235

227-
| Feature | pie-api-aws | bundler-shared |
228-
|---------|-------------|----------------|
236+
| Feature | pie-api-aws | element-bundler |
237+
| -------- | ----------- | ---------------- |
229238
| **Bundler** | Webpack 5 | Webpack 5 ✓ |
230239
| **Version resolution** | NormalModuleReplacementPlugin | Same ✓ |
231240
| **Entry generation** | code-generator.ts | Simplified ✓ |
@@ -237,6 +246,11 @@ Potential additions:
237246
| **Complexity** | ~5000 lines | ~600 lines |
238247
| **Open source** | No (private repo) | Yes ✓ |
239248

249+
## Scope Clarification
250+
251+
- `@pie-element/element-bundler` currently produces IIFE bundles for the local IIFE runtime path.
252+
- ESM bundle workflows do not require this package.
253+
240254
## License
241255

242256
MIT
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# @pie-element/bundler-shared
2+
3+
## 0.1.1
4+
5+
### Patch Changes
6+
7+
- Deprecated package name. This package now re-exports from `@pie-element/element-bundler`.

0 commit comments

Comments
 (0)