-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Feature request: local context for entrypoints #7583
Comments
Did I understand you correctly that you want to view/run the output from Parcel via a |
Yes |
@mischnic differential bundling gives a fallback bundle and that works if I just remove the |
This is duplicated by #7959. Commenting here because this is still open. I would like support for bundling for the I've created a workaround in the following repo. https://github.com/NothingEverWorks/parcel-local-html |
That would be great 👍 Thanks a lot @NothingEverWorks for the inspiration. I had to adapt a the script for my use case but I can finally have a full automatic pipeline for the game GUI without having to manually modify the file. Do you mind it if I package your idea in a new repository that -should- cover most use cases for the game and maintain it ? I had to google way to much to find this ! |
Parcel removing Parcel sells itself as the works-out-of-the-box alternative to webpack and then does stuff like this where it completely subverts basic expectations such as leaving |
Top level await: #4028 Leaving |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 14 days if no further activity occurs. |
This issue still persists, can it be reopened? I'm hitting the lack of apparent support for local-filesystem JavaScript due to magic that was being done before but isn't now. At the least, the migration document could do more to explain how to change things for this use-case.
The hint is useless because I run into CORS problems with running a local file. A workaround I found is to change to a more raw form of import. var PaletteProfiles;
import('./modules/PaletteProfiles.js').then((x) => { PaletteProfiles = x.default; }) This worked for importing data. When dealing with a class, I did not have success in shipping the class outside of the Beforeimport SaveData from './modules/SaveData';
var saveContainer = new SaveData(localStorage); Aftervar saveContainer;
import('./modules/SaveData.js').then((x) => { saveContainer = new x.default(localStorage); }) For classes that needed instantiation later and multiple instances, this was trickier, as I had to make another scaffholding constructor function and store a lambda function off that passed in parameters, so that the scaffholding could use the exported default class. Considering this worked in Parcel 1 with "nice module syntax", it'd be good to have this option, as the local web app was my only target. My workaround still has other issues to figure out and I'm not optimistic that I'll have a clean solution when it's done. |
🙋 feature request
local
orbrowser-local
entrypoint context for environments that load scripts locally.🤔 Expected Behavior
If entrypoint has a
local
context, the script elements in the HTML page output should have neithertype="module"
nornomodule
attributes.😯 Current Behavior
The HTML page fails to load both the
type="module"
script and thenomodule
script. This is because the browser supports JS modules but there is no server serving the JS files, resulting in a CORS error or invalid MIME error.💁 Possible Solution
If entrypoint has
"context": "local"
, don't usetype="module"
andnomodule
, just use the "fallback" script withtype="text/javascript"
attribute on the HTML element.🔦 Context
I have an application that runs on specific hardware using a chromium browser locally and functions similarly to electron - uses an HTML entrypoint and necessary assets are fetched locally.
JS modules are supported by the chromium version but I get the error
Failed to load module script: The server responded with a non-JavaScript MIME type of "". Strict MIME type checking is enforced for module scripts per HTML spec.
because there is no server serving the JS files, they are only being loaded from the filesystem.I've tried using
"context": "electron-renderer"
, but this gives the same HTML output as"context": "browser"
. The only workarounds I could find were manually changing the HTML output and inlining the entire JS bundle (~1MB) which are not optimal.The only similar issue I could find was this discussion.
💻 Examples
Build using parcel using an HTML entrypoint that has a JS script element and try to open the resulting HTML in the browser.
The text was updated successfully, but these errors were encountered: