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 32
32
* Callback called by Rollup and Vite to transform.
33
33
* @param {string } value
34
34
* File contents.
35
- * @param {string } path
36
- * File path .
35
+ * @param {string } id
36
+ * Module ID .
37
37
* @returns {Promise<SourceDescription | undefined> }
38
38
* Result.
39
39
*
@@ -80,14 +80,15 @@ export function rollup(options) {
80
80
...rest
81
81
} )
82
82
} ,
83
- async transform ( value , path ) {
83
+ async transform ( value , id ) {
84
84
if ( ! formatAwareProcessors ) {
85
85
formatAwareProcessors = createFormatAwareProcessors ( {
86
86
SourceMapGenerator,
87
87
...rest
88
88
} )
89
89
}
90
90
91
+ const [ path ] = id . split ( '?' )
91
92
const file = new VFile ( { path, value} )
92
93
93
94
if (
Original file line number Diff line number Diff line change @@ -101,4 +101,27 @@ test('@mdx-js/rollup', async function (t) {
101
101
assert . doesNotMatch ( code , / j s x s ? \( / )
102
102
assert . match ( code , / j s x D E V \( / )
103
103
} )
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
+ } )
104
127
} )
You can’t perform that action at this time.
0 commit comments