mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:11:08 -06:00
cbc28e8e33
(extracted from #23678) * Move Wizard back into main app, remove Wizard addon * Remove Wizard-related resolver or build hacks * Install and enable `@embroider/router` * Add "wizard" to `splitAtRoutes` In a fully optimized Embroider app, route-based code splitting more or less Just Work™ – install `@embroider/router`, subclass from it, configure which routes you want to split and that's about it. However, our app is not "fully optimized", by which I mean we are not able to turn on all the `static*` flags. In Embroider, "static" means "statically analyzable". Specifically it means that all inter-dependencies between modules (files) are explicitly expressed as `import`s, as opposed to `{{i18n ...}}` magically means "look for the default export in app/helpers/i18n.js" or something even more dynamic with the resolver. Without turning on those flags, Embroider behaves conservatively, slurps up all `app` files eagerly into the primary bundle/chunks. So, while you _could_ turn on route-based code splitting, there won't be much to split. The commits leading up to this involves a bunch of refactors and cleanups that 1) works perfectly fine in the classic build, 2) are good and useful in their own right, but also 3) re-arranged things such that most dependencies are now explicit. With those in place, I was able to move all the wizard code into the "app/static" folder. Embroider does not eagerly pull things from this folder into any bundle, unless something explicitly "asks" for them via `imports`. Conversely, things from this folder are not registered with the resolver and are not added to the `loader.js` registry. In conjunction with route-based code splitting, we now have the ability to split out islands of on-demand functionalities from the main app bundle. When you split a route in Embroider, it automatically creates a bundle/entrypoint with the relevant routes/templates/controllers matching that route prefix. Anything they import will be added to the bundle as well, assuming they are not already in the main app bundle, which is where the "app/static" folder comes into play. The "app/static" folder name is not special. It is configured in ember-cli-build.js. Alternatively, we could have left everything in their normal locations, and add more fine-grained paths to the `staticAppPaths` array. I just thought it would be easy to manage and scale, and less error-prone to do it this way. Note that putting things in `app/static` does not guarantee that it would not be part of the main app bundle. For example, if we were to add an `import ... from "app/static/wizard/...";` in a main bundle file (say, `app.js`), then that chunk of the module graph would be pulled in. (Consider using `await import(...)`?) Overtime, we can build better tooling (e.g. lint rules and babel macros to make things less repetitive) as we expand the use of this pattern, but this is a start. Co-authored-by: Godfrey Chan <godfreykfc@gmail.com>
104 lines
3.8 KiB
JSON
104 lines
3.8 KiB
JSON
// This file was generated by scripts/build_jsconfig.rb
|
|
{
|
|
"compilerOptions": {
|
|
"target": "es2021",
|
|
"module": "esnext",
|
|
"moduleResolution": "bundler",
|
|
"experimentalDecorators": true,
|
|
"paths": {
|
|
"discourse/*": [
|
|
"./app/assets/javascripts/discourse/app/*"
|
|
],
|
|
"discourse/tests/*": [
|
|
"./app/assets/javascripts/discourse/tests/*"
|
|
],
|
|
"discourse-common/*": [
|
|
"./app/assets/javascripts/discourse-common/addon/*"
|
|
],
|
|
"admin/*": [
|
|
"./app/assets/javascripts/admin/addon/*"
|
|
],
|
|
"pretty-text/*": [
|
|
"./app/assets/javascripts/pretty-text/addon/*"
|
|
],
|
|
"select-kit/*": [
|
|
"./app/assets/javascripts/select-kit/addon/*"
|
|
],
|
|
"float-kit/*": [
|
|
"./app/assets/javascripts/float-kit/addon/*"
|
|
],
|
|
"truth-helpers/*": [
|
|
"./app/assets/javascripts/truth-helpers/addon/*"
|
|
],
|
|
"dialog-holder/*": [
|
|
"./app/assets/javascripts/dialog-holder/addon/*"
|
|
],
|
|
"discourse/plugins/chat/*": [
|
|
"./plugins/chat/assets/javascripts/*",
|
|
"./plugins/chat/test/javascripts/*"
|
|
],
|
|
"discourse/plugins/checklist/*": [
|
|
"./plugins/checklist/assets/javascripts/*",
|
|
"./plugins/checklist/test/javascripts/*"
|
|
],
|
|
"discourse/plugins/discourse-details/*": [
|
|
"./plugins/discourse-details/assets/javascripts/*",
|
|
"./plugins/discourse-details/test/javascripts/*"
|
|
],
|
|
"discourse/plugins/discourse-lazy-videos/*": [
|
|
"./plugins/discourse-lazy-videos/assets/javascripts/*",
|
|
"./plugins/discourse-lazy-videos/test/javascripts/*"
|
|
],
|
|
"discourse/plugins/discourse-local-dates/*": [
|
|
"./plugins/discourse-local-dates/assets/javascripts/*",
|
|
"./plugins/discourse-local-dates/test/javascripts/*"
|
|
],
|
|
"discourse/plugins/discourse-narrative-bot/*": [
|
|
"./plugins/discourse-narrative-bot/assets/javascripts/*",
|
|
"./plugins/discourse-narrative-bot/test/javascripts/*"
|
|
],
|
|
"discourse/plugins/discourse-presence/*": [
|
|
"./plugins/discourse-presence/assets/javascripts/*",
|
|
"./plugins/discourse-presence/test/javascripts/*"
|
|
],
|
|
"discourse/plugins/poll/*": [
|
|
"./plugins/poll/assets/javascripts/*",
|
|
"./plugins/poll/test/javascripts/*"
|
|
],
|
|
"discourse/plugins/styleguide/*": [
|
|
"./plugins/styleguide/assets/javascripts/*",
|
|
"./plugins/styleguide/test/javascripts/*"
|
|
]
|
|
}
|
|
},
|
|
"include": [
|
|
"./app/assets/javascripts/discourse/app",
|
|
"./app/assets/javascripts/discourse/tests",
|
|
"./app/assets/javascripts/discourse-common/addon",
|
|
"./app/assets/javascripts/admin/addon",
|
|
"./app/assets/javascripts/pretty-text/addon",
|
|
"./app/assets/javascripts/select-kit/addon",
|
|
"./app/assets/javascripts/float-kit/addon",
|
|
"./app/assets/javascripts/truth-helpers/addon",
|
|
"./app/assets/javascripts/dialog-holder/addon",
|
|
"./plugins/chat/assets/javascripts",
|
|
"./plugins/chat/test/javascripts",
|
|
"./plugins/checklist/assets/javascripts",
|
|
"./plugins/checklist/test/javascripts",
|
|
"./plugins/discourse-details/assets/javascripts",
|
|
"./plugins/discourse-details/test/javascripts",
|
|
"./plugins/discourse-lazy-videos/assets/javascripts",
|
|
"./plugins/discourse-lazy-videos/test/javascripts",
|
|
"./plugins/discourse-local-dates/assets/javascripts",
|
|
"./plugins/discourse-local-dates/test/javascripts",
|
|
"./plugins/discourse-narrative-bot/assets/javascripts",
|
|
"./plugins/discourse-narrative-bot/test/javascripts",
|
|
"./plugins/discourse-presence/assets/javascripts",
|
|
"./plugins/discourse-presence/test/javascripts",
|
|
"./plugins/poll/assets/javascripts",
|
|
"./plugins/poll/test/javascripts",
|
|
"./plugins/styleguide/assets/javascripts",
|
|
"./plugins/styleguide/test/javascripts"
|
|
]
|
|
}
|