Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
cd52372
Initial support for DDC + FES with build_runner
Markzipan Aug 28, 2025
af089bf
Adding hot reload flag consistency checks and enforcing module builde…
Markzipan Aug 29, 2025
01e2411
Moving sources to generated scratch dirs
Markzipan Sep 4, 2025
414fc95
Merging
Markzipan Sep 4, 2025
fa6594f
Only recompiling and invalidating requested source files
Markzipan Sep 5, 2025
09a0486
Merge branch 'master' of github.com:dart-lang/build
Markzipan Sep 17, 2025
efec641
Sample change with a hacky shared repo + digests impl comparisons
Markzipan Sep 23, 2025
aae24a2
Moving shared state to scratch space
Markzipan Sep 26, 2025
7aba038
Merging
Markzipan Sep 29, 2025
51f1e0d
addressing analysis errors
Markzipan Sep 29, 2025
5d309ca
additional file cleanup
Markzipan Sep 29, 2025
9a37369
Adding build_modules tests
Markzipan Sep 29, 2025
b2bab91
Adding build_modules tests
Markzipan Sep 29, 2025
cba3f6b
Merging
Markzipan Sep 30, 2025
244dcd4
Merge branch 'master' of github.com:dart-lang/build
Markzipan Sep 30, 2025
12a8af7
Adding reset to frontend server driver
Markzipan Oct 1, 2025
b9e30b3
Adding a builder for labeling the app entrypoint.
Markzipan Oct 1, 2025
309b11f
Removing the entrypoint from builder options
Markzipan Oct 1, 2025
625a922
Fixing error handling
Markzipan Oct 1, 2025
150a42a
Fixing some shutdown race conditions
Markzipan Oct 3, 2025
c48e015
Adding reader-writer resets
Markzipan Oct 3, 2025
9349807
Adding support for incremental build testing.
Markzipan Oct 3, 2025
f108cb6
Adding DDC frontend server builder tests
Markzipan Oct 3, 2025
75f3061
Updating entrypoint marker builder
Markzipan Oct 3, 2025
e248938
Merge branch 'master' of github.com:dart-lang/build
Markzipan Oct 3, 2025
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
12 changes: 9 additions & 3 deletions build_modules/lib/build_modules.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

export 'src/ddc_names.dart';
export 'src/errors.dart' show MissingModulesException, UnsupportedModules;
export 'src/kernel_builder.dart'
show KernelBuilder, multiRootScheme, reportUnusedKernelInputs;
export 'src/kernel_builder.dart' show KernelBuilder, reportUnusedKernelInputs;
export 'src/meta_module_builder.dart'
show MetaModuleBuilder, metaModuleExtension;
export 'src/meta_module_clean_builder.dart'
show MetaModuleCleanBuilder, metaModuleCleanExtension;
export 'src/module_builder.dart' show ModuleBuilder, moduleExtension;
export 'src/module_library.dart' show ModuleLibrary;
export 'src/module_library_builder.dart'
show ModuleLibraryBuilder, moduleLibraryExtension;
export 'src/modules.dart';
export 'src/platform.dart' show DartPlatform;
export 'src/scratch_space.dart' show scratchSpace, scratchSpaceResource;
export 'src/workers.dart' show dartdevkDriverResource, maxWorkersPerTask;
export 'src/workers.dart'
show
dartdevkDriverResource,
frontendServerProxyDriverResource,
maxWorkersPerTask,
persistentFrontendServerResource;
14 changes: 14 additions & 0 deletions build_modules/lib/src/common.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,17 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'dart:io';

import 'package:build/build.dart';
import 'package:path/path.dart' as p;
import 'package:scratch_space/scratch_space.dart';

const multiRootScheme = 'org-dartlang-app';
const webHotReloadOption = 'web-hot-reload';
final sdkDir = p.dirname(p.dirname(Platform.resolvedExecutable));
final packagesFilePath = p.join('.dart_tool', 'package_config.json');

final defaultAnalysisOptionsId = AssetId(
'build_modules',
'lib/src/analysis_options.default.yaml',
Expand All @@ -16,6 +24,12 @@ String defaultAnalysisOptionsArg(ScratchSpace scratchSpace) =>
enum ModuleStrategy { fine, coarse }

ModuleStrategy moduleStrategy(BuilderOptions options) {
// DDC's Library Bundle module system only supports fine modules since it must
// align with the Frontend Server's library management scheme.
final usesWebHotReload = options.config[webHotReloadOption] as bool? ?? false;
if (usesWebHotReload) {
return ModuleStrategy.fine;
}
final config = options.config['strategy'] as String? ?? 'coarse';
switch (config) {
case 'coarse':
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file
// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

import 'package:path/path.dart' as p;

/// Logic in this file must be synchronized with their namesakes in DDC at:
/// pkg/dev_compiler/lib/src/compiler/js_names.dart

bool isSdkInternalRuntimeUri(Uri importUri) {
return importUri.isScheme('dart') && importUri.path == '_runtime';
}

String libraryUriToJsIdentifier(Uri importUri) {
if (importUri.isScheme('dart')) {
return isSdkInternalRuntimeUri(importUri) ? 'dart' : importUri.path;
}
return pathToJSIdentifier(p.withoutExtension(importUri.pathSegments.last));
}

/// Transforms a path to a valid JS identifier.
///
/// This logic must be synchronized with [pathToJSIdentifier] in DDC at:
/// pkg/dev_compiler/lib/src/compiler/module_builder.dart
///
/// For backwards compatibility, if this pattern is changed,
/// dev_compiler_bootstrap.dart must be updated to accept both old and new
/// patterns.
Expand All @@ -35,12 +46,11 @@ String toJSIdentifier(String name) {
for (var i = 0; i < name.length; i++) {
final ch = name[i];
final needsEscape = ch == r'$' || _invalidCharInIdentifier.hasMatch(ch);
if (needsEscape && buffer == null) {
buffer = StringBuffer(name.substring(0, i));
}
if (buffer != null) {
buffer.write(needsEscape ? '\$${ch.codeUnits.join("")}' : ch);
if (needsEscape) {
buffer ??= StringBuffer(name.substring(0, i));
}

buffer?.write(needsEscape ? '\$${ch.codeUnits.join("")}' : ch);
}

final result = buffer != null ? '$buffer' : name;
Expand All @@ -56,7 +66,11 @@ String toJSIdentifier(String name) {
/// Also handles invalid variable names in strict mode, like "arguments".
bool invalidVariableName(String keyword, {bool strictMode = true}) {
switch (keyword) {
// http://www.ecma-international.org/ecma-262/6.0/#sec-future-reserved-words
// https://262.ecma-international.org/6.0/#sec-reserved-words
case 'true':
case 'false':
case 'null':
// https://262.ecma-international.org/6.0/#sec-keywords
case 'await':
case 'break':
case 'case':
Expand All @@ -79,7 +93,6 @@ bool invalidVariableName(String keyword, {bool strictMode = true}) {
case 'import':
case 'in':
case 'instanceof':
case 'let':
case 'new':
case 'return':
case 'super':
Expand All @@ -99,6 +112,7 @@ bool invalidVariableName(String keyword, {bool strictMode = true}) {
// http://www.ecma-international.org/ecma-262/6.0/#sec-identifiers-static-semantics-early-errors
case 'implements':
case 'interface':
case 'let':
case 'package':
case 'private':
case 'protected':
Expand Down
Loading
Loading