-
Notifications
You must be signed in to change notification settings - Fork 221
Description
TLDR;
Adding more customization options to build_web_compilers would allow Jaspr to support flutter embedding and flutter plugins without needing to maintain a custom fork of this package. These include changing the sdk-, kernel- and library paths of ddc_builder, adding to the list of platform libraries (to allow dart:ui) and a few more. No custom logic is needed beyond configuration options.
When I initially added flutter embedding support to Jaspr, I was forced to fork the build_web_compilers package because of the deep changes I needed to make to the compilation pipeline. The two main problems were:
- Compiling a dart program that uses flutter (and thereby
dart:ui). - Correctly initializing any depended-on flutter plugin.
The compilation is solved by:
- replacing a bunch of paths like the sdk path, sdk kernel path and
libraries.jsonpath with ones pointing to the respective assets from the installed flutter framework (compare) - adding
uiandui_webto the list of allowed platform libraries (compare) - ignoring checks on
dart:io(compare) - copying
dart_sdk.jsfrom flutter instead of compiling from source (compare)
The plugin initialization is solved by generating a custom entrypoint script that initializes all plugins, similar to what flutter is generating when running for web.
In the last release I made significant changes to the framework to reduce the custom logic (including moving all the plugin generation to jaspr_builders) and bring the fork much closer to the original, to a point where I think now there is a way to do everything Jaspr needs with a few additional build options on the original builders.
The following should be all options that would need to be added (preliminary names):
build_web_compilers:ddc:platform_sdk_pathto be passed toplatformSdkofDevCompilerBuilderandKernelBuildersdk_kernel_pathto be passed tosdkKernelPathofDevCompilerBuilderandKernelBuilderlibraries_pathto be passed tolibrariesPathofDevCompilerBuilderandKernelBuilderadditional_web_librariesto be passed toDartPlatform.register
build_web_compilers:entrypointskip_unsupported_dependencies_checkto be passed tomodule.computeTransitiveDependencies(throwIfUnsupported: ...)insidedart2js_bootstrapanddart2wasm_bootstraplibraries_pathto be passed todart2js_bootstrap
build_web_compilers:sdk_jsdart_js_pathto use for copying thedart_sdk.jsfile and skipping its compilation (alternatively make compilation work using a different sdk, but so far that was unsuccessful for me)
By exposing these options, the package can stay completely independent and doesn't need any Flutter or Jaspr specific logic, while still enabling this use-case.
I'm happy to work on a PR for this, but before I do I would love some feedback from the team if this is the right direction. Finally I have two specific questions:
- Does someone see a way to do the sdk.js compilation work instead of copying over? The only downside rn is that this doesn't allow enabling canary features (whatever that is).
- Any concerns regarding the new hot-reload related parts of this package? I haven't tried it out yet and am not familiar enough with the whole thing to evaluate.