Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly not compatible with [email protected]? #267

Closed
NullVoxPopuli opened this issue Feb 6, 2020 · 9 comments · Fixed by #288
Closed

Possibly not compatible with [email protected]? #267

NullVoxPopuli opened this issue Feb 6, 2020 · 9 comments · Fixed by #288

Comments

@NullVoxPopuli
Copy link
Contributor

NullVoxPopuli commented Feb 6, 2020

Getting these errors:

Error: Could not find module `qrcode` imported from `emberclear/utils/string-encoding`
Error: Could not find module `showdown` imported from `emberclear/utils/dom/utils`
Error: Could not find module `testdouble` imported from `emberclear/tests/unit/service/notifications-test`

# and a bunch of: 
TypeError: Cannot read property 'exports' of undefined

The only change is going from

-    "ember-cli-typescript": "^3.1.3",
+    "ember-cli-typescript": "^4.0.0-alpha.1",

Not sure how ec-typescript is related to these behaviors, but the modules missing are auto-imported.

And I'm very unsure about the Cannot read property exports of undefined error.
image

I think I need to debug the node build process to get further information, cause this is all I have atm:
image

Two commits here:

first has green tests
second has all the module load errors (after upgrading ember-cli-typescript)

@dfreeman
Copy link
Contributor

dfreeman commented Feb 6, 2020

@NullVoxPopuli can you confirm that your app works with the latest ember-cli-babel without upgrading ember-cli-typescript? The only meaningful change from 3.x to the new 4.0 alpha is that the responsibility for adding @babel/plugin-transform-typescript moved from ember-cli-typescript to ember-cli-babel, which I wouldn't expect to have any impact here (though I could be wrong!)

@NullVoxPopuli
Copy link
Contributor Author

can you confirm that your app works with the latest ember-cli-babel without upgrading ember-cli-typescript?

yeah, these two commits show this:
image (ignore the red x's, those don't matter here (though, if you click on them, you'll see that tests pass for first, but don't for the second))

I mean, your description of what ec-typescript is doing sounds simple!
I'm only debugging this in spurts, so.. idk. As I'm casually I'm debugging (with the alpha):
image
(from requirejs, I think)

image

@nightire
Copy link

Yes, I found this issue too.

I'm using [email protected] with [email protected]. If using ember-auto-import in a .ts file, required modules are always missing, no matter been imported statically or dynamically. However, if I change this file to .js extension, required modules are loaded correctly.

I tried DEBUG=ember-auto-import:* to compare the difference, and I found ember-auto-import didn't analyze any .ts files.

@dfreeman
Copy link
Contributor

It looks like the problem is here:
https://github.com/ef4/ember-auto-import/blob/a9f41b1e989e4e5af16714ba819ded79995dea65/packages/ember-auto-import/ts/package.ts#L60-L61

ember-cli-babel now assumes it should transpile .ts files by default either if ember-cli-typescript>=4.0.0-alpha.1 is present, or if the enableTypeScriptTransform flag is set in its options:

https://github.com/babel/ember-cli-babel/blob/bc32a8ca546c30eb5ee1e231d81c67688a29bb7b/index.js#L337-L346

@nightire
Copy link

Yeah, I tested it with embroider and it works well, so it's not the problem of [email protected]

@NullVoxPopuli
Copy link
Contributor Author

I have this problem with embroider as well, I think -- still investigating

@lifeart
Copy link

lifeart commented Mar 4, 2021

I confirm same issue with ember-auto-import 1.10.1 & ember-cli-typescript 4.1.0 & ember-cli-babel 7.24.0, trying to import msal library inside service with .ts extension

@lifeart
Copy link

lifeart commented Mar 4, 2021

@dfreeman fix helps me

diff --git a/node_modules/ember-auto-import/js/package.js b/node_modules/ember-auto-import/js/package.js
index 40b93f8..6e9ac22 100644
--- a/node_modules/ember-auto-import/js/package.js
+++ b/node_modules/ember-auto-import/js/package.js
@@ -77,7 +77,7 @@ class Package {
         // match.
         let babelAddon = instance.addons.find(addon => addon.name === 'ember-cli-babel');
         let babelOptions = babelAddon.buildBabelOptions(options);
-        let extensions = babelOptions.filterExtensions || ['js'];
+        let extensions = babelOptions.filterExtensions || ['js','ts'];
         // https://github.com/babel/ember-cli-babel/issues/227
         delete babelOptions.annotation;
         delete babelOptions.throwUnlessParallelizable;

@lifeart
Copy link

lifeart commented Mar 4, 2021

@dfreeman , @ef4 wondering, could we just check for ember-cli-typescript and if it's installed and >=4, then manually add ts to extensions list to solve it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants