Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions packages/rollup/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
* Callback called by Rollup and Vite to transform.
* @param {string} value
* File contents.
* @param {string} path
* File path.
* @param {string} id
* Module ID.
* @returns {Promise<SourceDescription | undefined>}
* Result.
*
Expand Down Expand Up @@ -80,14 +80,15 @@ export function rollup(options) {
...rest
})
},
async transform(value, path) {
async transform(value, id) {
if (!formatAwareProcessors) {
formatAwareProcessors = createFormatAwareProcessors({
SourceMapGenerator,
...rest
})
}

const [path] = id.split('?')
const file = new VFile({path, value})

if (
Expand Down
23 changes: 23 additions & 0 deletions packages/rollup/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,27 @@ test('@mdx-js/rollup', async function (t) {
assert.doesNotMatch(code, /jsxs?\(/)
assert.match(code, /jsxDEV\(/)
})

await t.test('should handle query parameters in vite', async () => {
const result = /** @type {Array<RollupOutput>} */ (
await build({
build: {
lib: {
entry:
fileURLToPath(new URL('vite-entry.mdx', import.meta.url)) +
'?query=param',
name: 'query'
},
write: false
},
logLevel: 'silent',
plugins: [rollupMdx()]
})
)

const code = result[0].output[0].code

assert.match(code, /Hello Vite/)
assert.match(code, /jsxs?\(/)
})
})
Loading