Skip to content

Commit 2180d0f

Browse files
committed
chore: move dev-aliases into @repo/dev-aliases
1 parent 8b509f7 commit 2180d0f

File tree

6 files changed

+65
-33
lines changed

6 files changed

+65
-33
lines changed

dev/aliases.cjs

-32
This file was deleted.
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* eslint-disable tsdoc/syntax */
2+
3+
// NOTE: THIS FILE NEEDS TO REMAIN COMMONJS
4+
// It can be converted to ESM/TS when we either not use jest anymore, or node/jest runner natively supports ESM (including with import.meta etc).
5+
6+
/**
7+
* The path mappings/aliases used by various tools in the monorepo to map imported modules to
8+
* source files in order to speed up rebuilding and avoid having a separate watcher process to build
9+
* from `src` to `lib`.
10+
*
11+
* This file is currently read by:
12+
* - Vite when running the dev server (only when running in this monorepo)
13+
* - jest when running test suite
14+
*
15+
* @type Record<string, string>
16+
*/
17+
const devAliases = {
18+
// NOTE: do not use regex in the module expressions,
19+
// because they will be escaped by the jest config
20+
'@sanity/block-tools': '@sanity/block-tools/src',
21+
'@sanity/diff': '@sanity/diff/src',
22+
'@sanity/cli': '@sanity/cli/src',
23+
'@sanity/mutator': '@sanity/mutator/src',
24+
'@sanity/schema': '@sanity/schema/src/_exports',
25+
'@sanity/migrate': '@sanity/migrate/src/_exports',
26+
'@sanity/types': '@sanity/types/src',
27+
'@sanity/util': '@sanity/util/src/_exports',
28+
'@sanity/vision': '@sanity/vision/src',
29+
'sanity': 'sanity/src/_exports',
30+
'groq': 'groq/src/_exports.mts',
31+
}
32+
33+
module.exports = devAliases
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@repo/dev-aliases",
3+
"version": "3.57.4",
4+
"private": true,
5+
"description": "Dev aliases for the sanity monorepo",
6+
"type": "module",
7+
"exports": {
8+
".": "./dev-aliases.cjs"
9+
},
10+
"main": "./dev-aliases.cjs"
11+
}

packages/@repo/dev-aliases/vite.mjs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import devAliases from './dev-aliases.cjs'
2+
3+
import {dirname, resolve} from 'node:path'
4+
5+
const PACKAGES_PATH = resolve(getDirname(import.meta.url), '..', '..')
6+
7+
function getDirname(importMetaUrl) {
8+
return dirname(importMetaUrl.replace('file://', ''))
9+
}
10+
11+
export function getViteAliases() {
12+
return Object.fromEntries(
13+
Object.entries(devAliases).map(([packageName, aliasPath]) => [
14+
packageName,
15+
resolve(PACKAGES_PATH, aliasPath),
16+
]),
17+
)
18+
}

pnpm-lock.yaml

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
// Until what's in dev/, scripts. and test/ is in workspaces it's necessary to type check them from the root
33
"extends": "@repo/tsconfig/base.json",
4-
"include": ["./dev/aliases.cjs", "./scripts", "./test"],
4+
"include": ["./scripts", "./test"],
55
"files": [],
66
"compilerOptions": {
77
"rootDir": "."

0 commit comments

Comments
 (0)