Skip to content

Commit

Permalink
detect reexport all
Browse files Browse the repository at this point in the history
Fixes #178.
  • Loading branch information
ef4 committed Oct 17, 2021
1 parent 32b9978 commit d7031b9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions packages/ember-auto-import/ts/analyzer-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,13 @@ function analyzerPlugin(babel: typeof Babel) {
specifier: path.node.source.value,
});
},
ExportAllDeclaration(path: NodePath<t.ExportAllDeclaration>, state: State) {
if (erasedExportKinds.has(path.node.exportKind)) return;
state.imports.push({
isDynamic: false,
specifier: path.node.source.value,
});
},
},
};
}
Expand Down
15 changes: 15 additions & 0 deletions packages/ember-auto-import/ts/tests/analyzer-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,21 @@ Qmodule('analyzer', function (hooks) {
]);
});

test('dependency discovered from namespace reexport', async function (assert) {
let original = "export * from 'some-package';";
outputFileSync(join(upstream, 'sample.js'), original);
await builder.build();
assert.deepEqual(analyzer.imports, [
{
isDynamic: false,
specifier: 'some-package',
path: 'sample.js',
package: pack,
treeType: undefined,
},
]);
});

type LiteralExample = [string, string];
type TemplateExample = [string, string[], string[]];
function isLiteralExample(exp: LiteralExample | TemplateExample): exp is LiteralExample {
Expand Down

0 comments on commit d7031b9

Please sign in to comment.