// allocate a private field key
private #constructedHere;
export let create = () => {
return {
// cannot be used in computed properties
// #constructedHere is not a variable with a reified value
#constructedHere: true
};
console.log('hi'); | |
module.exports = 123; |
{ | |
async resolve() { | |
const dep = vm.Module('export let a = 0; ({set a(v) {a = v;} get a() {return a;}})'); | |
dep.onEvaluated((ns, reflect) => { | |
setInterval(() => reflect.a++, 1000); | |
}); | |
return dep; | |
} | |
} |
<!doctype html> | |
<html> | |
<style> | |
.screenreader-only { | |
position: absolute; | |
display: block; | |
left: -1px; | |
top: -1px; | |
width: 1px; | |
height: 1px; |
ESM do not have a way to setup modules that are aliases of other modules
ESM in in browsers cannot reliably use export * from
to act as an alias since it may alter the shape of the namespace they are importing, nor can they use HTTP redirects which are treated as new module records.
Adding default
to the list of exports from export * from
has been revisted and rejected.
I have to take extra effort to use export *
reliably as a means to create pass through modules.
Typically involving resolving, fetching, and parsing the source text of a dependency outside of VM control.
This can be seen in projects where I am invoking http/file access and parsing to AST to figure out if the module being delegated to has a default.
In addition using export *
is also not suitable to be used
** bikeshed **
fs.getFile(url)
- https://developer.mozilla.org/en-US/docs/Web/API/File
Can be used by loaders/servers if they wish to request information about the file's MIME as file.type
.
It will get the .type
by checking the context for the current MIME DB, falling back to the globally MIME DB.
import {ran} from 'b'; | |
let ready; | |
// this function can be saved to a variable, but blows up if `b` has not run yet | |
export function onlyAvailableIfBHasRun() { | |
ready; | |
ran; | |
// ... | |
}; |
class LockingActor { | |
constructor(buffer, offset, bytes) { | |
let needle = offset; | |
// if our lock isn't aligned | |
if (needle % 4 !== 0) { | |
// align | |
needle += 4 - (needle % 4); | |
} | |
this.state = new Transitions(buffer, needle); | |
needle += this.lock.byteLength; |
Various command line applications use an Interpreter Directive to define how they should be run.
#! js -m foo
#! node foo
There has been no progress in working towards a single cohesive story for path resolution between Servers and Web. Notable discussion points relevant to this are:
- Node has a path searching algorithm.
- Web has not been able to gather support for any of the following:
- Build tooling as part of UX expectations (lack of interest)
- Smarter static web servers (lack of interest). PoC example at https://github.com/bmeck/esm-http-server
- A
resolve
based hook. (interest shown with desire for ~6 months of userland experimentation)