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

[Issue] Plugin is not working #44

Closed
qlaffont opened this issue Dec 26, 2023 · 12 comments
Closed

[Issue] Plugin is not working #44

qlaffont opened this issue Dec 26, 2023 · 12 comments

Comments

@qlaffont
Copy link

Hi,
I'm using vinxi with solid start template and currently this plugin is not working : https://github.com/nguyenbatranvan/vite-multiple-assets
If needed I can create a repro.
Regards

@nksaraf
Copy link
Owner

nksaraf commented Dec 27, 2023

Yeah this one is tricky. Vinxi does the server and static assets slightly differently from vite. We have this concept of routers and each public directory is just another router. So the default solid-start app config is approximately this:

import { serverFunctions } from "@vinxi/server-functions/plugin";
import { createApp } from "vinxi";
import solid from "vite-plugin-solid";

export function defineConfig(options) { 
    return createApp({
		routers: [
			{
				name: "public",
				mode: "static",
				dir: "./public",
				base: "/",
			},
			{
				name: "client",
				mode: "build",
				handler: "./app/client.tsx",
				target: "browser",
				plugins: () => [serverFunctions.client(), solid({ ssr: true })],
				base: "/_build",
			},
			{
				name: "ssr",
				mode: "handler",
				handler: "./app/server.tsx",
				target: "server",
				plugins: () => [solid({ ssr: true })],
			},
			serverFunctions.router(),
		],
	});
}

What you can do to add another router to the mix is:

import { defineConfig } from '@solidjs/start/config'
const config = defineConfig({ ... })

config.addRouter({
  mode: "static",
  name: "solid-start-cmp",
  dir: "node_modules/solid-start-cmp/public",
  base: "/",
});

export default config;

@nksaraf nksaraf closed this as completed Dec 27, 2023
@qlaffont
Copy link
Author

Now I have this error :

demo-ventes git:(solid-migration) ✗ pnpm build

> demo-ventes@ build /home/quentin/Documents/dev/madeformed/demo-ventes
> vinxi build

Error: Cannot find module './plugins/decorate-exports.js'
Require stack:
- /home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/@vinxi+plugin-directives@0.0.52_vinxi@0.0.56/node_modules/@vinxi/plugin-directives/index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Function.resolve (node:internal/modules/cjs/helpers:125:19)
    at _resolve (/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/dist/jiti.js:1:250334)
    at jiti (/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/dist/jiti.js:1:252917)
    at /home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/@vinxi+plugin-directives@0.0.52_vinxi@0.0.56/node_modules/@vinxi/plugin-directives/index.js:2:24
    at evalModule (/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/dist/jiti.js:1:255614)
    at jiti (/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/dist/jiti.js:1:253542)
    at /home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/@vinxi+server-functions@0.0.53_vinxi@0.0.56/node_modules/@vinxi/server-functions/client.js:1:186
    at evalModule (/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/dist/jiti.js:1:255614)
    at jiti (/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/dist/jiti.js:1:253542)
    at /home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/@vinxi+server-functions@0.0.53_vinxi@0.0.56/node_modules/@vinxi/server-functions/plugin.js:3:15
    at evalModule (/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/dist/jiti.js:1:255614)
    at jiti (/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/dist/jiti.js:1:253542)
    at /home/quentin/Documents/dev/madeformed/demo-ventes/app.config.js:1:213
    at evalModule (/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/dist/jiti.js:1:255614)
    at Object.jiti (/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/jiti@1.20.0/node_modules/jiti/dist/jiti.js:1:253542)
    at resolveConfig (file:///home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/c12@1.5.1/node_modules/c12/dist/index.mjs:288:24)
    at loadConfig (file:///home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/c12@1.5.1/node_modules/c12/dist/index.mjs:116:40)
    at loadApp (file:///home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/vinxi@0.0.56_@types+node@18.18.8_rollup@3.29.4_sass@1.69.5_terser@5.24.0/node_modules/vinxi/lib/load-app.js:16:31)
    at Object.run (file:///home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/vinxi@0.0.56_@types+node@18.18.8_rollup@3.29.4_sass@1.69.5_terser@5.24.0/node_modules/vinxi/bin/cli.mjs:176:23)
    at async runCommand (file:///home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/citty@0.1.5/node_modules/citty/dist/index.mjs:316:16)
    at async runCommand (file:///home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/citty@0.1.5/node_modules/citty/dist/index.mjs:307:11)
    at async runMain (file:///home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/citty@0.1.5/node_modules/citty/dist/index.mjs:441:7) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/@vinxi+plugin-directives@0.0.52_vinxi@0.0.56/node_modules/@vinxi/plugin-directives/index.js'
  ]
}


┌────────────────────────────┐
│ ⚙  Building your app...    │
└────────────────────────────┘

 ERROR  Cannot read properties of undefined (reading 'hooks')                                                                                                  6:31:47 AM

  at createBuild (node_modules/.pnpm/vinxi@0.0.56_@types+node@18.18.8_rollup@3.29.4_sass@1.69.5_terser@5.24.0/node_modules/vinxi/lib/build.js:39:12)
  at Object.run (node_modules/.pnpm/vinxi@0.0.56_@types+node@18.18.8_rollup@3.29.4_sass@1.69.5_terser@5.24.0/node_modules/vinxi/bin/cli.mjs:179:11)
  at async runCommand (node_modules/.pnpm/citty@0.1.5/node_modules/citty/dist/index.mjs:316:16)
  at async runCommand (node_modules/.pnpm/citty@0.1.5/node_modules/citty/dist/index.mjs:307:11)
  at async runMain (node_modules/.pnpm/citty@0.1.5/node_modules/citty/dist/index.mjs:441:7) 



 ERROR  Cannot read properties of undefined (reading 'hooks')                                                                                                  6:31:47 AM

 ELIFECYCLE  Command failed with exit code 1.
 
 ```

@qlaffont
Copy link
Author

@nksaraf is it possible to reopen it ?

@nksaraf
Copy link
Owner

nksaraf commented Dec 28, 2023

Ohh this was a dumb mistake where I didn't include plugin folder in the files for the directives plugin. Should be working in latest versions of these packages. i.e 0.0.57

@qlaffont
Copy link
Author

 demo-ventes git:(solid-migration) ✗ pnpm build

> demo-ventes@ build /home/quentin/Documents/dev/madeformed/demo-ventes
> vinxi build

vinxi 0.0.59
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.


┌────────────────────────────┐
│ ⚙  Building your app...    │
└────────────────────────────┘


┌──────────────────────────────────┐
│ 📦 Compiling client router...    │
└──────────────────────────────────┘
vinxi building router client in build mode
[ '#vinxi/handler/client' ]
vite v4.5.0 building for production...
✓ 6 modules transformed.
✓ built in 127ms
[vite]: Rollup failed to resolve import "#start/app" from "/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/@solidjs+start@0.4.2_rollup@3.29.4_solid-js@1.8.7_vinxi@0.0.59_vite@5.0.10/node_modules/@solidjs/start/client/StartClient.tsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`

[11:38:07 AM]  ERROR  [vite]: Rollup failed to resolve import "#start/app" from "/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/@solidjs+start@0.4.2_rollup@3.29.4_solid-js@1.8.7_vinxi@0.0.59_vite@5.0.10/node_modules/@solidjs/start/client/StartClient.tsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external

  This is most likely unintended because it can break your application at runtime.
  If you do want to externalize this module explicitly add it to
  build.rollupOptions.external
  at viteWarn (node_modules/.pnpm/vite@4.5.0_@types+node@18.18.8_sass@1.69.5_terser@5.24.0/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:48216:27)
  at onRollupWarning (node_modules/.pnpm/vite@4.5.0_@types+node@18.18.8_sass@1.69.5_terser@5.24.0/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:48248:9)
  at onwarn (node_modules/.pnpm/vite@4.5.0_@types+node@18.18.8_sass@1.69.5_terser@5.24.0/node_modules/vite/dist/node/chunks/dep-bb8a8339.js:47976:13)
  at node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:24276:13
  at Object.logger [as onLog] (node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:25950:9)
  at ModuleLoader.handleInvalidResolvedId (node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:24862:26)
  at node_modules/.pnpm/rollup@3.29.4/node_modules/rollup/dist/es/shared/node-entry.js:24822:26 



[11:38:07 AM]  ERROR  [vite]: Rollup failed to resolve import "#start/app" from "/home/quentin/Documents/dev/madeformed/demo-ventes/node_modules/.pnpm/@solidjs+start@0.4.2_rollup@3.29.4_solid-js@1.8.7_vinxi@0.0.59_vite@5.0.10/node_modules/@solidjs/start/client/StartClient.tsx".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external

 ELIFECYCLE  Command failed with exit code 1.
 ```
 @nksaraf 

@qlaffont
Copy link
Author

I don't have such import

@nksaraf
Copy link
Owner

nksaraf commented Dec 29, 2023

Can I get a repro of this? I am not sure why this is happening? Could be a bug

@nksaraf nksaraf reopened this Dec 29, 2023
@qlaffont
Copy link
Author

nksaraf added a commit that referenced this issue Dec 30, 2023
…atures fix (fixes [Issue] Plugin is not working #44)
nksaraf added a commit that referenced this issue Dec 30, 2023
feat: add process.env.MINIFY support for build, add preserveEntrySignatures fix (fixes [Issue] Plugin is not working #44)
@nksaraf nksaraf closed this as completed Dec 30, 2023
@nksaraf
Copy link
Owner

nksaraf commented Dec 30, 2023

nksaraf/test-cmp@5529e8f should have the latest commit with the fixes. I think there was some miscommunication with the first fix. solid-start's defineConfig is already creating the main thing for you. You had to add the addRouter part to the bottom of vite.config.js itself.

@qlaffont
Copy link
Author

qlaffont commented Jan 2, 2024

Yes it working ! Thanks !

@qlaffont
Copy link
Author

qlaffont commented Jan 2, 2024

@nksaraf I have an issue with my vite plugin "unplugin-imagemin/vite" can you check please.

It's the same repo but you need to rebase.

> test-cmp@ build /home/quentin/Documents/dev/test/test-cmp
> vinxi build

vinxi 0.0.60
start {
  appRoot: './src',
  ssr: false,
  islands: false,
  server: { base: undefined },
  solid: {}
}
vinxi Found vite.config.js with app config


┌────────────────────────────┐
│ ⚙  Building your app...    │
└────────────────────────────┘
removing /home/quentin/Documents/dev/test/test-cmp/.vinxi/build/ssr
removing /home/quentin/Documents/dev/test/test-cmp/.vinxi/build/client
removing /home/quentin/Documents/dev/test/test-cmp/.vinxi/build/server-fns


┌───────────────────────────────┐
│ 📦 Compiling ssr router...    │
└───────────────────────────────┘
vinxi building router ssr in handler mode
vite v4.5.0 building SSR bundle for production...
"createHandler" is imported from external module "h3" but never used in "node_modules/.pnpm/vinxi@0.0.60_rollup@3.29.4_terser@5.26.0/node_modules/vinxi/runtime/server.js".
✓ 40 modules transformed.
.vinxi/build/ssr/manifest.json                   1.40 kB
.vinxi/build/ssr/assets/index-fb87c914.css      46.63 kB
.vinxi/build/ssr/_...404_.js                     0.74 kB
.vinxi/build/ssr/about.js                        0.96 kB
.vinxi/build/ssr/assets/components-86ea9901.js   1.20 kB
.vinxi/build/ssr/index.js                        3.61 kB
.vinxi/build/ssr/ssr.js                          6.50 kB


[unplugin-imagemin] 📦 📦 Process start with Mode sharp
✓ built in 743ms
✔ build done                                                                                                                                                  7:01:06 AM


┌──────────────────────────────────┐
│ 📦 Compiling client router...    │
└──────────────────────────────────┘
vinxi building router client in build mode
[
  '#vinxi/handler/client',
  '/home/quentin/Documents/dev/test/test-cmp/src/routes/[...404].tsx?pick=default&pick=$css',
  '/home/quentin/Documents/dev/test/test-cmp/src/routes/about.tsx?pick=default&pick=$css',
  '/home/quentin/Documents/dev/test/test-cmp/src/routes/index.tsx?pick=default&pick=$css'
]
plugin-legacy overrode 'build.target'. You should pass 'targets' as an option to this plugin with the list of legacy browsers to support instead.
vite v4.5.0 building for production...
virtual:#vinxi/handler/client (1:106) "default" is not exported by "src/entry-client.tsx", imported by "virtual:#vinxi/handler/client".
✓ 115 modules transformed.
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

[Error: ENOENT: no such file or directory, open '/home/quentin/Documents/dev/test/test-cmp/.vinxi/build/client/_build/assets/_...404_-legacy-ca63b2ec.js'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/quentin/Documents/dev/test/test-cmp/.vinxi/build/client/_build/assets/_...404_-legacy-ca63b2ec.js'
}

Node.js v18.17.1
 ELIFECYCLE  Command failed with exit code 1.```

@qlaffont
Copy link
Author

qlaffont commented Jan 8, 2024

@nksaraf any update ?
I have update to vinxi 0.1.1 bug still present.

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

2 participants