fix(static-module-record): Fix export name as
MODIFY
packages/static-module-record/src/babelPlugin.js
packages/static-module-record/src/babelPlugin.js
@@ -446,7 +446,7 @@ function makeModulePlugins(options) {
const ident = topLevelIsOnce[importFrom]
? h.HIDDEN_ONCE
: h.HIDDEN_LIVE;
- myUpdaterSources.push(`${ident}[${JSON.stringify(importFrom)}]`);
+ myUpdaterSources.push(`${ident}[${JSON.stringify(importTo)}]`);
}
if (source || myUpdaterSources) {

MODIFY
packages/static-module-record/test/test-static-module-record.js
packages/static-module-record/test/test-static-module-record.js
@@ -60,6 +60,7 @@ test('export default', t => {
function initialize(t, source, options = {}) {
const { endowments, imports = new Map() } = options;
const record = new StaticModuleRecord(source);
+ t.log(record.__syncModuleProgram__);
const liveUpdaters = {};
const onceUpdaters = {};
const namespace = {};
@@ -573,6 +574,32 @@ test('export names', t => {
t.is(namespace.tomatoes, undefined);
});
+test('export name as', t => {
+ const { namespace } = initialize(
+ t,
+ `export { peaches as stonefruit, oranges as citrus } from 'module';`,
+ {
+ imports: new Map([
+ [
+ 'module',
+ new Map([
+ ['peaches', 'stonefruit'],
+ ['oranges', 'citrus'],
+ ['tomatoes', 'nightshades'],
+ ]),
+ ],
+ ]),
+ },
+ );
+ t.log(namespace);
+ t.is(namespace.stonefruit, 'stonefruit');
+ t.is(namespace.citrus, 'citrus');
+ t.is(namespace.peaches, undefined);
+ t.is(namespace.oranges, undefined);
+ t.is(namespace.tomatoes, undefined);
+ t.is(namespace.nightshades, undefined);
+});
+
test('export all', t => {
const { namespace } = initialize(t, `export * from 'module';`, {
imports: new Map([

fix(static-module-record): Fix export name as