feat(exportAlls): track the export * from 'foo' occurrences
We supply the module specifiers from which we export * as the
second argument to $h_imports.
MODIFY
package-lock.json
package-lock.json
}
},
"@babel/core": {
- "version": "7.5.5",
- "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.5.5.tgz",
- "integrity": "sha512-i4qoSr2KTtce0DmkuuQBV4AuQgGPUcPXMr9L5MyYAtk06z068lQ10a4O009fe5OB/DfNV+h+qqT7ddNV8UnRjg==",
+ "version": "7.7.2",
+ "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.7.2.tgz",
+ "integrity": "sha512-eeD7VEZKfhK1KUXGiyPFettgF3m513f8FoBSWiQ1xTvl1RAopLs42Wp9+Ze911I6H0N9lNqJMDgoZT7gHsipeQ==",
"requires": {
"@babel/code-frame": "^7.5.5",
- "@babel/generator": "^7.5.5",
- "@babel/helpers": "^7.5.5",
- "@babel/parser": "^7.5.5",
- "@babel/template": "^7.4.4",
- "@babel/traverse": "^7.5.5",
- "@babel/types": "^7.5.5",
- "convert-source-map": "^1.1.0",
+ "@babel/generator": "^7.7.2",
+ "@babel/helpers": "^7.7.0",
+ "@babel/parser": "^7.7.2",
+ "@babel/template": "^7.7.0",
+ "@babel/traverse": "^7.7.2",
+ "@babel/types": "^7.7.2",
+ "convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"json5": "^2.1.0",
"lodash": "^4.17.13",
"requires": {
"@babel/highlight": "^7.0.0"
}
- },
- "@babel/generator": {
- "version": "7.5.5",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.5.tgz",
- "integrity": "sha512-ETI/4vyTSxTzGnU2c49XHv2zhExkv9JHLTwDAFz85kmcwuShvYG2H08FwgIguQf4JC75CBnXAUM5PqeF4fj0nQ==",
- "requires": {
- "@babel/types": "^7.5.5",
- "jsesc": "^2.5.1",
- "lodash": "^4.17.13",
- "source-map": "^0.5.0",
- "trim-right": "^1.0.1"
- }
- },
- "@babel/parser": {
- "version": "7.5.5",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz",
- "integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g=="
- },
- "@babel/traverse": {
- "version": "7.5.5",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.5.tgz",
- "integrity": "sha512-MqB0782whsfffYfSjH4TM+LMjrJnhCNEDMDIjeTpl+ASaUvxcjoiVCo/sM1GhS1pHOXYfWVCYneLjMckuUxDaQ==",
- "requires": {
- "@babel/code-frame": "^7.5.5",
- "@babel/generator": "^7.5.5",
- "@babel/helper-function-name": "^7.1.0",
- "@babel/helper-split-export-declaration": "^7.4.4",
- "@babel/parser": "^7.5.5",
- "@babel/types": "^7.5.5",
- "debug": "^4.1.0",
- "globals": "^11.1.0",
- "lodash": "^4.17.13"
- }
}
}
},
}
},
"@babel/helper-function-name": {
- "version": "7.1.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz",
- "integrity": "sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==",
+ "version": "7.7.0",
+ "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.7.0.tgz",
+ "integrity": "sha512-tDsJgMUAP00Ugv8O2aGEua5I2apkaQO7lBGUq1ocwN3G23JE5Dcq0uh3GvFTChPa4b40AWiAsLvCZOA2rdnQ7Q==",
"requires": {
- "@babel/helper-get-function-arity": "^7.0.0",
- "@babel/template": "^7.1.0",
- "@babel/types": "^7.0.0"
+ "@babel/helper-get-function-arity": "^7.7.0",
+ "@babel/template": "^7.7.0",
+ "@babel/types": "^7.7.0"
}
},
"@babel/helper-get-function-arity": {
- "version": "7.0.0",
- "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz",
- "integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==",
+ "version": "7.7.0",
+ "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.7.0.tgz",
+ "integrity": "sha512-tLdojOTz4vWcEnHWHCuPN5P85JLZWbm5Fx5ZsMEMPhF3Uoe3O7awrbM2nQ04bDOUToH/2tH/ezKEOR8zEYzqyw==",
"requires": {
- "@babel/types": "^7.0.0"
+ "@babel/types": "^7.7.0"
}
},
"@babel/helper-split-export-declaration": {
- "version": "7.4.4",
- "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.4.4.tgz",
- "integrity": "sha512-Ro/XkzLf3JFITkW6b+hNxzZ1n5OQ80NvIUdmHspih1XAhtN3vPTuUFT4eQnela+2MaZ5ulH+iyP513KJrxbN7Q==",
+ "version": "7.7.0",
+ "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.7.0.tgz",
+ "integrity": "sha512-HgYSI8rH08neWlAH3CcdkFg9qX9YsZysZI5GD8LjhQib/mM0jGOZOVkoUiiV2Hu978fRtjtsGsW6w0pKHUWtqA==",
"requires": {
- "@babel/types": "^7.4.4"
+ "@babel/types": "^7.7.0"
}
},
"@babel/helpers": {
- "version": "7.5.5",
- "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.5.5.tgz",
- "integrity": "sha512-nRq2BUhxZFnfEn/ciJuhklHvFOqjJUD5wpx+1bxUF2axL9C+v4DE/dmp5sT2dKnpOs4orZWzpAZqlCy8QqE/7g==",
- "requires": {
- "@babel/template": "^7.4.4",
- "@babel/traverse": "^7.5.5",
- "@babel/types": "^7.5.5"
- },
- "dependencies": {
- "@babel/code-frame": {
- "version": "7.5.5",
- "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
- "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
- "requires": {
- "@babel/highlight": "^7.0.0"
- }
- },
- "@babel/generator": {
- "version": "7.5.5",
- "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.5.5.tgz",
- "integrity": "sha512-ETI/4vyTSxTzGnU2c49XHv2zhExkv9JHLTwDAFz85kmcwuShvYG2H08FwgIguQf4JC75CBnXAUM5PqeF4fj0nQ==",
- "requires": {
- "@babel/types": "^7.5.5",
- "jsesc": "^2.5.1",
- "lodash": "^4.17.13",
- "source-map": "^0.5.0",
- "trim-right": "^1.0.1"
- }
- },
- "@babel/parser": {
- "version": "7.5.5",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.5.tgz",
- "integrity": "sha512-E5BN68cqR7dhKan1SfqgPGhQ178bkVKpXTPEXnFJBrEt8/DKRZlybmy+IgYLTeN7tp1R5Ccmbm2rBk17sHYU3g=="
- },
- "@babel/traverse": {
- "version": "7.5.5",
- "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.5.5.tgz",
- "integrity": "sha512-MqB0782whsfffYfSjH4TM+LMjrJnhCNEDMDIjeTpl+ASaUvxcjoiVCo/sM1GhS1pHOXYfWVCYneLjMckuUxDaQ==",
+ "version": "7.7.0",
+ "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.7.0.tgz",
+ "integrity": "sha512-VnNwL4YOhbejHb7x/b5F39Zdg5vIQpUUNzJwx0ww1EcVRt41bbGRZWhAURrfY32T5zTT3qwNOQFWpn+P0i0a2g==",
"requires": {
- "@babel/code-frame": "^7.5.5",
- "@babel/generator": "^7.5.5",
- "@babel/helper-function-name": "^7.1.0",
- "@babel/helper-split-export-declaration": "^7.4.4",
- "@babel/parser": "^7.5.5",
- "@babel/types": "^7.5.5",
- "debug": "^4.1.0",
- "globals": "^11.1.0",
- "lodash": "^4.17.13"
- }
- }
+ "@babel/template": "^7.7.0",
+ "@babel/traverse": "^7.7.0",
+ "@babel/types": "^7.7.0"
}
},
"@babel/highlight": {
}
},
"@babel/parser": {
- "version": "7.5.0",
- "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.5.0.tgz",
- "integrity": "sha512-I5nW8AhGpOXGCCNYGc+p7ExQIBxRFnS2fd/d862bNOKvmoEPjYPcfIjsfdy0ujagYOIYPczKgD9l3FsgTkAzKA=="
+ "version": "7.7.3",
+ "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.7.3.tgz",
+ "integrity": "sha512-bqv+iCo9i+uLVbI0ILzKkvMorqxouI+GbV13ivcARXn9NNEabi2IEz912IgNpT/60BNXac5dgcfjb94NjsF33A=="
},
"@babel/runtime": {
"version": "7.5.4",
}
},
"@babel/template": {
- "version": "7.4.4",
- "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.4.4.tgz",
- "integrity": "sha512-CiGzLN9KgAvgZsnivND7rkA+AeJ9JB0ciPOD4U59GKbQP2iQl+olF1l76kJOupqidozfZ32ghwBEJDhnk9MEcw==",
+ "version": "7.7.0",
+ "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.7.0.tgz",
+ "integrity": "sha512-OKcwSYOW1mhWbnTBgQY5lvg1Fxg+VyfQGjcBduZFljfc044J5iDlnDSfhQ867O17XHiSCxYHUxHg2b7ryitbUQ==",
"requires": {
"@babel/code-frame": "^7.0.0",
- "@babel/parser": "^7.4.4",
- "@babel/types": "^7.4.4"
+ "@babel/parser": "^7.7.0",
+ "@babel/types": "^7.7.0"
}
},
- "@babel/types": {
+ "@babel/traverse": {
+ "version": "7.7.2",
+ "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.7.2.tgz",
+ "integrity": "sha512-TM01cXib2+rgIZrGJOLaHV/iZUAxf4A0dt5auY6KNZ+cm6aschuJGqKJM3ROTt3raPUdIDk9siAufIFEleRwtw==",
+ "requires": {
+ "@babel/code-frame": "^7.5.5",
+ "@babel/generator": "^7.7.2",
+ "@babel/helper-function-name": "^7.7.0",
+ "@babel/helper-split-export-declaration": "^7.7.0",
+ "@babel/parser": "^7.7.2",
+ "@babel/types": "^7.7.2",
+ "debug": "^4.1.0",
+ "globals": "^11.1.0",
+ "lodash": "^4.17.13"
+ },
+ "dependencies": {
+ "@babel/code-frame": {
"version": "7.5.5",
- "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.5.5.tgz",
- "integrity": "sha512-s63F9nJioLqOlW3UkyMd+BYhXt44YuaFm/VV0VwuteqjYwRrObkU7ra9pY4wAJR3oXi8hJrMcrcJdO/HH33vtw==",
+ "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.5.5.tgz",
+ "integrity": "sha512-27d4lZoomVyo51VegxI20xZPuSHusqbQag/ztrBC7wegWoQ1nLREPVSKSW8byhTlzTKyNE4ifaTA6lCp7JjpFw==",
+ "requires": {
+ "@babel/highlight": "^7.0.0"
+ }
+ }
+ }
+ },
+ "@babel/types": {
+ "version": "7.7.2",
+ "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.7.2.tgz",
+ "integrity": "sha512-YTf6PXoh3+eZgRCBzzP25Bugd2ngmpQVrk7kXX0i5N9BO7TFBtIgZYs7WtxtOGs8e6A4ZI7ECkbBCEHeXocvOA==",
"requires": {
"esutils": "^2.0.2",
"lodash": "^4.17.13",
"dev": true
},
"convert-source-map": {
- "version": "1.6.0",
- "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.6.0.tgz",
- "integrity": "sha512-eFu7XigvxdZ1ETfbgPBohgyQ/Z++C0eEhTor0qRwBw9unw+L0/6V8wkSuGgzdThkiS5lSpdptOQPD8Ak40a+7A==",
+ "version": "1.7.0",
+ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz",
+ "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==",
"requires": {
"safe-buffer": "~5.1.1"
}
"dev": true
},
"json5": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.0.tgz",
- "integrity": "sha512-8Mh9h6xViijj36g7Dxi+Y4S6hNGV96vcJZr/SrlHh1LR/pEn/8j/+qIBbs44YKl69Lrfctp4QD+AdWLTMqEZAQ==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.1.tgz",
+ "integrity": "sha512-l+3HXD0GEI3huGq1njuqtzYK8OYJyXMkOLtQ53pjWh89tvWS2h6l+1zMkYWqlb57+SiQodKZyvMEFb2X+KrFhQ==",
"requires": {
"minimist": "^1.2.0"
},
"integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=",
"dev": true
},
- "trim-right": {
- "version": "1.0.1",
- "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz",
- "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM="
- },
"tslib": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz",

MODIFY
package.json
package.json
},
"dependencies": {
"@agoric/evaluate": "^2.1.3",
- "@babel/core": "^7.5.5",
+ "@babel/core": "^7.7.2",
"esm": "^3.2.5",
"rollup": "^1.17.0",
"rollup-plugin-node-resolve": "^5.2.0"

MODIFY
src/babelPlugin.js
src/babelPlugin.js
@@ -31,6 +31,7 @@ const collectPatternIdentifiers = (path, pattern) => {
function makeModulePlugins(options) {
const {
+ exportAlls,
fixedExportMap,
imports,
importDecls,
@@ -190,7 +191,7 @@ function makeModulePlugins(options) {
const specifier = path.node.source.value;
let myImportSources = importSources[specifier];
if (!myImportSources) {
- myImportSources = [];
+ myImportSources = Object.create(null);
importSources[specifier] = myImportSources;
}
let myImports = imports[specifier];
@@ -303,6 +304,21 @@ function makeModulePlugins(options) {
}
}
},
+ ExportAllDeclaration(path) {
+ const { source } = path.node;
+ if (doAnalyze) {
+ const specifier = source.value;
+ let myImportSources = importSources[specifier];
+ if (!myImportSources) {
+ myImportSources = Object.create(null);
+ importSources[specifier] = myImportSources;
+ }
+ exportAlls.push(specifier);
+ }
+ if (doTransform) {
+ path.replaceWithMultiple([]);
+ }
+ },
ExportNamedDeclaration(path) {
const { declaration: decl, specifiers: specs, source } = path.node;
@@ -313,7 +329,7 @@ function makeModulePlugins(options) {
const specifier = source.value;
myImportSources = importSources[specifier];
if (!myImportSources) {
- myImportSources = [];
+ myImportSources = Object.create(null);
importSources[specifier] = myImportSources;
}
myImports = imports[specifier];

MODIFY
src/index.js
src/index.js
@@ -17,6 +17,7 @@ const makeModuleTransformer = (babelCore, importer) => {
// This list taken and amended from:
// https://github.com/prettier/prettier/tree/master/src/language-js/parser-babylon.js#L21
parserPlugins.push(
+ 'eventualSend',
'doExpressions',
'objectRestSpread',
'classProperties',
@@ -46,6 +47,8 @@ const makeModuleTransformer = (babelCore, importer) => {
const modulePlugins = makeModulePlugins(sourceOptions);
const output = babelCore.transformSync(source, {
parserOpts: {
+ allowAwaitOutsideFunction: true,
+ allowImportExportEverywhere: true,
plugins: parserPlugins,
},
generatorOpts: {
@@ -88,6 +91,8 @@ const makeModuleTransformer = (babelCore, importer) => {
// Record of imported module specifier names to list of importNames.
// The importName '*' is that module's module namespace object.
imports: {},
+ // List of module specifiers that we export all from.
+ exportAlls: [],
// exportNames of variables that are assigned to, or reexported and
// therefore assumed live. A reexported variable might not have any
// localName.
@@ -111,7 +116,7 @@ const makeModuleTransformer = (babelCore, importer) => {
.map(([exp, upds]) => `[${js(exp)}, [${upds.join(',')}]]`)
.join(',')}])]`,
)
- .join(',')}]));`;
+ .join(',')}]), ${js(sourceOptions.exportAlls)});`;
preamble += sourceOptions.hoistedDecls
.map(vname => `${h.HIDDEN_LIVE}.${vname}();`)
.join('');
@@ -137,6 +142,7 @@ const makeModuleTransformer = (babelCore, importer) => {
imports: sourceOptions.imports,
liveExportMap: sourceOptions.liveExportMap,
fixedExportMap: sourceOptions.fixedExportMap,
+ exportAlls: sourceOptions.exportAlls,
functorSource,
};
// console.log(moduleStaticRecord);

feat(exportAlls): track the export * from 'foo' occurrences

We supply the module specifiers from which we export * as the
second argument to $h_imports.