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

Is there support for using with System.import() (or alternative?) #99

Closed
danhayden opened this issue Nov 25, 2016 · 1 comment
Closed

Comments

@danhayden
Copy link

danhayden commented Nov 25, 2016

I am using System.import() in my React project for lazy loading components and data to reduce initial bundle size.

["module-resolver", {"alias": { "data": "./src/data/"}}]

Sample code

System.import('data/faqs')
  .then(response => response.default)
  .then(faqs => this.setState({faqs}))

Error

ERROR in ./src/scripts/app/pages/FAQ.js
Module not found: Error: Can't resolve 'data/faqs' in '<truncated-path>/src/scripts/app/pages'
 @ ./src/scripts/app/pages/FAQ.js 42:6-39
 @ ./src/scripts/bundles/app.js
 @ multi app

Regular imports (import faqs from 'data/faqs') are working as expected, but not when using System.import()

If System.import() is not supported is there an alternative I can use?
For now I am just creating aliases within webpack config for the affected imports like below

resolve: {
  alias: {
    data: path.join(__dirname, 'src/data/')
  }
}

Would be nice if babel could handle all the aliases if possible :)

@tleunen
Copy link
Owner

tleunen commented Nov 25, 2016

Yes, as this time, the System.import syntax is not supported. But it would be great to add support for it. I'm adding this to the list of improvement.

It's a functionality similar to #97

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