Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 24 additions & 5 deletions projects/packages/premium-analytics/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,19 @@ jetpack build packages/premium-analytics # via Jetpack CLI
### Adding a route

1. Create `routes/<name>/package.json`:

```json
{
"name": "<name>-route",
"route": {
"path": "/<name>",
"page": "jetpack-premium-analytics"
}
"name": "<name>-route",
"route": {
"path": "/<name>",
"page": "jetpack-premium-analytics"
}
Comment thread
chihsuan marked this conversation as resolved.
Outdated
}
```

2. Create `routes/<name>/stage.tsx` exporting `stage()`:

```tsx
export const stage = () => <div>My new page</div>;
```
Expand All @@ -74,11 +76,28 @@ fixes the template or the minimum WordPress version is 7.0+.
### Init module (`packages/init/`)

Serves two purposes:

1. Sets the dashboard menu icon via `@wordpress/boot` store
2. Forces `@wordpress/build` to track `@wordpress/boot` as a module
dependency — without an init module that imports boot, the build
skips it

## Internal packages (`packages/*`)

App-internal modules discovered by `@wordpress/build`. Types/IDE resolve
`@jetpack-premium-analytics/<dir>` imports via the `tsconfig.json` `paths` alias
(`pnpm typecheck`).

To import one from a route/another package, the build also needs it symlinked in
`node_modules` under that specifier. Name the package
`@automattic/jetpack-premium-analytics-<dir>` (a bare `@jetpack-premium-analytics/*`
name fails the repo name lint and `_@…` is invalid to pnpm), then add a `link:`
dep on the top-level `package.json` (routes aren't workspace members):
Comment thread
chihsuan marked this conversation as resolved.
Outdated

```jsonc
"dependencies": { "@jetpack-premium-analytics/<dir>": "link:packages/<dir>" }
```

## File structure

```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: added

Add a tsconfig paths alias and typecheck script so internal packages/* resolve for types/IDE, and document how to wire cross-package imports for the build.
2 changes: 2 additions & 0 deletions projects/packages/premium-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"scripts": {
"build": "wp-build && mkdir -p build/modules/boot && cp shims/boot-asset.php build/modules/boot/index.min.asset.php",
"build-production": "NODE_ENV=production wp-build && mkdir -p build/modules/boot && cp shims/boot-asset.php build/modules/boot/index.min.asset.php",
"typecheck": "tsgo --noEmit",
"watch": "wp-build --watch"
},
"wpPlugin": {
Expand Down Expand Up @@ -38,6 +39,7 @@
},
"devDependencies": {
"@babel/core": "7.29.0",
"@typescript/native-preview": "7.0.0-dev.20260225.1",
"@wordpress/build": "0.13.0",
"browserslist": "4.28.2"
}
Expand Down
9 changes: 9 additions & 0 deletions projects/packages/premium-analytics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
{
"extends": "jetpack-js-tools/tsconfig.base.json",
"compilerOptions": {
// Resolve cross-package imports between internal `packages/*` modules
// (`@jetpack-premium-analytics/<dir>`) to their TypeScript source for
// type-checking + IDE. The build resolves the same specifier separately (see
// README → "Internal packages"); this keeps tsc/esbuild and `tsgo` in sync.
Comment thread
chihsuan marked this conversation as resolved.
Outdated
"paths": {
"@jetpack-premium-analytics/*": [ "./packages/*/src" ]
Comment thread
manzoorwanijk marked this conversation as resolved.
}
},
"include": [ "routes/**/*", "packages/**/*" ]
}
Loading