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

Module imports are not working #2

Closed
0x-r4bbit opened this issue Sep 20, 2018 · 8 comments · Fixed by #3
Closed

Module imports are not working #2

0x-r4bbit opened this issue Sep 20, 2018 · 8 comments · Fixed by #3

Comments

@0x-r4bbit
Copy link

When trying to import symbols from any other TS module within an embark project that based on this template, webpack isn't able to resolve the module paths.

Here's how this can be reproduced:

$ embark new test --template embark-framework/embark-typescript-template

Then, take the Greeter class from app/js/index.ts and move it into app/js/greeter.ts:

// greeter.ts
export class Greeter {
  ...
}

Next try to import Greeter from this new file inside index.ts:

import { Greeter } from './greeter'

This will result in:

./app/js/index.ts
Module not found: Error: Can't resolve './greeter' in '/Users/pascalprecht/projects/embark/playground/ts-test/app/js'
resolve './greeter' in '/Users/pascalprecht/projects/embark/playground/ts-test/app/js'
  using description file: /Users/pascalprecht/projects/embark/playground/ts-test/package.json (relative path: ./app/js)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: /Users/pascalprecht/projects/embark/playground/ts-test/package.json (relative path: ./app/js/greeter)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        /Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter doesn't exist
      .wasm
        Field 'browser' doesn't contain a valid alias configuration
        /Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter.wasm doesn't exist
      .mjs
        Field 'browser' doesn't contain a valid alias configuration
        /Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter.mjs doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        /Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        /Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter.json doesn't exist
      as directory
        /Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter doesn't exist
[/Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter]
[/Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter.wasm]
[/Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter.mjs]
[/Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter.js]
[/Users/pascalprecht/projects/embark/playground/ts-test/app/js/greeter.json]
 @ ./app/js/index.ts 5:0-36 13:18-25
 @ multi ./app/js/index.ts
@iurimatias
Copy link
Contributor

I can't replicate this anymore, at least with next

@iurimatias
Copy link
Contributor

also works with develop

@0x-r4bbit
Copy link
Author

Verifying this now on latest develop and next

@0x-r4bbit
Copy link
Author

@iurimatias I can still reproduce this on both, develop and next. Here are the steps to reproduce:

$ cd embark
$ git checkout -f develop # or next
$ rm -rf node_modules && npm install
$ npm link
$ cd path/to/some/embark-project
$ embark run

@0x-r4bbit
Copy link
Author

So after I saw embarklabs/embark-angular-template#2 (comment) I tried it again by importing modules including their file extension.

This seems to work perfectly fine but I honestly didn't expect this. I think we should support importing modules without specifying the file extension.

@michaelsbradleyjr
Copy link
Contributor

Using embark's next branch, I am unable to reproduce the problem per the instructions at the top.

Even without giving a file extension (import { Greeter } from './greeter' in index.ts), embark run completes successfully. I verified the expected transpiled code is in dist/js/app.js.

@michaelsbradleyjr
Copy link
Contributor

Also unable to reproduce with embark's develop branch.

@0x-r4bbit
Copy link
Author

That is very weird, because I still manage to reproduce this.

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