Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Path error #4

Closed
liu-lihao opened this issue May 2, 2021 · 7 comments
Closed

Path error #4

liu-lihao opened this issue May 2, 2021 · 7 comments

Comments

@liu-lihao
Copy link
Contributor

import { createApp } from 'vue'
import Index from '/src/options/index.vue'

const app = createApp(Index)
app.mount('#root')
 // The same is true for other onloads
 build.onLoad({filter: /\.vue$/, namespace: "vue"}, async (args) => {
     // args.path === '/src/options/index.vue'
    //  The original code will report an error
    //  no such file or directory, open '/src/options/index.vue'
    const content = await fs.promises.readFile(args.path, "utf8");
    // temporary solution
    const content = await fs.promises.readFile(path.join(process.cwd(), args.path), "utf8");
    // In fact, we should consider relative path, absolute path and alias,
    // but we can't get other information through args

    // ...
 }
@liu-lihao
Copy link
Contributor Author

Sorry, I didn't notice that onResolve could handle path. I'll add pr

@egoist
Copy link
Owner

egoist commented May 6, 2021

we can't assume that /src is the same as $cwd/src, because they're not, /src is an absolute path.

@liu-lihao
Copy link
Contributor Author

Sorry, you're right. I've looked at the document about absWorkingDir again. I'll revise it here

@liu-lihao
Copy link
Contributor Author

updated

@Akryum
Copy link

Akryum commented Jun 25, 2021

Have this issue with a simple relative import:

import SomeComponent from './SomeComponent.vue'

I get:

> src/index.ts:2:26: error: [plugin: vue] ENOENT: no such file or directory, open './SomeComponent.vue'
     2 │ import SomeComponent from './SomeComponent.vue'
       ╵                           ~~~~~~~~~~~~~~~~~~~~~
   node_modules/esbuild-plugin-vue/dist/index.js:29:12: note: This error came from the "onLoad" callback registered here
    29 │       build.onLoad({filter: /\.vue$/, namespace: "vue"}, async (args) => {
       ╵             ~~~~~~
    at setup (/home/akryum/Projects/demos/vue-devtools-plugin/node_modules/esbuild-plugin-vue/dist/index.js:29:13)
    at handlePlugins (/home/akryum/Projects/demos/vue-devtools-plugin/node_modules/esbuild/lib/main.js:736:23)
    at Object.buildOrServe (/home/akryum/Projects/demos/vue-devtools-plugin/node_modules/esbuild/lib/main.js:1024:7)
    at /home/akryum/Projects/demos/vue-devtools-plugin/node_modules/esbuild/lib/main.js:1748:17
    at new Promise (<anonymous>)
    at Object.build (/home/akryum/Projects/demos/vue-devtools-plugin/node_modules/esbuild/lib/main.js:1747:14)
    at Object.build (/home/akryum/Projects/demos/vue-devtools-plugin/node_modules/esbuild/lib/main.js:1623:51)
    at Object.<anonymous> (/home/akryum/Projects/demos/vue-devtools-plugin/esbuild.js:22:9)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)

@Akryum
Copy link

Akryum commented Jun 25, 2021

I can confirm #5 fixes the issue for me

@egoist
Copy link
Owner

egoist commented Jun 26, 2021

Should work now with v0.1.3

@egoist egoist closed this as completed Jun 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants