添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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

Hi, great work on this!

After updating from 0.8.7 to 0.9.1 i get the following error when building:

failed to load config from vite.config.js
error when starting dev server:
Error: Dynamic require of "path" is not supported
    at file:///src/webapp/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-aliases/dist/index.mjs:30:9
    at node_modules/fast-glob/out/utils/path.js (file:///src/webapp/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-aliases/dist/index.mjs:131:16)
    at __require2 (file:///src/webapp/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-aliases/dist/index.mjs:36:50)
    at node_modules/fast-glob/out/utils/index.js (file:///src/webapp/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-aliases/dist/index.mjs:3235:16)
    at __require2 (file:///src/webapp/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-aliases/dist/index.mjs:36:50)
    at node_modules/fast-glob/out/managers/tasks.js (file:///src/webapp/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-aliases/dist/index.mjs:3253:17)
    at __require2 (file:///src/webapp/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-aliases/dist/index.mjs:36:50)
    at node_modules/fast-glob/out/index.js (file:///src/webapp/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-aliases/dist/index.mjs:5167:23)
    at __require2 (file:///src/webapp/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-aliases/dist/index.mjs:36:50)
    at file:///src/webapp/node_modules/.pnpm/[email protected][email protected]/node_modules/vite-aliases/dist/index.mjs:5240:32
 ELIFECYCLE  Command failed with exit code 1.

working: working.zip
repro: repro.zip

using versions
vite: 2.8.6
node: v17.1.0
pnpm: 6.23.2
npm: 8.1.2

@ivarlovlie Would you be able to provide a reproduction?
Also it would be good to know what node version you are using.
Ive tried to replicate the issue with node 16, npm 8 and vite 2.8.6 and dont run into the same Issue!

repro: repro.zip

I am able to build the repro project when i'm on 0.8.7 of vite-aliases, and unable on 0.9.1.

using versions
node: v17.1.0
pnpm: 6.23.2
npm: 8.1.2

I did a test reproduction in this git repo here:
https://github.com/Subwaytime/vite-aliases-test - edit: not needed anymore

It works flawlessly for me, even tried pnpm.

used pnpm: 6.32.3 (latest)

Cant seem to replicate your Issue. What operating system do you use?

I am using Ubuntu 20.04
Tried with node 16.14.0 but still see the same behaviour using vite-aliases 0.9.1.

Cant seem to replicate your Issue

You're not able to reproduce on the project inside of repro.zip?

After further troubleshooting i managed to build with 0.9.1 by removing type: "module" from package.json. Would it be worth looking into why type: "module" worked with 0.8.7 but not with 0.9.1?.

new-repro.zip

tim-kilian, cwilvx, MarcMunhoz, PrimalCat-Real, EdmilsonFerreiraF, G-Linares, AbdElRahmanMostafa1, elmoren, aronft, monosolar, and 18 more reacted with thumbs up emoji EdmilsonFerreiraF, juliakroger, aussenseiter, leodotcloud, ojako, Pelliccia96, tiagobfaustino, shaheerkn, and minikdev reacted with heart emoji EdmilsonFerreiraF, monosolar, aussenseiter, Pelliccia96, indymaat, minikdev, and Murad1893 reacted with rocket emoji All reactions

Just wanted to say I was getting the same error. Tried going down to 16.14.2 of node and that didn't help. Was on 9.1 but upgraded to 9.2 of vite-aliases and it built. Is this then resolved? Below was the error I was getting if it were to be any help if it's not resolved.

error when starting dev server:
Error: Dynamic require of "path" is not supported
at file:///Users/jessecoble/Repositories/PLAYGROUND/SvelteTemplate/SvelteTemplate/node_modules/vite-aliases/dist/index.mjs:30:9
at node_modules/fast-glob/out/utils/path.js (file:///Users/jessecoble/Repositories/PLAYGROUND/SvelteTemplate/SvelteTemplate/node_modules/vite-aliases/dist/index.mjs:131:16)
at __require2 (file:///Users/jessecoble/Repositories/PLAYGROUND/SvelteTemplate/SvelteTemplate/node_modules/vite-aliases/dist/index.mjs:36:50)
at node_modules/fast-glob/out/utils/index.js (file:///Users/jessecoble/Repositories/PLAYGROUND/SvelteTemplate/SvelteTemplate/node_modules/vite-aliases/dist/index.mjs:3235:16)
at __require2 (file:///Users/jessecoble/Repositories/PLAYGROUND/SvelteTemplate/SvelteTemplate/node_modules/vite-aliases/dist/index.mjs:36:50)
at node_modules/fast-glob/out/managers/tasks.js (file:///Users/jessecoble/Repositories/PLAYGROUND/SvelteTemplate/SvelteTemplate/node_modules/vite-aliases/dist/index.mjs:3253:17)
at __require2 (file:///Users/jessecoble/Repositories/PLAYGROUND/SvelteTemplate/SvelteTemplate/node_modules/vite-aliases/dist/index.mjs:36:50)
at node_modules/fast-glob/out/index.js (file:///Users/jessecoble/Repositories/PLAYGROUND/SvelteTemplate/SvelteTemplate/node_modules/vite-aliases/dist/index.mjs:5167:23)
at __require2 (file:///Users/jessecoble/Repositories/PLAYGROUND/SvelteTemplate/SvelteTemplate/node_modules/vite-aliases/dist/index.mjs:36:50)
at file:///Users/jessecoble/Repositories/PLAYGROUND/SvelteTemplate/SvelteTemplate/node_modules/vite-aliases/dist/index.mjs:5240:32

I'm sorry, i actually downgraded to 8.6 of vite-aliases and that worked. I thought that's what I did but my package.json was showing 9.2 for some reason. I stopped and tried to restart the dev server and got the error again. Tried downgrading to 8.6 again, this time it "took" and showed as 8.6 in package.json and was then able to start the dev server. Sorry for the confusion.

Ya. I tried taking it out and just got a bunch more errors. I don't know a whole lot about bundlers, config files etc. Just been learning more about them, especially Vite. There's something special about it that just really intrigues me. I guess its just the pure speed of it and how it can build 100x faster than other bundlers. Anyways, if you need anymore info let me know. Be happy to help.

vite and vite-aliases should both run without "type":"module". If you dont have any other plugins installed that need this configuration specifically!

Ive been working on th ESM support, but it will still take some time, as other Bugfixes need to get implemented first!

sorry for the late response

quick note: due to covid i wasnt able to work on this again, but now i can finally continue!

also, i will bundle this with the upcoming major changes from vite 3!

Add the below code in the 'vite.config.ts' or 'vite.config.js' file:

import { resolve } from 'path';
export default defineConfig({
  resolve: {
    alias: {
      '@': resolve(__dirname, './src')
  plugins: [vue()],
  fscheidt, Reikooters, Sergio-Pedrosa, CRYPTO-GENIK, v-andrade, martinx, daria-z, jsadeli, babinslava, redaali1997, and 11 more reacted with thumbs up emoji
  MisterZurg, struginskij, and andreandyp reacted with rocket emoji
    All reactions
  iuliiast, macp-auditsight, struginskij, Glideh, yensubldg, leoplaw, kiwenlau, RidouanTaibi, kevinwaxi, maiconfz, and 14 more reacted with thumbs up emoji
  aussenseiter and juangarcia12we reacted with laugh emoji
  MoySantanaV, LiammCodes, and myDisconnect reacted with hooray emoji
  dineshdsv3, aussenseiter, aloisiovilasboas, struginskij, zsoltjanes, TzuH-Hsu, MoySantanaV, Hachiko03, and alemangui reacted with heart emoji
  mw-muwo, struginskij, and MoySantanaV reacted with rocket emoji
    All reactions