@@ -14,21 +14,21 @@ import {test} from 'uvu'
1414import * as assert from 'uvu/assert'
1515import esbuild from 'esbuild'
1616import React from 'react'
17- import { renderToStaticMarkup } from 'react-dom/server.js '
17+ import { renderToStaticMarkup } from 'react-dom/server'
1818import esbuildMdx from '../index.js'
1919
2020test ( '@mdx-js/esbuild' , async ( ) => {
2121 // MDX.
2222 await fs . writeFile (
23- new URL ( './ esbuild.mdx' , import . meta. url ) ,
23+ new URL ( 'esbuild.mdx' , import . meta. url ) ,
2424 'export const Message = () => <>World!</>\n\n# Hello, <Message />'
2525 )
2626
2727 await esbuild . build ( {
2828 bundle : true ,
2929 define : { 'process.env.NODE_ENV' : '"development"' } ,
30- entryPoints : [ fileURLToPath ( new URL ( './ esbuild.mdx' , import . meta. url ) ) ] ,
31- outfile : fileURLToPath ( new URL ( './ esbuild.js' , import . meta. url ) ) ,
30+ entryPoints : [ fileURLToPath ( new URL ( 'esbuild.mdx' , import . meta. url ) ) ] ,
31+ outfile : fileURLToPath ( new URL ( 'esbuild.js' , import . meta. url ) ) ,
3232 format : 'esm' ,
3333 plugins : [ esbuildMdx ( ) ]
3434 } )
@@ -44,30 +44,30 @@ test('@mdx-js/esbuild', async () => {
4444 'should compile'
4545 )
4646
47- await fs . unlink ( new URL ( './ esbuild.mdx' , import . meta. url ) )
48- await fs . unlink ( new URL ( './ esbuild.js' , import . meta. url ) )
47+ await fs . unlink ( new URL ( 'esbuild.mdx' , import . meta. url ) )
48+ await fs . unlink ( new URL ( 'esbuild.js' , import . meta. url ) )
4949
5050 // Resolve directory.
5151 await fs . writeFile (
52- new URL ( './ esbuild-resolve.mdx' , import . meta. url ) ,
52+ new URL ( 'esbuild-resolve.mdx' , import . meta. url ) ,
5353 'import Content from "./folder/file.mdx"\n\n<Content/>'
5454 )
55- await fs . mkdir ( new URL ( './ folder' , import . meta. url ) )
55+ await fs . mkdir ( new URL ( 'folder' , import . meta. url ) )
5656 await fs . writeFile (
57- new URL ( './ folder/file.mdx' , import . meta. url ) ,
57+ new URL ( 'folder/file.mdx' , import . meta. url ) ,
5858 'import {data} from "./file.js"\n\n{data}'
5959 )
6060 await fs . writeFile (
61- new URL ( './ folder/file.js' , import . meta. url ) ,
61+ new URL ( 'folder/file.js' , import . meta. url ) ,
6262 'export const data = 0.1'
6363 )
6464 await esbuild . build ( {
6565 bundle : true ,
6666 define : { 'process.env.NODE_ENV' : '"development"' } ,
6767 entryPoints : [
68- fileURLToPath ( new URL ( './ esbuild-resolve.mdx' , import . meta. url ) )
68+ fileURLToPath ( new URL ( 'esbuild-resolve.mdx' , import . meta. url ) )
6969 ] ,
70- outfile : fileURLToPath ( new URL ( './ esbuild-resolve.js' , import . meta. url ) ) ,
70+ outfile : fileURLToPath ( new URL ( 'esbuild-resolve.js' , import . meta. url ) ) ,
7171 format : 'esm' ,
7272 plugins : [ esbuildMdx ( ) ]
7373 } )
@@ -82,18 +82,18 @@ test('@mdx-js/esbuild', async () => {
8282 'should compile'
8383 )
8484
85- await fs . unlink ( new URL ( './ esbuild-resolve.mdx' , import . meta. url ) )
86- await fs . unlink ( new URL ( './ esbuild-resolve.js' , import . meta. url ) )
87- await fs . rmdir ( new URL ( './ folder/' , import . meta. url ) , { recursive : true } )
85+ await fs . unlink ( new URL ( 'esbuild-resolve.mdx' , import . meta. url ) )
86+ await fs . unlink ( new URL ( 'esbuild-resolve.js' , import . meta. url ) )
87+ await fs . rmdir ( new URL ( 'folder/' , import . meta. url ) , { recursive : true } )
8888
8989 // Markdown.
90- await fs . writeFile ( new URL ( './ esbuild.md' , import . meta. url ) , '\ta' )
90+ await fs . writeFile ( new URL ( 'esbuild.md' , import . meta. url ) , '\ta' )
9191
9292 await esbuild . build ( {
9393 bundle : true ,
9494 define : { 'process.env.NODE_ENV' : '"development"' } ,
95- entryPoints : [ fileURLToPath ( new URL ( './ esbuild.md' , import . meta. url ) ) ] ,
96- outfile : fileURLToPath ( new URL ( './ esbuild-md.js' , import . meta. url ) ) ,
95+ entryPoints : [ fileURLToPath ( new URL ( 'esbuild.md' , import . meta. url ) ) ] ,
96+ outfile : fileURLToPath ( new URL ( 'esbuild-md.js' , import . meta. url ) ) ,
9797 format : 'esm' ,
9898 plugins : [ esbuildMdx ( ) ]
9999 } )
@@ -108,17 +108,17 @@ test('@mdx-js/esbuild', async () => {
108108 'should compile `.md`'
109109 )
110110
111- await fs . unlink ( new URL ( './ esbuild.md' , import . meta. url ) )
112- await fs . unlink ( new URL ( './ esbuild-md.js' , import . meta. url ) )
111+ await fs . unlink ( new URL ( 'esbuild.md' , import . meta. url ) )
112+ await fs . unlink ( new URL ( 'esbuild-md.js' , import . meta. url ) )
113113
114114 // `.md` as MDX extension.
115- await fs . writeFile ( new URL ( './ esbuild.md' , import . meta. url ) , '\ta' )
115+ await fs . writeFile ( new URL ( 'esbuild.md' , import . meta. url ) , '\ta' )
116116
117117 await esbuild . build ( {
118118 bundle : true ,
119119 define : { 'process.env.NODE_ENV' : '"development"' } ,
120- entryPoints : [ fileURLToPath ( new URL ( './ esbuild.md' , import . meta. url ) ) ] ,
121- outfile : fileURLToPath ( new URL ( './ esbuild-md-as-mdx.js' , import . meta. url ) ) ,
120+ entryPoints : [ fileURLToPath ( new URL ( 'esbuild.md' , import . meta. url ) ) ] ,
121+ outfile : fileURLToPath ( new URL ( 'esbuild-md-as-mdx.js' , import . meta. url ) ) ,
122122 format : 'esm' ,
123123 plugins : [ esbuildMdx ( { mdExtensions : [ ] , mdxExtensions : [ '.md' ] } ) ]
124124 } )
@@ -133,20 +133,18 @@ test('@mdx-js/esbuild', async () => {
133133 'should compile `.md` as MDX w/ configuration'
134134 )
135135
136- await fs . unlink ( new URL ( './ esbuild.md' , import . meta. url ) )
137- await fs . unlink ( new URL ( './ esbuild-md-as-mdx.js' , import . meta. url ) )
136+ await fs . unlink ( new URL ( 'esbuild.md' , import . meta. url ) )
137+ await fs . unlink ( new URL ( 'esbuild-md-as-mdx.js' , import . meta. url ) )
138138
139139 // File not in `extnames`:
140- await fs . writeFile ( new URL ( './ esbuild.md' , import . meta. url ) , 'a' )
141- await fs . writeFile ( new URL ( './ esbuild.mdx' , import . meta. url ) , 'a' )
140+ await fs . writeFile ( new URL ( 'esbuild.md' , import . meta. url ) , 'a' )
141+ await fs . writeFile ( new URL ( 'esbuild.mdx' , import . meta. url ) , 'a' )
142142
143143 console . log ( '\nnote: the following error is expected!\n' )
144144 try {
145145 await esbuild . build ( {
146- entryPoints : [ fileURLToPath ( new URL ( './esbuild.md' , import . meta. url ) ) ] ,
147- outfile : fileURLToPath (
148- new URL ( './esbuild-md-as-mdx.js' , import . meta. url )
149- ) ,
146+ entryPoints : [ fileURLToPath ( new URL ( 'esbuild.md' , import . meta. url ) ) ] ,
147+ outfile : fileURLToPath ( new URL ( 'esbuild-md-as-mdx.js' , import . meta. url ) ) ,
150148 plugins : [ esbuildMdx ( { format : 'mdx' } ) ]
151149 } )
152150 assert . unreachable ( )
@@ -161,10 +159,8 @@ test('@mdx-js/esbuild', async () => {
161159 console . log ( '\nnote: the following error is expected!\n' )
162160 try {
163161 await esbuild . build ( {
164- entryPoints : [ fileURLToPath ( new URL ( './esbuild.mdx' , import . meta. url ) ) ] ,
165- outfile : fileURLToPath (
166- new URL ( './esbuild-md-as-mdx.js' , import . meta. url )
167- ) ,
162+ entryPoints : [ fileURLToPath ( new URL ( 'esbuild.mdx' , import . meta. url ) ) ] ,
163+ outfile : fileURLToPath ( new URL ( 'esbuild-md-as-mdx.js' , import . meta. url ) ) ,
168164 plugins : [ esbuildMdx ( { format : 'md' } ) ]
169165 } )
170166 assert . unreachable ( )
@@ -176,22 +172,22 @@ test('@mdx-js/esbuild', async () => {
176172 )
177173 }
178174
179- await fs . unlink ( new URL ( './ esbuild.md' , import . meta. url ) )
180- await fs . unlink ( new URL ( './ esbuild.mdx' , import . meta. url ) )
175+ await fs . unlink ( new URL ( 'esbuild.md' , import . meta. url ) )
176+ await fs . unlink ( new URL ( 'esbuild.mdx' , import . meta. url ) )
181177
182178 console . log ( '\nnote: the following errors and warnings are expected!\n' )
183179
184180 await fs . writeFile (
185- new URL ( './ esbuild-broken.mdx' , import . meta. url ) ,
181+ new URL ( 'esbuild-broken.mdx' , import . meta. url ) ,
186182 'asd <https://example.com>?'
187183 )
188184
189185 try {
190186 await esbuild . build ( {
191187 entryPoints : [
192- fileURLToPath ( new URL ( './ esbuild-broken.mdx' , import . meta. url ) )
188+ fileURLToPath ( new URL ( 'esbuild-broken.mdx' , import . meta. url ) )
193189 ] ,
194- outfile : fileURLToPath ( new URL ( './ esbuild.js' , import . meta. url ) ) ,
190+ outfile : fileURLToPath ( new URL ( 'esbuild.js' , import . meta. url ) ) ,
195191 plugins : [ esbuildMdx ( ) ]
196192 } )
197193 assert . unreachable ( 'esbuild should throw' )
@@ -219,19 +215,19 @@ test('@mdx-js/esbuild', async () => {
219215 )
220216 }
221217
222- await fs . unlink ( new URL ( './ esbuild-broken.mdx' , import . meta. url ) )
218+ await fs . unlink ( new URL ( 'esbuild-broken.mdx' , import . meta. url ) )
223219
224220 await fs . writeFile (
225- new URL ( './ esbuild-warnings.mdx' , import . meta. url ) ,
221+ new URL ( 'esbuild-warnings.mdx' , import . meta. url ) ,
226222 'export const Message = () => <>World!</>\n\n# Hello, <Message />'
227223 )
228224
229225 try {
230226 await esbuild . build ( {
231227 entryPoints : [
232- fileURLToPath ( new URL ( './ esbuild-warnings.mdx' , import . meta. url ) )
228+ fileURLToPath ( new URL ( 'esbuild-warnings.mdx' , import . meta. url ) )
233229 ] ,
234- outfile : fileURLToPath ( new URL ( './ esbuild-warnings.js' , import . meta. url ) ) ,
230+ outfile : fileURLToPath ( new URL ( 'esbuild-warnings.js' , import . meta. url ) ) ,
235231 format : 'esm' ,
236232 plugins : [
237233 esbuildMdx ( {
@@ -386,20 +382,20 @@ test('@mdx-js/esbuild', async () => {
386382 )
387383 }
388384
389- await fs . unlink ( new URL ( './ esbuild-warnings.mdx' , import . meta. url ) )
385+ await fs . unlink ( new URL ( 'esbuild-warnings.mdx' , import . meta. url ) )
390386
391387 await fs . writeFile (
392- new URL ( './ esbuild-plugin-crash.mdx' , import . meta. url ) ,
388+ new URL ( 'esbuild-plugin-crash.mdx' , import . meta. url ) ,
393389 '# hi'
394390 )
395391
396392 try {
397393 await esbuild . build ( {
398394 entryPoints : [
399- fileURLToPath ( new URL ( './ esbuild-plugin-crash.mdx' , import . meta. url ) )
395+ fileURLToPath ( new URL ( 'esbuild-plugin-crash.mdx' , import . meta. url ) )
400396 ] ,
401397 outfile : fileURLToPath (
402- new URL ( './ esbuild-plugin-crash.js' , import . meta. url )
398+ new URL ( 'esbuild-plugin-crash.js' , import . meta. url )
403399 ) ,
404400 format : 'esm' ,
405401 plugins : [
@@ -449,25 +445,25 @@ test('@mdx-js/esbuild', async () => {
449445 )
450446 }
451447
452- await fs . unlink ( new URL ( './ esbuild-plugin-crash.mdx' , import . meta. url ) )
448+ await fs . unlink ( new URL ( 'esbuild-plugin-crash.mdx' , import . meta. url ) )
453449
454450 console . log ( '\nnote: the preceding errors and warnings are expected!\n' )
455451
456452 /** @type {(contents: string) => import('esbuild').Plugin } */
457453 const inlinePlugin = ( contents ) => ( {
458454 name : 'inline plugin' ,
459- setup : ( build ) => {
455+ setup ( build ) {
460456 build . onResolve ( { filter : / e s b u i l d \. m d x / } , ( ) => ( {
461- path : fileURLToPath ( new URL ( './ esbuild.mdx' , import . meta. url ) ) ,
457+ path : fileURLToPath ( new URL ( 'esbuild.mdx' , import . meta. url ) ) ,
462458 pluginData : { contents}
463459 } ) )
464460 }
465461 } )
466462
467463 await esbuild . build ( {
468- entryPoints : [ fileURLToPath ( new URL ( './ esbuild.mdx' , import . meta. url ) ) ] ,
464+ entryPoints : [ fileURLToPath ( new URL ( 'esbuild.mdx' , import . meta. url ) ) ] ,
469465 outfile : fileURLToPath (
470- new URL ( './ esbuild-compile-from-memory.js' , import . meta. url )
466+ new URL ( 'esbuild-compile-from-memory.js' , import . meta. url )
471467 ) ,
472468 plugins : [ inlinePlugin ( `# Test` ) , esbuildMdx ( ) ] ,
473469 define : { 'process.env.NODE_ENV' : '"development"' } ,
@@ -485,12 +481,12 @@ test('@mdx-js/esbuild', async () => {
485481 'should compile from `pluginData.content`'
486482 )
487483
488- await fs . unlink ( new URL ( './ esbuild-compile-from-memory.js' , import . meta. url ) )
484+ await fs . unlink ( new URL ( 'esbuild-compile-from-memory.js' , import . meta. url ) )
489485
490486 await esbuild . build ( {
491- entryPoints : [ fileURLToPath ( new URL ( './ esbuild.mdx' , import . meta. url ) ) ] ,
487+ entryPoints : [ fileURLToPath ( new URL ( 'esbuild.mdx' , import . meta. url ) ) ] ,
492488 outfile : fileURLToPath (
493- new URL ( './ esbuild-compile-from-memory-empty.js' , import . meta. url )
489+ new URL ( 'esbuild-compile-from-memory-empty.js' , import . meta. url )
494490 ) ,
495491 plugins : [ inlinePlugin ( `` ) , esbuildMdx ( ) ] ,
496492 define : { 'process.env.NODE_ENV' : '"development"' } ,
@@ -509,21 +505,21 @@ test('@mdx-js/esbuild', async () => {
509505 )
510506
511507 await fs . unlink (
512- new URL ( './ esbuild-compile-from-memory-empty.js' , import . meta. url )
508+ new URL ( 'esbuild-compile-from-memory-empty.js' , import . meta. url )
513509 )
514510
515511 // Remote markdown.
516512 await fs . writeFile (
517- new URL ( './ esbuild-with-remote-md.mdx' , import . meta. url ) ,
513+ new URL ( 'esbuild-with-remote-md.mdx' , import . meta. url ) ,
518514 'import Content from "https://raw.githubusercontent.com/mdx-js/mdx/main/packages/esbuild/test/files/md-file.md"\n\n<Content />'
519515 )
520516
521517 await esbuild . build ( {
522518 entryPoints : [
523- fileURLToPath ( new URL ( './ esbuild-with-remote-md.mdx' , import . meta. url ) )
519+ fileURLToPath ( new URL ( 'esbuild-with-remote-md.mdx' , import . meta. url ) )
524520 ] ,
525521 outfile : fileURLToPath (
526- new URL ( './ esbuild-with-remote-md.js' , import . meta. url )
522+ new URL ( 'esbuild-with-remote-md.js' , import . meta. url )
527523 ) ,
528524 bundle : true ,
529525 define : { 'process.env.NODE_ENV' : '"development"' } ,
@@ -541,21 +537,21 @@ test('@mdx-js/esbuild', async () => {
541537 'should compile remote markdown files w/ `allowDangerousRemoteMdx`'
542538 )
543539
544- await fs . unlink ( new URL ( './ esbuild-with-remote-md.mdx' , import . meta. url ) )
545- await fs . unlink ( new URL ( './ esbuild-with-remote-md.js' , import . meta. url ) )
540+ await fs . unlink ( new URL ( 'esbuild-with-remote-md.mdx' , import . meta. url ) )
541+ await fs . unlink ( new URL ( 'esbuild-with-remote-md.js' , import . meta. url ) )
546542
547543 // Remote MDX importing more markdown.
548544 await fs . writeFile (
549- new URL ( './ esbuild-with-remote-mdx.mdx' , import . meta. url ) ,
545+ new URL ( 'esbuild-with-remote-mdx.mdx' , import . meta. url ) ,
550546 'import Content from "https://raw.githubusercontent.com/mdx-js/mdx/main/packages/esbuild/test/files/mdx-file-importing-markdown.mdx"\n\n<Content />'
551547 )
552548
553549 await esbuild . build ( {
554550 entryPoints : [
555- fileURLToPath ( new URL ( './ esbuild-with-remote-mdx.mdx' , import . meta. url ) )
551+ fileURLToPath ( new URL ( 'esbuild-with-remote-mdx.mdx' , import . meta. url ) )
556552 ] ,
557553 outfile : fileURLToPath (
558- new URL ( './ esbuild-with-remote-mdx.js' , import . meta. url )
554+ new URL ( 'esbuild-with-remote-mdx.js' , import . meta. url )
559555 ) ,
560556 bundle : true ,
561557 define : { 'process.env.NODE_ENV' : '"development"' } ,
@@ -573,8 +569,8 @@ test('@mdx-js/esbuild', async () => {
573569 'should compile remote MD, MDX, and JS files w/ `allowDangerousRemoteMdx`'
574570 )
575571
576- await fs . unlink ( new URL ( './ esbuild-with-remote-mdx.mdx' , import . meta. url ) )
577- await fs . unlink ( new URL ( './ esbuild-with-remote-mdx.js' , import . meta. url ) )
572+ await fs . unlink ( new URL ( 'esbuild-with-remote-mdx.mdx' , import . meta. url ) )
573+ await fs . unlink ( new URL ( 'esbuild-with-remote-mdx.js' , import . meta. url ) )
578574} )
579575
580576test . run ( )
0 commit comments