File tree Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Expand file tree Collapse file tree 2 files changed +27
-3
lines changed Original file line number Diff line number Diff line change 3232 * Callback called by Rollup and Vite to transform.
3333 * @param {string } value
3434 * File contents.
35- * @param {string } path
36- * File path .
35+ * @param {string } id
36+ * Module ID .
3737 * @returns {Promise<SourceDescription | undefined> }
3838 * Result.
3939 *
@@ -80,14 +80,15 @@ export function rollup(options) {
8080 ...rest
8181 } )
8282 } ,
83- async transform ( value , path ) {
83+ async transform ( value , id ) {
8484 if ( ! formatAwareProcessors ) {
8585 formatAwareProcessors = createFormatAwareProcessors ( {
8686 SourceMapGenerator,
8787 ...rest
8888 } )
8989 }
9090
91+ const [ path ] = id . split ( '?' )
9192 const file = new VFile ( { path, value} )
9293
9394 if (
Original file line number Diff line number Diff line change @@ -101,4 +101,27 @@ test('@mdx-js/rollup', async function (t) {
101101 assert . doesNotMatch ( code , / j s x s ? \( / )
102102 assert . match ( code , / j s x D E V \( / )
103103 } )
104+
105+ await t . test ( 'should handle query parameters in vite' , async ( ) => {
106+ const result = /** @type {Array<RollupOutput> } */ (
107+ await build ( {
108+ build : {
109+ lib : {
110+ entry :
111+ fileURLToPath ( new URL ( 'vite-entry.mdx' , import . meta. url ) ) +
112+ '?query=param' ,
113+ name : 'query'
114+ } ,
115+ write : false
116+ } ,
117+ logLevel : 'silent' ,
118+ plugins : [ rollupMdx ( ) ]
119+ } )
120+ )
121+
122+ const code = result [ 0 ] . output [ 0 ] . code
123+
124+ assert . match ( code , / H e l l o V i t e / )
125+ assert . match ( code , / j s x s ? \( / )
126+ } )
104127} )
You can’t perform that action at this time.
0 commit comments