@@ -3,7 +3,7 @@ import { posix as Path } from 'path'
3
3
import { createJSModule } from './tools'
4
4
import { createSFCModule , vueVersion } from './createSFCModule'
5
5
6
- import { ModuleExport , ModuleHandler , PathHandlers , Options } from './types'
6
+ import { ModuleExport , ModuleHandler , PathHandlers , Options , File } from './types'
7
7
8
8
/**
9
9
* the version of the library (process.env.VERSION is set by webpack, at compile-time)
@@ -117,11 +117,20 @@ export async function loadModule(path : string, options_ : Options = throwNotDef
117
117
loadModule,
118
118
} = options_ ;
119
119
120
+
121
+ // TBD: remove this in v1.0
122
+ async function normalizedGetFile ( path : string ) : Promise < File > {
123
+
124
+ const res = await getFile ( path ) ;
125
+ return typeof res === 'object' ? res : { content : res , extname : pathHandlers . extname ( path ) } ;
126
+ }
127
+
120
128
const options = {
121
129
moduleCache,
122
130
additionalModuleHandlers,
123
131
pathHandlers,
124
- ...options_
132
+ ...options_ ,
133
+ getFile : normalizedGetFile ,
125
134
} ;
126
135
127
136
if ( path in moduleCache ) {
@@ -142,9 +151,7 @@ export async function loadModule(path : string, options_ : Options = throwNotDef
142
151
return moduleCache [ path ] = module ;
143
152
}
144
153
145
- const res = await getFile ( path ) ;
146
-
147
- const file = typeof res === 'object' ? res : { content : res , extname : pathHandlers . extname ( path ) } ;
154
+ const file = await options . getFile ( path ) ;
148
155
149
156
const moduleHandlers = { ...defaultModuleHandlers , ...additionalModuleHandlers } ;
150
157
0 commit comments