question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature request: local context for entrypoints

See original GitHub issue

🙋 feature request

local or browser-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 neither type="module" nor nomodule attributes.

😯 Current Behavior

The HTML page fails to load both the type="module" script and the nomodule 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 use type="module" and nomodule, just use the “fallback” script with type="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.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
NothingEverWorkscommented, Jul 18, 2022

This is duplicated by https://github.com/parcel-bundler/parcel/issues/7959. Commenting here because this is still open.

I would like support for bundling for the file:/// procotol, but I actually prefer the possible solution from the duplicate feature request; a CLI flag. The advantage of a CLI flag is that it allows a project to be bundled for different usecases (e.g. for file:/// protocol or for a web server) without changing any configuration.

I’ve created a workaround in the following repo. https://github.com/NothingEverWorks/parcel-local-html The workaround fixes the script tags after bundling by using the nomodule index.js output from the differential bundling, that already works with the file:/// procotol and supports synchronous import!

1reaction
tedbyroncommented, Jan 20, 2022

Did I understand you correctly that you want to view/run the output from Parcel via a file:// url without a werbserver?

Yes

Read more comments on GitHub >

github_iconTop Results From Across the Web

Entry Points — Dioptra 0.0.0 documentation - NIST Pages
The term entry point, in the context of running experiment jobs, refers to executable scripts or binaries that are paired with information about...
Read more >
Best practices for writing Dockerfiles - Docker Documentation
ENTRYPOINT. The best use for ENTRYPOINT is to set the image's main command, allowing that image to be run as though it was...
Read more >
Advanced configuration - GitLab Docs
Absolute path to a directory where builds are stored in the context of the selected executor. For example, locally, Docker, or SSH. cache_dir,...
Read more >
Routers - Traefik Labs documentation
If not specified, HTTP routers will accept requests from all defined entry points. If you want to limit the router scope to a...
Read more >
Keeping request context over the function call stack - Medium
The SSENSE ecosystem is composed of multiple applications and services, each of which may have multiple entry points or execution triggers.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found