Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
alanorozco committed Dec 3, 2021
1 parent 3e71ec2 commit bff8fe3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion build-system/babel-config/bento-element-config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {
getSharedBentoSymbols,
} = require('../compile/generate/metadata/shared-bento-symbols');
} = require('../compile/generate/shared-bento-symbols');
const {generateIntermediatePackage} = require('../compile/generate/bento');
const {getMinifiedConfig} = require('./minified-config');
const {getUnminifiedConfig} = require('./unminified-config');
Expand Down
2 changes: 1 addition & 1 deletion build-system/compile/generate/bento.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// into this file. Add tests for them, now that we have tests here.

const dedent = require('dedent');
const {getSharedBentoSymbols} = require('./metadata/shared-bento-symbols');
const {getSharedBentoSymbols} = require('./shared-bento-symbols');

/**
* @param {Object<string, string[]>} packageSymbols
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ const packages = [
* @return {string[]}
*/
function getExportedSymbols(source) {
const tree = parse(source, {sourceType: 'module', plugins: ['jsx']});
const tree = parse(source, {
sourceType: 'module',
plugins: ['jsx', 'exportDefaultFrom'],
});
const symbols = [];
for (const node of tree.program.body) {
if (types.isExportAllDeclaration(node)) {
throw new Error('Should not "export *"');
}
if (types.isExportDefaultDeclaration(node)) {
throw new Error('Should not "export default"');
}
if (!types.isExportNamedDeclaration(node)) {
continue;
}
Expand Down Expand Up @@ -66,7 +72,7 @@ function getExportedSymbols(source) {
})
);
}
return symbols;
return symbols.filter(Boolean);
}

let sharedBentoSymbols;
Expand All @@ -82,7 +88,7 @@ function getSharedBentoSymbols() {
try {
const source = readFileSync(filepath, 'utf8');
const symbols = getExportedSymbols(source);
return [`#${pkg}`, symbols.filter(Boolean)];
return [`#${pkg}`, symbols];
} catch (e) {
e.message = `${filepath}: ${e.message}`;
throw e;
Expand All @@ -93,4 +99,4 @@ function getSharedBentoSymbols() {
return sharedBentoSymbols;
}

module.exports = {getSharedBentoSymbols};
module.exports = {getExportedSymbols, getSharedBentoSymbols};
9 changes: 6 additions & 3 deletions build-system/compile/generate/test/bento.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const dedent = require('dedent');
const test = require('ava');
const {generateBentoRuntime, generateIntermediatePackage} = require('../bento');
const {
generateBentoRuntimeEntrypoint,
generateIntermediatePackage,
} = require('../bento');

test('generateBentoRuntime', (t) => {
test('generateBentoRuntimeEntrypoint', (t) => {
t.is(
generateBentoRuntime({
generateBentoRuntimeEntrypoint({
'#foo': ['bar', 'baz'],
'#baz/bar': ['car'],
}),
Expand Down

0 comments on commit bff8fe3

Please sign in to comment.