-
Notifications
You must be signed in to change notification settings - Fork 153
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
TypeError: laravel is not a function #187
Comments
I have the same issue. lrfahmi and I are following the same path. We both first had an error that the svelte module could not be resolved because our package.json file was missing "type": "module". We added that, and then this error was the result. My vite.config.js: import { defineConfig } from "vite"; export default defineConfig({ resolve: { css: { My package.json: { |
@fpolli I see you're using
That's not a valid setting for a Laravel app. Please revert that and try again. @lrfahmi are you also using that? |
If I do that, then I go right back to my first error, where NPM cannot resolve the svelte-vite-plugin. It sounds like you are saying that Svelte cannot be used in a Laravel app. At least with Vite. This is all very confusing. Does this mean that Laravel is a CommonJS environment and not ES6? |
I have no idea about all that sorry. I just can confirm that you cannot use |
Basically because a Laravel app is... well an app, not a module. |
Thank you. That is helpful information. As you can tell, I am just learning all of this. Direct support for Svelte as you have for React and Vue would be cool. |
Gonna close this for now but feel free to still reply @lrfahmi |
I'll try to start with the configuration details:
Is not working. When package.json is added
If without
Temporary SolutionIt can take hours or even days to solve the problem. Conflicts between one package and another. The solution I reverted to the previous running version of the packages with vite 3.0.0. Change package.json to rollback packages version:
The laravel application is up and back to work. Hope this solution helps, until there is an official solution from the publishers. Cheers. |
Thank you for this! I hope the developers do solve it, because each side seems to think there is no problem. |
Looks to me like Vite and Svelte have moved on to ES6 modules and Laravel
is still in CommonJS land.
…On Fri, Dec 16, 2022 at 10:37 AM Fahmi L. Ramdhani ***@***.***> wrote:
I'll try to start with the configuration details:
# package.json
...
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
***@***.***/inertia": "^0.11.1",
***@***.***/inertia-svelte": "^0.8.0",
***@***.***/progress": "^0.2.7",
***@***.***/vite-plugin-svelte": "^2.0.2",
***@***.***/forms": "^0.5.3",
"autoprefixer": "^10.4.13",
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.2",
"lodash": "^4.17.19",
"postcss": "^8.4.20",
"svelte": "^3.55.0",
"tailwindcss": "^3.2.4",
"vite": "^4.0.0"
},
...
# vite.config.js
import { defineConfig } from 'vite';
import { svelte } from ***@***.***/vite-plugin-svelte';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: ['resources/js/app.js'],
refresh: true,
}),
svelte({
prebundleSvelteLibraries: true,
}),
],
optimizeDeps: {
include: [
***@***.***/inertia',
***@***.***/inertia-svelte',
***@***.***/inertia-progress',
]
}
});
Is not working. When package.json is added "type": "module", i get an
error message:
failed to load config from /home/fahmi/repos/..../laravel/vite.config.js
error when starting dev server:
TypeError: laravel is not a function
If without "type": "module", i get an error message:
✘ [ERROR] [plugin externalize-deps] Failed to resolve entry for package ***@***.***/vite-plugin-svelte". The package may have incorrect main/module/exports specified in its package.json: No known conditions for "." entry in ***@***.***/vite-plugin-svelte" package
node_modules/esbuild/lib/main.js:1355:27:
1355 │ let result = await callback({
Temporary Solution
It can take hours or even days to solve the problem. Conflicts between one
package and another. The solution I reverted to the previous running
version of the packages with vite 3.0.0.
Change package.json to rollback packages version:
1. ***@***.***/vite-plugin-svelte": "^1.4.0"
2. "laravel-vite-plugin": "^0.7.1"
3. "vite": "^3.0.0"
...
"private": true,
"scripts": {
"dev": "vite",
"build": "vite build"
},
"devDependencies": {
***@***.***/inertia": "^0.11.1",
***@***.***/inertia-svelte": "^0.8.0",
***@***.***/progress": "^0.2.7",
***@***.***/vite-plugin-svelte": "^1.4.0",
***@***.***/forms": "^0.5.3",
"autoprefixer": "^10.4.13",
"axios": "^1.1.2",
"laravel-vite-plugin": "^0.7.1",
"lodash": "^4.17.19",
"postcss": "^8.4.20",
"svelte": "^3.55.0",
"tailwindcss": "^3.2.4",
"vite": "^3.0.0"
},
...
The laravel application is up and back to work. Hope this solution helps,
until there is an official solution from the publishers. Cheers.
—
Reply to this email directly, view it on GitHub
<#187 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABJXG7TO7SRIMZJISYCWWHTWNSZHLANCNFSM6AAAAAATAONNVI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Frederick R. Polli
***@***.***
Additional contact information available upon request
|
I have exactly the same issue here since updated to Vite 4.
More here, and also mentioned in this issue And from what I understand We are currently forced to stay with Vite 3. |
I've made a note to look into this when I'm back at work next week. |
As a temporary fix, you may specify We will investigate a fix for this. e.g. import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
import { svelte } from '@sveltejs/vite-plugin-svelte';
export default defineConfig({
plugins: [
laravel.default({
input: ['resources/js/app.js'],
refresh: true,
}),
svelte({
//
}),
],
}); |
WIP PR to address this issue: #189 |
Gonna close this and we can continue the conversation in the PR. |
Description:
I'm using Laravel 9.x along with Inertia (Svelte). There is an issue when running
npm run dev
: error when starting dev server:TypeError: laravel is not a function.
Steps To Reproduce:
Bellow is vite.config.js
The text was updated successfully, but these errors were encountered: