Understanding module bindings
# Domenic Denicola (11 years ago)
The exported values change, and any bindings created by import statements now reference the new values.
# Brian Donovan (11 years ago)
As Domenic said, your examples should be fine as long as the assignment happens in the module that originally exports the bindings. This is how I’ve implemented it with the new transpiler rewrite: square/es6-module-transpiler/tree/rewrite-with-bindings/test/examples/bindings
Note that this would be an error:
import { a } from './a';
export { a };
a++;
I was just looking to clarify how module bindings behave.
What happens in the following example:
export var template = '...template string...'; export var counter = 0; export var obj = {}; template += 'post-script'; counter++; obj = { new: 'obj' };
Do these throw an error? Does the exported value change, or does the internal value change only?
It would be good to make sure we're implementing this right.