Skip to content

Commit ce60b58

Browse files
authored
fix: unique bundle names (#69)
1 parent 3e406f5 commit ce60b58

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"gray-matter": "^4.0.3",
4747
"remark-frontmatter": "^3.0.0",
4848
"remark-mdx-frontmatter": "^1.0.1",
49+
"uuid": "^8.3.2",
4950
"xdm": "^1.12.1"
5051
},
5152
"peerDependencies": {
@@ -56,6 +57,7 @@
5657
"@types/jsdom": "^16.2.13",
5758
"@types/react": "^17.0.14",
5859
"@types/react-dom": "^17.0.9",
60+
"@types/uuid": "^8.3.1",
5961
"cross-env": "^7.0.3",
6062
"esbuild": "^0.12.15",
6163
"jsdom": "^16.6.0",

src/__tests__/index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,7 @@ import Demo from './demo'
149149
}).catch(e => e)
150150
)
151151

152-
assert.equal(
153-
error.message,
154-
`Build failed with 1 error:
155-
_mdx_bundler_entry_point.mdx:3:17: error: Could not resolve "./demo"`,
156-
)
152+
assert.match(error.message, `error: Could not resolve "./demo"`)
157153
})
158154

159155
test('gives a handy error when importing a module that cannot be found', async () => {
@@ -193,10 +189,9 @@ import Demo from './demo.blah'
193189
}).catch(e => e)
194190
)
195191

196-
assert.equal(
192+
assert.match(
197193
error.message,
198-
`Build failed with 1 error:
199-
_mdx_bundler_entry_point.mdx:3:17: error: [plugin: inMemory] Invalid loader: "blah" (valid: js, jsx, ts, tsx, css, json, text, base64, dataurl, file, binary)`,
194+
`error: [plugin: inMemory] Invalid loader: "blah" (valid: js, jsx, ts, tsx, css, json, text, base64, dataurl, file, binary)`,
200195
)
201196
})
202197

src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import matter from 'gray-matter'
77
import * as esbuild from 'esbuild'
88
import {NodeResolvePlugin} from '@esbuild-plugins/node-resolve'
99
import {globalExternals} from '@fal-works/esbuild-plugin-global-externals'
10+
import {v4 as uuid} from 'uuid'
1011
import dirnameMessedUp from './dirname-messed-up.cjs'
1112

1213
const {readFile, unlink} = fs.promises
@@ -41,7 +42,7 @@ async function bundleMDX(
4142
// extract the frontmatter
4243
const {data: frontmatter} = matter(mdxSource)
4344

44-
const entryPath = path.join(cwd, './_mdx_bundler_entry_point.mdx')
45+
const entryPath = path.join(cwd, `./_mdx_bundler_entry_point-${uuid()}.mdx`)
4546

4647
/** @type Record<string, string> */
4748
const absoluteFiles = {[entryPath]: mdxSource}

0 commit comments

Comments
 (0)