Subwaytime / vite-aliases

Alias auto generation for Vite
https://www.npmjs.com/package/vite-aliases
MIT License
210 stars 12 forks source link

0.97 - Can't use vite-aliases #43

Closed tsanyqudsi closed 1 year ago

tsanyqudsi commented 1 year ago

ERROR: [plugin: externalize-deps] Failed to resolve entry for package "vite-aliases". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in "vite-aliases" package

I think you need to change package.json and how tsup compile tho. I'll send you a PR

tsanyqudsi commented 1 year ago

@Subwaytime I will give it to your judgement to close this issue since the more I dig up, I starting to believe that this is an issue with vite-plugin-solid.

The main issue with SolidJS in vite using vite-aliases are :

Generator {
  options: {
    dir: 'src',
    prefix: '@',
    deep: true,
    depth: 1,
    createGlobalAlias: true,
    createLog: false,
    logPath: 'src/logs',
    adjustDuplicates: false,
    useAbsolute: false,
    useConfig: true,
    useIndexes: true,
    useTypescript: true,
    root: '***Omitted***'
  },
  fullPath: '***Omitted***',
  aliases: [],
  directories: Set(0) {},
  paths: {},
  searched: false,
  servermode: 'serve'
}

Your example is working well so I figures it's because of another vite plugins. I haven't check with react but I will later.

I'm using Windows 10 btw, haven't test it on Linux.

Subwaytime commented 1 year ago

Ill have a look! Thanks for the report :)

tsanyqudsi commented 1 year ago

@Subwaytime thanks bro, tbh vite-aliases helping me big time for years before vite 3 came and ruin everything.

And thanks to your plugin, I had an idea to build yet-another-front-end starter kit using solidjs, will sponsor you next month.

nichita-pasecinic commented 1 year ago

Same here

ViteJS version - ^3.1.8

Error Stack trace ``` X [ERROR] [plugin externalize-deps] Failed to resolve entry for package "vite-aliases". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in "vite-aliases" package node_modules/esbuild/lib/main.js:1327:27: 1327 │ let result = await callback({ ╵ ^ at packageEntryFailure (file:///C:/Jivy/exberry/app/trading-ui/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:34841:11) at resolvePackageEntry (file:///C:/Jivy/exberry/app/trading-ui/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:34836:9) at tryNodeResolve (file:///C:/Jivy/exberry/app/trading-ui/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:34584:20) at file:///C:/Jivy/exberry/app/trading-ui/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:63472:44 at requestCallbacks.on-resolve (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:1327:28) at handleRequest (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:697:19) at handleIncomingPacket (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:719:7) at Socket.readFromStdout (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:647:7) at Socket.emit (node:events:513:28) at addChunk (node:internal/streams/readable:315:12) This error came from the "onResolve" callback registered here: node_modules/esbuild/lib/main.js:1251:20: 1251 │ let promise = setup({ ╵ ^ at setup (file:///C:/Jivy/exberry/app/trading-ui/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:63465:27) at handlePlugins (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:1251:21) at buildOrServeImpl (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:942:5) at Object.buildOrServe (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:750:5) at C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:2085:17 at new Promise () at Object.build (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:2084:14) at build (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:1931:51) at bundleConfigFile (file:///C:/Jivy/exberry/app/trading-ui/node_modules/vite/dist/node/chunks/dep-4da11a5e.js:63432:26) The plugin "externalize-deps" was triggered by this import vite.config.ts:3:28: 3 │ import { ViteAliases } from 'vite-aliases'; ╵ ~~~~~~~~~~~~~~ failed to load config from C:\Jivy\exberry\app\trading-ui\vite.config.ts error when starting dev server: Error: Build failed with 1 error: node_modules/esbuild/lib/main.js:1327:27: ERROR: [plugin: externalize-deps] Failed to resolve entry for package "vite-aliases". The package may have incorrect main/module/exports specified i n its package.json: No known conditions for "." entry in "vite-aliases" package at failureErrorWithLog (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:1566:15) at C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:1024:28 at runOnEndCallbacks (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:1438:61) at buildResponseToResult (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:1022:7) at C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:1134:14 at responseCallbacks. (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:671:9) at handleIncomingPacket (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:726:9) at Socket.readFromStdout (C:\Jivy\exberry\app\trading-ui\node_modules\esbuild\lib\main.js:647:7) at Socket.emit (node:events:513:28) at addChunk (node:internal/streams/readable:315:12) ```
monarcode commented 1 year ago

Having this error too

Subwaytime commented 1 year ago

@nichita-pasecinic these look like two different errors, so ill fix them seperately! Thanks for the report

tsanyqudsi commented 1 year ago

@Subwaytime Actually this might have anything to do with no type: module on their package.json as I mentioned on my PR back then.

@monarcode , @nichita-pasecinic do you have those ? Because it will give those errors on your app when you don't have those as mentioned in https://github.com/Subwaytime/vite-aliases/pull/44#issuecomment-1282892495

Subwaytime commented 1 year ago

I will add this also to the readme file, as installation instructions. The ESM move should have been more clear! Sorry about that

monarcode commented 1 year ago

@Subwaytime Actually this might have anything to do with no type: module on their package.json as I mentioned on my PR back then.

@monarcode , @nichita-pasecinic do you have those ? Because it will give those errors on your app when you don't have those as mentioned in #44 (comment)

i removed type: module when installed vite-aliases at first... this is how i get it to work normally..is that the issue?

tsanyqudsi commented 1 year ago

@monarcode most probably, yes.

nichita-pasecinic commented 1 year ago

@Subwaytime , I don't have type defined in my package.json

tsanyqudsi commented 1 year ago

@Subwaytime , I don't have type defined in my package.json

try adding them, You use Vite 3 ? Because I don't think vite-aliases pasca 0.95 support Vite 2 anymore.

monarcode commented 1 year ago

adding "type":"mofule" fixed the issue for me 👍🏽

Subwaytime commented 1 year ago

@nichita-pasecinic i deleted the comment, as thats not part of the conversation. Vite-aliases is meant for bigger projects where having distinct aliases per folder is important for managing and organizing the code base. Having one alias is totally fine but it also just turns your aliases into an entire path.

nichita-pasecinic commented 1 year ago

@Subwaytime you're the boss here 😄

thisVioletHydra commented 1 year ago
yarn run v1.22.19
$ vite
✘ [ERROR] [plugin externalize-deps] Failed to resolve entry for package "vite-aliases". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in "vite-aliases" package

    node_modules/vite/node_modules/esbuild/lib/main.js:1327:27:
      1327 │         let result = await callback({
           ╵                            ^

This error came from the "onResolve" callback registered here:

    node_modules/vite/node_modules/esbuild/lib/main.js:1251:20:
      1251 │       let promise = setup({
           ╵                     ^

  The plugin "externalize-deps" was triggered by this import

    vite.config.ts:17:28:
      17 │ import { ViteAliases } from 'vite-aliases';
         ╵                             ~~~~~~~~~~~~~~
Subwaytime commented 1 year ago

@thisVioletHydra This has already been reported upwards, you need to add "type":"module" to your package.json, as the latest version moved entirely to ESM.

thisVioletHydra commented 1 year ago

its good solution but my postcss crashed if i set type: module 🙃

tsanyqudsi commented 1 year ago

@thisVioletHydra do you have the error report for when your postcss crashed ?

Most probably it has nothing to do with vite-aliases but the implemenation of vite ( https://github.com/vitejs/vite/issues/10192 )

update : Don't use postcss.config.ts since it won't work with vite and esm. maybe you could use postcss.config.mjs instead

tsanyqudsi commented 1 year ago

I will close this issue since it's need to be more specific and the discussion is widening.

mvslan commented 1 year ago

@thisVioletHydra This has already been reported upwards, you need to add "type":"module" to your package.json, as the latest version moved entirely to ESM.

yes,it's useful