Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a PR against a default LiveView (0.15.7) that removes all use of Node/NPM/Webpack.
There's no bundling of assets in any way -- we just copy /assets directly into /priv/static (see hacky_watcher.sh). We're relying on the browser's ESM support to be able to load javascript modules directly. We also don't do any CSS preprocessing - the .scss file phoenix ships with is valid css, so I just renamed it to cut a preprocessing step.
Normally, a bare module import (e.g.
import "morphdom"
) won't work in the browser since it doesn't know where to import the module from. Luckily there's a proposal for import-maps which map module names to locations. This amounts to a poor man's package.json running in the browser! Seeimport-map.json
for an example.Chromium supports import-maps, and we vendor a polyfill to get it to work on other browsers, reducing our requirement to browsers that support ESM.
In the example I vendor the phoenix dependencies and rely on rely SkyPack as a CDN for other modules we're using. SkyPack also let's me refer to
package@version
This PR lets you run without any node in development. I think it's missing a few things to be used for your production builds:
Options to bundle javacript for production without node