From d7031b95168c7f280d8be74d08a56e375b965104 Mon Sep 17 00:00:00 2001 From: Edward Faulkner Date: Sun, 17 Oct 2021 11:00:58 -0400 Subject: [PATCH] detect reexport all Fixes #178. --- package-lock.json | 6 +++--- packages/ember-auto-import/ts/analyzer-plugin.ts | 7 +++++++ .../ember-auto-import/ts/tests/analyzer-test.ts | 15 +++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index ed2fc66f4..efc14bd70 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40447,7 +40447,7 @@ } }, "packages/ember-auto-import": { - "version": "2.2.1", + "version": "2.2.2", "license": "MIT", "dependencies": { "@babel/core": "^7.1.6", @@ -41636,7 +41636,7 @@ "@embroider/addon-shim": "^0.40.0", "@embroider/macros": "^0.40.0", "@types/fs-extra": "^5.0.4", - "ember-auto-import": "2.2.1", + "ember-auto-import": "2.2.2", "ember-cli": "git+https://github.com/ember-cli/ember-cli#master", "ember-cli-babel-older": "npm:ember-cli-babel@7.11.1", "ember-cli-beta": "npm:ember-cli@beta", @@ -46729,7 +46729,7 @@ "@embroider/macros": "^0.40.0", "@types/fs-extra": "^5.0.4", "@types/qunit": "^2.11.1", - "ember-auto-import": "2.2.1", + "ember-auto-import": "2.2.2", "ember-cli": "git+https://github.com/ember-cli/ember-cli#master", "ember-cli-babel-older": "npm:ember-cli-babel@7.11.1", "ember-cli-beta": "npm:ember-cli@beta", diff --git a/packages/ember-auto-import/ts/analyzer-plugin.ts b/packages/ember-auto-import/ts/analyzer-plugin.ts index 236e76724..c1ef92d45 100644 --- a/packages/ember-auto-import/ts/analyzer-plugin.ts +++ b/packages/ember-auto-import/ts/analyzer-plugin.ts @@ -72,6 +72,13 @@ function analyzerPlugin(babel: typeof Babel) { specifier: path.node.source.value, }); }, + ExportAllDeclaration(path: NodePath, state: State) { + if (erasedExportKinds.has(path.node.exportKind)) return; + state.imports.push({ + isDynamic: false, + specifier: path.node.source.value, + }); + }, }, }; } diff --git a/packages/ember-auto-import/ts/tests/analyzer-test.ts b/packages/ember-auto-import/ts/tests/analyzer-test.ts index 18a55d3cc..b8981f8f1 100644 --- a/packages/ember-auto-import/ts/tests/analyzer-test.ts +++ b/packages/ember-auto-import/ts/tests/analyzer-test.ts @@ -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 {