@awarebydefault/display-case 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awarebydefault/display-case",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A Bun-native, AI-friendly component showcase — a lightweight alternative to Storybook.",
5
5
  "license": "MIT",
6
6
  "author": "Jake Uskoski <jake@awarebydefault.com>",
@@ -73,8 +73,10 @@
73
73
  "e2e": "playwright test",
74
74
  "e2e:headed": "playwright test --headed",
75
75
  "e2e:install": "playwright install chromium",
76
- "release": "semantic-release",
77
- "release:dry": "semantic-release --dry-run --no-ci",
76
+ "changeset": "changeset",
77
+ "changeset:status": "changeset status",
78
+ "changeset:version": "changeset version",
79
+ "changeset:publish": "changeset publish",
78
80
  "prepare": "husky"
79
81
  },
80
82
  "peerDependencies": {
@@ -93,6 +95,7 @@
93
95
  },
94
96
  "devDependencies": {
95
97
  "@biomejs/biome": "^2.5.0",
98
+ "@changesets/cli": "^2.27.11",
96
99
  "@commitlint/cli": "^19.6.0",
97
100
  "@commitlint/config-conventional": "^19.6.0",
98
101
  "@emotion/cache": "^11.14.0",
@@ -100,14 +103,11 @@
100
103
  "@emotion/server": "^11.11.0",
101
104
  "@fission-ai/openspec": "1.4.1",
102
105
  "@playwright/test": "^1.60.0",
103
- "@semantic-release/changelog": "^6.0.3",
104
- "@semantic-release/git": "^10.0.1",
105
106
  "@types/bun": "^1.2.0",
106
107
  "@types/pngjs": "^6.0.5",
107
108
  "@types/react": "^19",
108
109
  "@types/react-dom": "^19",
109
110
  "husky": "^9.1.7",
110
- "semantic-release": "^25.0.5",
111
111
  "typescript": "^5.7.0"
112
112
  }
113
113
  }
@@ -57,4 +57,30 @@ describe('mdxPlugin', () => {
57
57
  await rm(dir, { recursive: true, force: true })
58
58
  }
59
59
  })
60
+
61
+ test('emits an absolute, self-resolved markdown-to-jsx specifier', async () => {
62
+ const { run } = captureOnLoad()
63
+ const dir = await makeTempDir()
64
+ try {
65
+ const file = join(dir, 'doc.mdx')
66
+ await Bun.write(file, '# Title\n\nSome prose.\n')
67
+ const result = await run({ path: file })
68
+ // The compiled primer is loaded from the consumer's tree, where a bare
69
+ // `markdown-to-jsx` would not resolve. The plugin anchors it at Display
70
+ // Case's own install so the consumer never needs to declare the dep.
71
+ const resolved = Bun.resolveSync('markdown-to-jsx', import.meta.dir)
72
+ expect(result.contents).toContain(
73
+ `import __Md from ${JSON.stringify(resolved)}`,
74
+ )
75
+ // Never a bare specifier — that is the bug this guards against.
76
+ expect(result.contents).not.toContain(
77
+ "import __Md from 'markdown-to-jsx'",
78
+ )
79
+ expect(result.contents).not.toContain(
80
+ 'import __Md from "markdown-to-jsx"',
81
+ )
82
+ } finally {
83
+ await rm(dir, { recursive: true, force: true })
84
+ }
85
+ })
60
86
  })
@@ -1,6 +1,38 @@
1
1
  import type { BunPlugin } from 'bun'
2
2
  import { mdxToTsx } from './mdx-lite'
3
3
 
4
+ /**
5
+ * Absolute path to `markdown-to-jsx`, resolved from Display Case's own location
6
+ * (this module), memoized on first use.
7
+ *
8
+ * The compiled primer module is loaded from inside the *consumer* package's tree
9
+ * (its `primer.mdx` is the bundle entry), so a bare `import 'markdown-to-jsx'`
10
+ * would be resolved relative to the consumer — and `markdown-to-jsx` is a private
11
+ * dependency of `@awarebydefault/display-case`, not hoisted into the consumer's
12
+ * scope, so that resolution fails with `Could not resolve "markdown-to-jsx"`.
13
+ * Emitting an absolute path anchored at Display Case's own install makes the
14
+ * import resolve regardless of the consumer's `node_modules` layout, so authoring
15
+ * a Markdown/MDX primer never requires the consumer to redeclare the dep. It also
16
+ * resolves to the same physical module the `.placard.md` DocPanel imports, so Bun
17
+ * dedupes the two into one bundled copy.
18
+ */
19
+ let cachedMarkdownSpecifier: string | undefined
20
+ function markdownSpecifier(): string {
21
+ if (cachedMarkdownSpecifier === undefined) {
22
+ try {
23
+ cachedMarkdownSpecifier = Bun.resolveSync(
24
+ 'markdown-to-jsx',
25
+ import.meta.dir,
26
+ )
27
+ } catch {
28
+ // Fall back to the bare specifier (matches mdx-lite's own default) for the
29
+ // case where a consumer does carry the dep and resolution from here fails.
30
+ cachedMarkdownSpecifier = 'markdown-to-jsx'
31
+ }
32
+ }
33
+ return cachedMarkdownSpecifier
34
+ }
35
+
4
36
  /**
5
37
  * Bun bundler plugin that compiles `.mdx` to TSX on load, so the Primer entry can
6
38
  * `import` an authored `.mdx` document and the components it pulls in.
@@ -23,7 +55,12 @@ export function mdxPlugin(): BunPlugin {
23
55
  setup(build) {
24
56
  build.onLoad({ filter: /\.mdx$/ }, async (args) => {
25
57
  const source = await Bun.file(args.path).text()
26
- return { contents: mdxToTsx(source), loader: 'tsx' }
58
+ return {
59
+ contents: mdxToTsx(source, {
60
+ markdownSpecifier: markdownSpecifier(),
61
+ }),
62
+ loader: 'tsx',
63
+ }
27
64
  })
28
65
  },
29
66
  }