lhapaipai / vite-bundle

Integration with your Symfony app & Vite

Home Page:https://symfony-vite.pentatrion.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot access offset of type string on string

drazik opened this issue · comments

I just updated the bundle from v3.3.1 to v4.0.2 on my project with composer require 'pentatrion/vite-bundle:^4.0'. But now I get the following error:

image

I reduced my vite config to the bare minimum:

import { defineConfig } from "vite"
import symfonyPlugin from "vite-plugin-symfony"
import react from "@vitejs/plugin-react"
import { fileURLToPath, URL } from "node:url"

export default defineConfig({
	plugins: [react(), symfonyPlugin()],
	build: {
		rollupOptions: {
			input: {
				"generation-add": "./assets/js/pages/generation/add/index.tsx",
			},
		},
	},
	server: {
		origin: "http://localhost:3000",
		port: 3000,
		host: "0.0.0.0",
	},
	resolve: {
		alias: {
			app: fileURLToPath(new URL("./assets/js", import.meta.url)),
		},
	},
})

Here is how I call the vite_entry_link_tags and vite_entry_script_tags functions (templates/base.html.twig file):

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="initial-scale=1, width=device-width" />
        {% block stylesheets %}
          {{ vite_entry_link_tags("generation-add") }}
        {% endblock %}

        {% block javascripts %}
            <script type="text/javascript">
                window.pageProps = {{ (pageProps ?? '{}')|raw }};
            </script>
            {{ vite_entry_script_tags("generation-add", { dependency: "react" }) }}
        {% endblock %}
    </head>
    <body>
        {% block body %}<div id="app"></div>{% endblock %}
    </body>
</html>

I also tried v4.0.1 and v4.0.0 and still got the same issue. v3.3.1 works fine. Did I do something wrong on the upgrade process? Is there any upgrade guide?

hi @drazik, have you update the vite-plugin-symfony ? vite-bundle v4.0.x need vite-plugin-symfony v4.0.x (v4 change the entrypoints.json file)

It fixes the issue! Thanks a lot @lhapaipai ❤️

you're welcome. before it was not easy to know which version to use between the 2 packages, now it's documented here : https://symfony-vite.pentatrion.com/fr/extra/compatibility.html