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

Path mappings not rewritten with dynamic import() #39

Open
michaeltugby0 opened this issue Jun 5, 2018 · 0 comments
Open

Path mappings not rewritten with dynamic import() #39

michaeltugby0 opened this issue Jun 5, 2018 · 0 comments

Comments

@michaeltugby0
Copy link

Just noticed that it seems like dynamic import paths are not being rewritten in accordance to the baseURL and paths set in the tsconfig.

const loading: SFC = () => <div>Loading...</div>;

const HomePage = Loadable({
    loader: () => import("~/src/routes/Home"),
    loading
});

The error I've got is:

Cannot resolve dependency '~/src/routes/Home'
  5 | const loading: SFC = () => <div>Loading...</div>;
> 6 |
    | ^
  7 | const HomePage = Loadable({
  8 |     loader: () => import("~/src/routes/Home"),
  9 |     loading

If I refactor to use a regular ES6 import, or a dynamic import with a relative path, all works fine. So, this is just an issue with dynamic imports when using non-relative paths.

My tsconfig is as follows:

{
    "compilerOptions": {
      "baseUrl": ".",
      "paths": {
        "~/*": ["./*"]
      },
      "outDir": "out-tsc",
      "module": "esnext",
      "moduleResolution": "node",
      "allowSyntheticDefaultImports": true,
      "experimentalDecorators": true,
      "strictNullChecks": true,
      "target": "es6",
      "jsx": "react",
      "sourceMap": true
    }
  }
@fathyb fathyb changed the title Path mappings not rewritten with import() syntax Path mappings not rewritten with dynamic import() Jul 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants