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

Doesn't work with scripts included from html #1

Open
edemaine opened this issue Jan 11, 2023 · 5 comments
Open

Doesn't work with scripts included from html #1

edemaine opened this issue Jan 11, 2023 · 5 comments
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@edemaine
Copy link

edemaine commented Jan 11, 2023

Chrome gives the error: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "text/coffeescript". Strict MIME type checking is enforced for module scripts per HTML spec.

I believe the filename needs to be mapped to .js (or maybe .jsx depending on whether there is JSX? maybe not)... Here is another plugin which does so.

@edemaine edemaine changed the title Doesn't work in dev mode Doesn't work with scripts included from html Jan 11, 2023
@edemaine
Copy link
Author

The issue here might actually be that the file is included from an .html file, via <script src="filename.coffee">, not that I was running in dev mode. This plugin does some special handling of HTML to make that work without adding ?transform.

@eldarlrd
Copy link

I have the same problem in Development Mode, Firefox gives the error:
Loading module from “http://localhost:5173/main.coffee” was blocked because of a disallowed MIME type (“text/coffeescript”).

The problem no longer persists when built for production.

@bkuri
Copy link
Owner

bkuri commented Sep 8, 2023

Thanks for the report and apologies for not replying earlier.

I'm not entirely sure where to start debugging this… Is it a matter of files not being transpiled on time, or is it due to transpiled files not being placed in the correct path?

I looked at the rollup docs and perhaps this plugin may need to grab onto one of the build hooks in order to force a render at a specific time, but I'm not sure if that's the proper way to look at this problem.

I'm a bit tied up with work at the moment, but I'll see if I can take a closer look at this soon,

@bkuri bkuri self-assigned this Sep 8, 2023
@vokshirg
Copy link

vokshirg commented Sep 24, 2023

I suppose that references to vitejs/vite#9963

upd:
and this one vitejs/vite#3828

@edemaine
Copy link
Author

FWIW, this newer plugin (which uses "unplugin" to work for Vite and lots of other build systems) works much better in this respect (for Civet). Perhaps it could inspire a CoffeeScript plugin? In particular I think the idea is to do transpilation in the load phase. (But see the (short) code for details.)

@bkuri bkuri added bug Something isn't working good first issue Good for newcomers labels Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

4 participants