Title: Proposal: Async imports · Issue #3100 · microsoft/TypeScript · GitHub
Open Graph Title: Proposal: Async imports · Issue #3100 · microsoft/TypeScript
X Title: Proposal: Async imports · Issue #3100 · microsoft/TypeScript
Description: Most module bundlers bundles everything into one file e.g. browserify, requirejs etc. But if you are developing a very large scale application you might not find it suitable to have everything bundled into a single file. What you might w...
Open Graph Description: Most module bundlers bundles everything into one file e.g. browserify, requirejs etc. But if you are developing a very large scale application you might not find it suitable to have everything bund...
X Description: Most module bundlers bundles everything into one file e.g. browserify, requirejs etc. But if you are developing a very large scale application you might not find it suitable to have everything bund...
Opengraph URL: https://github.com/microsoft/TypeScript/issues/3100
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Proposal: Async imports","articleBody":"Most module bundlers bundles everything into one file e.g. `browserify`, `requirejs` etc. But if you are developing a very large scale application you might not find it suitable to have everything bundled into a single file. What you might want is to have it bundled into multiple files, i.e. sub graphs of the main dependency graph. So if you visit a page, you only want to download the contents of that page instead of contents of others. This is a very good use case for SPA:s, because in today's day and age they need to be bundled into a single file, because they need to handle navigations and actions through all pages.\n\nBut in order for it to work we need `async imports`. To just give you an overview of what impact this feature could have — let's have a look at a general defined router for an SPA:\n\n``` typescript\nclass Router extends SomeRouter {\n ...\n private routes = {\n '/users/:id': 'renderUserPage'\n }\n ...\n renderUserPage() {\n async import {\n UserPageModel from './pages/user/UserPageModel';\n UserPageView from './pages/user/UserPageView';\n } {\n let model = new UserPageModel({ id: 1 });\n let view = UserPageView({ model: model });\n view.render();\n }\n }\n ...\n}\n```\n\nNow, the above `async import` statement could tell a module loader to bundle its' sub-dependency graph. So all files that `UserPageModel` and `UserPageView` requires could be bundled into a single file. Now, If you want to navigate to a different page you don't want to download the already downloaded modules. So a smart module bundler will bundles different subtracted modules of a bundle. So if a user navigates all pages in an application he would have download the whole dependency graph without over fetching something.\n\nThis proposal was inspired by how Facebook does its' closed source module handling. I know that they do something similar. And it also very similar to webpack's [code splitting](http://webpack.github.io/docs/code-splitting.html). It would be good if TypeScript support this with all the tooling support.\n","author":{"url":"https://github.com/tinganho","@type":"Person","name":"tinganho"},"datePublished":"2015-05-10T06:22:45Z","url":"https://github.com/microsoft/TypeScript/issues/3100"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:3af25281-173c-682b-ab45-15216d3eac97 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AD68:22DB35:F9B6D0:14147C5:6B00FFFE |
| html-safe-nonce | 456efc230280688b2154a28294209f26246b9fab723637b3403cfce1b117c6b4 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRDY4OjIyREIzNTpGOUI2RDA6MTQxNDdDNTo2QjAwRkZGRSIsInZpc2l0b3JfaWQiOiIyNjI4ODc2MzAxNzI5MDcxMTAyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | ef05c0e5f6ac72364ae8689c0b81c2343188f0c49407d7b7c1f572c442b404c0 |
| hovercard-subject-tag | issue:74846686 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/microsoft/TypeScript/3100/issue_layout |
| twitter:image | https://opengraph.githubassets.com/84b40a4b161f235bb93ce7e8af1edf71182c95eb962f3e6471549c331b5b70aa/microsoft/TypeScript/issues/3100 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/84b40a4b161f235bb93ce7e8af1edf71182c95eb962f3e6471549c331b5b70aa/microsoft/TypeScript/issues/3100 |
| og:image:alt | Most module bundlers bundles everything into one file e.g. browserify, requirejs etc. But if you are developing a very large scale application you might not find it suitable to have everything bund... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | tinganho |
| hostname | github.com |
| expected-hostname | github.com |
| None | cb7fa109eca7d4156c889f474306b0e91336055e9adf8fd4684b61e49094d124 |
| turbo-cache-control | no-preview |
| go-import | github.com/microsoft/TypeScript git https://github.com/microsoft/TypeScript.git |
| octolytics-dimension-user_id | 6154722 |
| octolytics-dimension-user_login | microsoft |
| octolytics-dimension-repository_id | 20929025 |
| octolytics-dimension-repository_nwo | microsoft/TypeScript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20929025 |
| octolytics-dimension-repository_network_root_nwo | microsoft/TypeScript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2b59d31a4e44f08b7af67a4b67f8fd0af3befe2a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width