aurelia / aurelia/webpack-plugin

Support Webpack Prefetch

Open
#163 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
89
Forks
33
PR merge metrics
No merged PRs in 30d

Description

**I'm submitting a feature request**

We're porting a reasonably sized repo (the Aurelia app takes 100k sloc) from AureliaCLI (vanilla RequireJS / Gulp) to Webpack with this Plugin, I made everything works already (Many thanks for the plugin itself and the helpful yet brief wiki!).

We had some hand-rolled solutions that would prefetch with RequireJS bundles before because the loading speed is kind of essential to us, and Webpack [support this already](https://webpack.js.org/guides/code-splitting/#prefetchingpreloading-modules):
```js
import(/* webpackPrefetch: true */ 'LoginModal');
```

The approach is just a dynamic import with magical comments. However, with Aurelia, I could only import modules with `PLATFORM.moduleName('./foo-module', 'foo-chunk')`.

I tried to figure out if there's a straightforward way to do it. But if I get it right, It seems the [IncludeDependency](https://github.com/aurelia/webpack-plugin/blob/master/src/IncludeDependency.ts#L11) only support two arguments: the module name and the chunk it belongs to.

Is there any way to achieve this? Furthermore, there seem to be some other useful options like preload could be expressed with the magical comment, is it possible to support those with `PLATFORM.moduleName`? Could the behavior and lazy loading share with the`` in templates?

Thank again for the great plugin.

**Expected/desired behavior:**

Contributor guide

Open the contributing guide

Research direction

Start by reading src/IncludeDependency.ts, especially how PLATFORM.moduleName accepts the module name and chunk. Compare that behavior with Webpack's documented dynamic-import prefetch and preload comments, then determine how the requested options could be represented and how they should interact with template loading. Done means the plugin supports the requested prefetch behavior and the resulting Aurelia bundles load as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, webpack
Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.