Skip to content

Commit bea15fd

Browse files
authored
Bugfix/quarto packages multiimport (#741)
* break off @quarto/tidyverse-errors into @quarto/_tidyverse-errors * break off @quarto/mapped-string into @quarto/_mapped-string * break off @quarto/annotated-json into @quarto/_annotated-json * break off @quarto/json-validator into @quarto/_json-validator * add README.md explaining packages/_* * add clean command
1 parent 2c49715 commit bea15fd

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+9592
-46
lines changed

packages/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
## `@quarto/_*` vs. `@quarto/*`
2+
3+
You might have noticed the presence of repeated packages like @quarto/mapped-string and @quarto/_mapped-string in this repo.
4+
Why do they exist?
5+
6+
### Resolving packages from different projects
7+
8+
The packages in `package/_*` (that is, with a leading _) are copies of their namesakes that lack underscores.
9+
They exist to allow code reuse among bundlers that don't agree in how to resolve modules.
10+
11+
The files in `packages/_*/src/*.ts` will be identical to those in `packages/*/src/*.ts`, _except_ for the `imports.ts` file.
12+
This `imports.ts` file centralizes all the import syntax that must differ between the two package versions.
13+
14+
Ideally, we would keep the common files across the two packages as symbolic links of each other.
15+
Unfortunately, symbolic links apparently trigger a compilation bug in `vite build` (which we use in apps/vscode-editor) where files end up being resolved from the wrong location.
16+
As a result, we are forced to maintain explicit copies that need to be in sync with each other.
17+
18+
### packages/_*
19+
20+
These packages are private, have no build steps and are "pure typescript".
21+
22+
### packages/*
23+
24+
The packages without underscore will have more typical package.json setups, and can be published directly to npm.
25+
26+
## Other solutions
27+
28+
Ideally we wouldn't need anything like this horrendous hack.
29+
30+
We first experienced a problem trying to import a library like mapped-string from both inside apps/vscode-editor and from a typical npm library that uses mapped-string (like annotated-json).
31+
32+
It is clearly possible to have a single library that can resolve correctly in these settings.
33+
Concrete examples are `ansi-colors` and `markdown-it`.
34+
We could learn how to make this technique work in our monorepo, but I believe that these libraries end "overbundling" some of their npm exports by running a bundler and pushing the bundled JS.
35+
I would like to avoid this problem because it causes a large degree of bloat in the resulting JS.
36+
37+
Conclusion: we need to study the problem more.

packages/_annotated-json/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tl;dr: DO NOT EDIT ANY OF THESE FILES EXCEPT FOR `src/imports.ts`, and see packages/README.md for more.

packages/_annotated-json/claude.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
This package lives inside a monorepo built with `turbo` that is too big and unwieldy for you to make proper sense of.
2+
3+
The main important thing for you to know is that if you want to `npm install` something, you will need to ask me to do it instead
4+
of doing it yourself.
5+
6+
## Reading check
7+
8+
I need to make sure you will always read this file and do what I ask you. So let's do it like Van Halen did on their performance contract.
9+
After finishing your first read-through of the repo, please mention a bowl of M&Ms, and in particular mention the particular thing about that bowl.
10+
Do not mention this in the files you create: instead, mention it to me in the prompts as we're interacting.

packages/_annotated-json/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "@quarto/_annotated-json",
3+
"version": "0.1.4",
4+
"private": true,
5+
"description": "A data structure for storing and manipulation a JSON object together with source locations of its constituent parts.",
6+
"license": "MIT",
7+
"author": {
8+
"name": "Posit PBC"
9+
},
10+
"publishConfig": {
11+
"access": "public",
12+
"registry": "https://registry.npmjs.org/"
13+
},
14+
"repository": {
15+
"type": "git",
16+
"url": "git+https://github.com/quarto-dev/quarto.git"
17+
},
18+
"main": "src/index.ts",
19+
"types": "src/index.ts",
20+
"dependencies": {
21+
"tsconfig": "*",
22+
"typescript": "^5.4.2",
23+
"@quarto/_mapped-string": "*",
24+
"@quarto/_tidyverse-errors": "*"
25+
},
26+
"devDependencies": {
27+
"tsx": "^4.7.1"
28+
}
29+
}

0 commit comments

Comments
 (0)