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

Does not work with namespaces #34

Open
rottmann opened this issue Sep 23, 2024 · 3 comments
Open

Does not work with namespaces #34

rottmann opened this issue Sep 23, 2024 · 3 comments

Comments

@rottmann
Copy link

rottmann commented Sep 23, 2024

Cause the generated code looks like

<link rel="stylesheet" crossorigin href="../../style-D00TQ7QE.css">
<script type="module" crossorigin src="../../index.php-DlZYXcJR.js"></script>
<link rel="modulepreload" crossorigin href="../../modulepreload-polyfill-B5Qt9EMX.js">
<?php
namespace MyNamespace;

namespace must be first.

A workaround could be a placeholder, that we can set within our code and vite-plugin-php insert (if it exists) at the placeholder.

And it would be great, if it could work with vites root parameter.

@donnikitos
Copy link
Owner

Hi @rottmann,

thanks for the submission!
The Vite root-parameter is already earmarked in issue #10 - so it's on it's way :)


Can you clarify your use case with the namespace?
As far as I understand you have a namespaced module with imports in it and during trasnpilation the imports are being set to the top of the file?

@rottmann
Copy link
Author

One case is a custom autoloader, that uses namespaces. Pages / Layouts are in namespaces and the autoloader include the e.g. the layouts within pages. Only direct includes work currently.

A download page could only be done, if it includes only the download functionality (header() ...) and is not allowed to respond a custom page, e.g. if the user is not allowed to download.
For this, it must be used a redirect workaround, that redirects to a separate page (because of the js/css headers).
So we need a download.php and a download-not-allowed.php with the HTML response.

@donnikitos donnikitos changed the title Does now work with namespaces Does not work with namespaces Sep 25, 2024
@donnikitos
Copy link
Owner

@rottmann I've published a new version with a new script evaluation method.
This should fix most unexpected issues...
Please try [email protected] and check if the error still persists.

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