Follow

Has the javascript ecosystem solved ES6 modules "just working" everywhere yet?

Or am I going to have to play bundler games? sigh

· · Web · 1 · 1 · 1
@brion works in some browsers but, turns out you don't actually want that. it's webpack time

ok so it looks like if i do modern webpack with modern es6 module syntax, and want to use 'import' to pull in my GLSL shaders from files during build into strings in the output JS, I have to use raw-loader -- this results in source JS that can't be run directly because the import path would not be valid in a browser.

Or, I can write my own build script that embeds text into .json, and import those.

Either way, life is terrible.

@brion Life is beautiful, you get to actually build that thing ;)

Ok, not too bad so far (but haven't yet tried building).

This *should* pull my jpegxr codec module from node_modules, and the shaders from text files as strings:

import jpegxr from 'jpegxr';
import vertexShader from 'raw-loader!./tonemap.vsh';
import fragmentShader from 'raw-loader!./tonemap.fsh';

Resulting bundle should itself have no external file dependencies, and should be freely re-bundle-able...

The only reason this is looking easy is because I embedded the WebAssembly binary into the JS of the codec module, though. ;)

Sign in to participate in the conversation
Mastodon for Tech Folks

This Mastodon instance is for people interested in technology. Discussions aren't limited to technology, because tech folks shouldn't be limited to technology either!