Skip to content

Commit 48cec74

Browse files
includePaths -> loadPaths and explicit node_modules search (#35)
* includePaths -> loadPaths and explicit node_modules search * Use projectRoot instead of process.cwd directly --------- Co-authored-by: Felipe Martinez <[email protected]>
1 parent 8c6882d commit 48cec74

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/index.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ const vuePlugin = (opts: Options = {}) => <esbuild.Plugin>{
4848

4949
const cache = new AsyncCache(!opts.disableCache);
5050

51+
const projectRoot = process.env.npm_config_local_prefix || process.cwd();
52+
5153
const transforms: Record<string, core.DirectiveTransform> = {};
5254
if (opts.directiveTransforms) {
5355
for (const name in opts.directiveTransforms) {
@@ -269,12 +271,12 @@ const vuePlugin = (opts: Options = {}) => <esbuild.Plugin>{
269271
postcssPlugins: opts.postcss?.plugins,
270272
preprocessLang: style.lang as any,
271273
preprocessOptions: Object.assign({
272-
includePaths: [
273-
path.dirname(args.path)
274+
loadPaths: [
275+
path.dirname(args.path),
276+
path.resolve(projectRoot, "node_modules"),
274277
],
275278
importer: {
276279
findFileUrl(url: string) {
277-
const projectRoot = process.env.npm_config_local_prefix || process.cwd()
278280
const modulePath = path.join(projectRoot, "node_modules", url)
279281

280282
if (fs.existsSync(modulePath)) return pathToFileURL(modulePath)

0 commit comments

Comments
 (0)