@@ -37,6 +37,12 @@ async function gatherPartials(ast, schemaDir) {
37
37
// Returning a JSX object is what allows fast refresh to work
38
38
async function load ( source ) {
39
39
const logger = this . getLogger ( '@markdoc/next.js' ) ;
40
+ const resolve = this . getResolve ( {
41
+ // https://webpack.js.org/api/loaders/#thisgetresolve
42
+ extensions : [ '.js' , '.jsx' , '.json' , '.ts' , '.tsx' , '...' ] ,
43
+ preferRelative : true ,
44
+ } ) ;
45
+
40
46
const { mode = 'static' , schemaPath = DEFAULT_SCHEMA_PATH } =
41
47
this . getOptions ( ) || { } ;
42
48
@@ -120,7 +126,7 @@ async function load(source) {
120
126
121
127
async function readDir ( variable ) {
122
128
try {
123
- const module = require . resolve ( path . join ( schemaDir , variable ) ) ;
129
+ const module = await resolve ( schemaDir , variable ) ;
124
130
return `import * as ${ variable } from '${ module } '` ;
125
131
} catch ( error ) {
126
132
return `const ${ variable } = {};` ;
@@ -155,7 +161,7 @@ import yaml from 'js-yaml';
155
161
// renderers is imported separately so Markdoc isn't sent to the client
156
162
import Markdoc, {renderers} from '@markdoc/markdoc'
157
163
158
- import {getSchema} from '${ require . resolve ( './runtime' ) } ';
164
+ import {getSchema} from '${ await resolve ( __dirname , './runtime' ) } ';
159
165
/**
160
166
* Schema is imported like this so end-user's code is compiled using build-in babel/webpack configs.
161
167
* This enables typescript/ESnext support
0 commit comments