@@ -22,13 +22,49 @@ test('@mdx-js/loader', async () => {
22
22
// Setup.
23
23
const base = new URL ( '.' , import . meta. url )
24
24
25
+ await fs . writeFile (
26
+ new URL ( 'webpack.mdx' , base ) ,
27
+ '# Hello, {<Message />'
28
+ )
29
+
30
+ // Errors.
31
+ const failedResult = await promisify ( webpack ) ( {
32
+ // @ts -expect-error To do: webpack types miss support for `context`.
33
+ context : fileURLToPath ( base ) ,
34
+ entry : './webpack.mdx' ,
35
+ mode : 'none' ,
36
+ module : {
37
+ rules : [
38
+ {
39
+ test : / \. m d x $ / ,
40
+ use : [ fileURLToPath ( new URL ( '../index.cjs' , import . meta. url ) ) ]
41
+ }
42
+ ]
43
+ } ,
44
+ output : {
45
+ path : fileURLToPath ( base ) ,
46
+ filename : 'react.cjs' ,
47
+ libraryTarget : 'commonjs'
48
+ }
49
+ } )
50
+
51
+ const error = failedResult ?. toJson ( ) ?. errors ?. [ 0 ]
52
+
53
+ assert . ok ( error ) ;
54
+ assert . equal (
55
+ error . message ,
56
+ `Module build failed (from ../index.cjs):
57
+ webpack.mdx:1:22: Unexpected end of file in expression, expected a corresponding closing brace for \`{\`` ,
58
+ 'received expected error message'
59
+ )
60
+
25
61
await fs . writeFile (
26
62
new URL ( 'webpack.mdx' , base ) ,
27
63
'export const Message = () => <>World!</>\n\n# Hello, <Message />'
28
64
)
29
65
30
66
// React.
31
- await promisify ( webpack ) ( {
67
+ const reactBuild = await promisify ( webpack ) ( {
32
68
// @ts -expect-error To do: webpack types miss support for `context`.
33
69
context : fileURLToPath ( base ) ,
34
70
entry : './webpack.mdx' ,
@@ -48,6 +84,8 @@ test('@mdx-js/loader', async () => {
48
84
}
49
85
} )
50
86
87
+ assert . not . ok ( reactBuild ?. hasErrors ( ) )
88
+
51
89
// One for ESM loading CJS, one for webpack.
52
90
const modReact = /** @type {{default: {default: MDXContent}} } */ (
53
91
// @ts -expect-error file is dynamically generated
@@ -63,7 +101,7 @@ test('@mdx-js/loader', async () => {
63
101
await fs . unlink ( new URL ( 'react.cjs' , base ) )
64
102
65
103
// Preact and source maps
66
- await promisify ( webpack ) ( {
104
+ const preactBuild = await promisify ( webpack ) ( {
67
105
// @ts -expect-error To do: webpack types miss support for `context`.
68
106
context : fileURLToPath ( base ) ,
69
107
entry : './webpack.mdx' ,
@@ -89,6 +127,9 @@ test('@mdx-js/loader', async () => {
89
127
}
90
128
} )
91
129
130
+ assert . not . ok ( preactBuild ?. hasErrors ( ) )
131
+
132
+
92
133
// One for ESM loading CJS, one for webpack.
93
134
const modPreact = /** @type {{default: {default: PreactComponent}} } */ (
94
135
// @ts -expect-error file is dynamically generated.
@@ -110,7 +151,7 @@ test('@mdx-js/loader', async () => {
110
151
await fs . unlink ( new URL ( 'preact.cjs' , base ) )
111
152
112
153
// Vue.
113
- await promisify ( webpack ) ( {
154
+ const vueBuild = await promisify ( webpack ) ( {
114
155
// @ts -expect-error To do: webpack types miss support for `context`.
115
156
context : fileURLToPath ( base ) ,
116
157
entry : './webpack.mdx' ,
@@ -140,6 +181,8 @@ test('@mdx-js/loader', async () => {
140
181
}
141
182
} )
142
183
184
+ assert . not . ok ( vueBuild ?. hasErrors ( ) )
185
+
143
186
// One for ESM loading CJS, one for webpack.
144
187
const modVue = /** @type {{default: {default: VueComponent}} } */ (
145
188
// @ts -expect-error file is dynamically generated
1 commit comments
vercel[bot] commentedon Sep 8, 2022
Successfully deployed to the following URLs:
mdx – ./
mdx-git-main-mdx.vercel.app
mdxjs.com
mdx-mdx.vercel.app
v2.mdxjs.com