Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build_web_compilers/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 4.4.8-wip
- Minor updates to flag resolution logic.

## 4.4.7
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you mean to release 4.4.7?

https://github.com/dart-lang/build/pull/4303/files#diff-6dc6d2a08a07bfe6a88bdaf089927dccbf638a138adddfea0664ca1ba2105851 put 4.4.7 in the CHANGELOG but did not update the pubspec, so there is no 4.4.7 released :) https://pub.dev/packages/build_web_compilers

To get back to a good state please do one of:

  • If you want a 4.4.7 release that does not include this PR, that will need a separate PR to update pubspec.yaml to 4.4.7, merge that, release, then this PR on top
  • If you want a 4.4.7 release that does include this PR, the new CHANGELOG entry here should be under 4.4.7, the pubspec needs updating to 4.4.7, then merge+release
  • If you don't want any release yet then the CHANGELOG should have 4.4.7-wip with two entries, and the pubspec should say 4.4.7-wip to match it

:)

- Add support for DDC's Library Bundle module system, which is compatible with web hot reload. This is not yet enabled by default.

Expand Down
2 changes: 1 addition & 1 deletion build_web_compilers/lib/src/dev_compiler_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class DevCompilerBuilder implements Builder {
this.generateFullDill = false,
this.emitDebugSymbols = false,
this.canaryFeatures = false,
this.ddcLibraryBundle = false,
this.ddcLibraryBundle = true,
this.trackUnusedInputs = false,
required this.platform,
String? sdkKernelPath,
Expand Down
10 changes: 6 additions & 4 deletions build_web_compilers/lib/src/web_entrypoint_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,11 @@ final class EntrypointBuilderOptions {
final config = options.config;
final nativeNullAssertions =
options.config[nativeNullAssertionsOption] as bool?;
final usesWebHotReload = options.config[webHotReloadOption] as bool?;
final usesWebHotReload =
options.config[webHotReloadOption] as bool? ?? false;
final usesDdcLibraryBundle =
usesWebHotReload ?? options.config[ddcLibraryBundleOption] as bool?;
usesWebHotReload ||
(options.config[ddcLibraryBundleOption] as bool? ?? false);
final librariesPath = options.config[librariesPathOption] as String?;
final unsafeAllowUnsupportedModules =
options.config[unsafeAllowUnsupportedModulesOption] as bool?;
Expand Down Expand Up @@ -281,8 +283,8 @@ final class EntrypointBuilderOptions {
config.containsKey(loaderOption)
? config[loaderOption] as String?
: defaultLoaderOption,
usesWebHotReload: usesWebHotReload ?? false,
ddcLibraryBundle: usesDdcLibraryBundle ?? false,
usesWebHotReload: usesWebHotReload,
ddcLibraryBundle: usesDdcLibraryBundle,
librariesPath: librariesPath,
unsafeAllowUnsupportedModules: unsafeAllowUnsupportedModules ?? false,
);
Expand Down
2 changes: 1 addition & 1 deletion build_web_compilers/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: build_web_compilers
version: 4.4.6
version: 4.4.8-wip
description: Builder implementations wrapping the dart2js and DDC compilers.
repository: https://github.com/dart-lang/build/tree/master/build_web_compilers
resolution: workspace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import 'package:build_web_compilers/build_web_compilers.dart';
import 'package:build_web_compilers/builders.dart';
import 'package:test/test.dart';

const ddcLibraryBundle = true;

final defaultBuilderOptions = const BuilderOptions({
'compiler': 'dartdevc',
'ddc-library-bundle': true,
'ddc-library-bundle': ddcLibraryBundle,
'native_null_assertions': false,
});

Expand All @@ -27,7 +29,10 @@ void main() {
MetaModuleCleanBuilder(ddcPlatform),
ModuleBuilder(ddcPlatform),
ddcKernelBuilder(const BuilderOptions({})),
DevCompilerBuilder(platform: ddcPlatform, ddcLibraryBundle: true),
DevCompilerBuilder(
platform: ddcPlatform,
ddcLibraryBundle: ddcLibraryBundle,
),
};
group('DDC Library Bundle:', () {
group('simple project', () {
Expand Down
32 changes: 20 additions & 12 deletions build_web_compilers/test/ddc_library_bundle_builder_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ import 'package:build_web_compilers/builders.dart';
import 'package:logging/logging.dart';
import 'package:test/test.dart';

const ddcLibraryBundle = true;

final builderOptions = const BuilderOptions({
'track-unused-inputs': false,
'ddc-library-bundle': true,
'ddc-library-bundle': ddcLibraryBundle,
});

void main() {
Expand Down Expand Up @@ -84,7 +86,7 @@ void main() {
platform: ddcPlatform,
useIncrementalCompiler: trackUnusedInputs,
trackUnusedInputs: trackUnusedInputs,
ddcLibraryBundle: true,
ddcLibraryBundle: ddcLibraryBundle,
);

final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
Expand Down Expand Up @@ -132,7 +134,7 @@ void main() {
final builder = DevCompilerBuilder(
platform: ddcPlatform,
environment: {'foo': 'zap'},
ddcLibraryBundle: true,
ddcLibraryBundle: ddcLibraryBundle,
);
final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
'a|lib/a$jsModuleExtension': isNotNull,
Expand All @@ -158,7 +160,7 @@ void main() {
final builder = DevCompilerBuilder(
platform: ddcPlatform,
canaryFeatures: true,
ddcLibraryBundle: true,
ddcLibraryBundle: ddcLibraryBundle,
);
final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
'a|lib/a$jsModuleExtension': decodedMatches(contains('canary')),
Expand All @@ -183,7 +185,7 @@ void main() {
() async {
final builder = DevCompilerBuilder(
platform: ddcPlatform,
ddcLibraryBundle: true,
ddcLibraryBundle: ddcLibraryBundle,
);
final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
'a|lib/a$jsModuleExtension': decodedMatches(
Expand Down Expand Up @@ -213,7 +215,7 @@ void main() {
final builder = DevCompilerBuilder(
platform: ddcPlatform,
generateFullDill: true,
ddcLibraryBundle: true,
ddcLibraryBundle: ddcLibraryBundle,
);
final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
'a|lib/a$fullKernelExtension': isNotNull,
Expand All @@ -239,7 +241,7 @@ void main() {
test('does not generate full dill by default', () async {
final builder = DevCompilerBuilder(
platform: ddcPlatform,
ddcLibraryBundle: true,
ddcLibraryBundle: ddcLibraryBundle,
);
final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
'a|lib/a$jsModuleExtension': isNotNull,
Expand All @@ -263,7 +265,7 @@ void main() {
final builder = DevCompilerBuilder(
platform: ddcPlatform,
emitDebugSymbols: true,
ddcLibraryBundle: true,
ddcLibraryBundle: ddcLibraryBundle,
);
final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
'a|lib/a$jsModuleExtension': isNotNull,
Expand All @@ -289,7 +291,7 @@ void main() {
test('does not emit debug symbols by default', () async {
final builder = DevCompilerBuilder(
platform: ddcPlatform,
ddcLibraryBundle: true,
ddcLibraryBundle: ddcLibraryBundle,
);
final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
'b|lib/b$jsModuleExtension': isNotNull,
Expand All @@ -312,7 +314,7 @@ void main() {
test('strips scratch paths from metadata', () async {
final builder = DevCompilerBuilder(
platform: ddcPlatform,
ddcLibraryBundle: true,
ddcLibraryBundle: ddcLibraryBundle,
);
final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
'a|lib/a$jsModuleExtension': isNotNull,
Expand Down Expand Up @@ -366,7 +368,10 @@ void main() {
MetaModuleCleanBuilder(ddcPlatform),
ModuleBuilder(ddcPlatform),
ddcKernelBuilder(builderOptions),
DevCompilerBuilder(platform: ddcPlatform, ddcLibraryBundle: true),
DevCompilerBuilder(
platform: ddcPlatform,
ddcLibraryBundle: ddcLibraryBundle,
),
],
assets,
outputs: expectedOutputs,
Expand Down Expand Up @@ -412,7 +417,10 @@ void main() {
MetaModuleCleanBuilder(ddcPlatform),
ModuleBuilder(ddcPlatform),
ddcKernelBuilder(builderOptions),
DevCompilerBuilder(platform: ddcPlatform, ddcLibraryBundle: true),
DevCompilerBuilder(
platform: ddcPlatform,
ddcLibraryBundle: ddcLibraryBundle,
),
],
assets,
outputs: expectedOutputs,
Expand Down
47 changes: 24 additions & 23 deletions build_web_compilers/test/dev_compiler_bootstrap_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,29 @@ import 'package:build_web_compilers/builders.dart';
import 'package:file/memory.dart';
import 'package:test/test.dart';

const ddcLibraryBundle = false;

final defaultBuilderOptions = const BuilderOptions({
'compiler': 'dartdevc',
'ddc-library-bundle': ddcLibraryBundle,
'native_null_assertions': false,
});

void main() {
initializePlatforms();
final startingBuilders = {
// Uses the real sdk copy builder to copy required files from the SDK.
sdkJsCopyRequirejs(const BuilderOptions({})),
sdkJsCompile(const BuilderOptions({})),
sdkJsCompile(defaultBuilderOptions),
const ModuleLibraryBuilder(),
MetaModuleBuilder(ddcPlatform),
MetaModuleCleanBuilder(ddcPlatform),
ModuleBuilder(ddcPlatform),
ddcKernelBuilder(const BuilderOptions({})),
DevCompilerBuilder(platform: ddcPlatform),
DevCompilerBuilder(
platform: ddcPlatform,
ddcLibraryBundle: ddcLibraryBundle,
),
};

group('simple project', () {
Expand Down Expand Up @@ -85,12 +96,7 @@ void main() {
test('can bootstrap dart entrypoints', () async {
// Just do some basic sanity checking, integration tests will validate
// things actually work.
final builder = WebEntrypointBuilder.fromOptions(
const BuilderOptions({
'compiler': 'dartdevc',
'native_null_assertions': false,
}),
);
final builder = WebEntrypointBuilder.fromOptions(defaultBuilderOptions);
final expectedOutputs = Map.of(startingExpectedOutputs)..addAll({
'a|web/index.dart.bootstrap.js': decodedMatches(
allOf([
Expand Down Expand Up @@ -122,12 +128,7 @@ void main() {
});
group('regression tests', () {
test('root dart file is not the primary source, #2269', () async {
final builder = WebEntrypointBuilder.fromOptions(
const BuilderOptions({
'compiler': 'dartdevc',
'native_null_assertions': false,
}),
);
final builder = WebEntrypointBuilder.fromOptions(defaultBuilderOptions);
final assets = {
// Becomes the primary source for the module, since it we alpha-sort.
'a|web/a.dart': '''
Expand Down Expand Up @@ -187,12 +188,7 @@ void main() {
});

test('root dart file is under lib', () async {
final builder = WebEntrypointBuilder.fromOptions(
const BuilderOptions({
'compiler': 'dartdevc',
'native_null_assertions': false,
}),
);
final builder = WebEntrypointBuilder.fromOptions(defaultBuilderOptions);
final assets = {
'a|lib/app.dart': 'void main() {}',
// Add a fake asset so that the build_web_compilers package exists.
Expand Down Expand Up @@ -235,7 +231,9 @@ void main() {
});

test('can enable canary features for SDK', () async {
final builder = sdkJsCompile(const BuilderOptions({'canary': true}));
final builder = sdkJsCompile(
const BuilderOptions({'canary': true, 'ddc-library-bundle': false}),
);
final sdkAssets = <String, Object>{'build_web_compilers|fake.txt': ''};
final expectedOutputs = {
'build_web_compilers|lib/src/dev_compiler/dart_sdk.js': decodedMatches(
Expand All @@ -247,7 +245,7 @@ void main() {
});

test('does not enable canary features for SDK by default', () async {
final builder = sdkJsCompile(const BuilderOptions({}));
final builder = sdkJsCompile(defaultBuilderOptions);
final sdkAssets = <String, Object>{'build_web_compilers|fake.txt': ''};
final expectedOutputs = {
'build_web_compilers|lib/src/dev_compiler/dart_sdk.js': decodedMatches(
Expand All @@ -260,7 +258,10 @@ void main() {

test('can use prebuilt sdk from path', () async {
final builder = sdkJsCompile(
const BuilderOptions({'use-prebuilt-sdk-from-path': 'path/to/sdk'}),
const BuilderOptions({
'use-prebuilt-sdk-from-path': 'path/to/sdk',
'ddc-library-bundle': false,
}),
);
final sdkAssets = <String, Object>{'build_web_compilers|fake.txt': ''};
final expectedOutputs = {
Expand Down
Loading
Loading