-
Notifications
You must be signed in to change notification settings - Fork 231
Drop build and serve #1871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Drop build and serve #1871
Conversation
- Drop `lib/src/{barback,datdevc,asset}` and relevant tests - Add `lib/src/asset/id.dart` since non-building code uses this type from barback. - Clean up analyzer errors, droping any code paths that relate to dealing with Transformers, for example the `run` command's ability to run with transformed code, or any parsing and plumbing for transformer config. - Clean up any tests that were checking behavior of transformers or the build or serve command. - Remove any dependencies for which I could no longer find an import.
Note that a |
The
|
- Hide the build and serve commands - Remove mode option
one failing test – and one unformatted file. Nice... |
@nex3 - can you help me understand how this test works? I see that it's setting up a fake package for |
Will do a full review in a bit, but:
I think this is fine. I think the vast majority of users of transformers in practice used them for building web apps.
This tries to simulate what The |
If I'm understanding the test correctly it seems to expect that the asset environment would have successfully provided that file, allow the Or am I misunderstanding this? |
Ah, Jake pointed me to where the magic file is created |
The immediate problem is that without the Barback asset environment we only know how to find a package if it has a I think the "1.6-style lockfile" for global packages might only work through the asset environment. Before I spend time on a fix - is this something we feel we need to continue to support? |
This is not worth supporting
The immediate problem is that without the Barback asset environment we only know how to find a package if it has a
Right. Before we started creating snapshots (which was well after 1.6), all
If it's a huge amount of effort you could drop it, but I think all you should need to do is something like if (!fileExists(snapshotPath)) await _precompileExecutables(package); There's a lot of psychological value for users in guaranteeing that the package manager will never choke on data it itself created, even in edge cases like this. |
This reverts commit 5baf955.
I think in order to support this we'd need to rewrite some of the AssetEnvironment stuff without barback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Real excited to see this stuff get deleted!
lib/src/asset/id.dart
Outdated
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// Like the AssetId class from barback but without the barback dependency. | ||
class AssetId { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to get rid of this entirely? Looking through the remaining uses, it seems like almost all of them exist in contexts where the package is determined by context, so you could just use the executable name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that at first and hit at least one case where we were storing a collection of AssetIds and lost context of their associated packages.
I can take another look, but I'd prefer to do that in a new PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I overestimated the scope. I replaced id
with a packageName
and pathInPackage
argument in the snapshot
method, but everything else was, as you pointed out, already in a context where we had the package name.
lib/src/cached_package.dart
Outdated
/// cached, this returns the cached information. It also wraps the package's | ||
/// pubspec to report no transformers, since the transformations have all been | ||
/// applied already. | ||
/// cached, this returns the cached information. | ||
class CachedPackage extends Package { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be necessary anymore—there's nothing for pub to precompile in the lib directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/src/command/barback.dart
Outdated
return result; | ||
log.error(log.red("Dart 2 has a new build system. Learn how to migrate " | ||
"from ${log.bold('pub build')} and\n" | ||
"${log.bold('pub serve')}: https://webdev.dartlang.org/dart-2\n")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: use fail()
instead of log.error()
and exit()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
GlobalRunCommand() { | ||
argParser.addFlag("checked", | ||
abbr: "c", help: "Enable runtime type checks and assertions."); | ||
argParser.addOption("mode", | ||
defaultsTo: "release", help: 'Mode to run transformers in.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to give build
and serve
helpful error messages, we might as well do so for --mode
as well (also below).
lib/src/dart.dart
Outdated
@@ -8,116 +8,13 @@ import 'dart:io'; | |||
import 'dart:isolate'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like isPart()
in this file is no longer used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed along with runInIsolate
and some (newly?) unused methods from utils.dart
lib/src/entrypoint.dart
Outdated
}); | ||
} | ||
|
||
//// Precompiles [executables] to snapshots from the filesystem. | ||
Future _precompileExecutablesWithoutBarback( | ||
Map<String, List<AssetId>> executables) { | ||
Future _precompileExecutables(Map<String, List<AssetId>> executables) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, the package names in the executables
map are totally redundant; this could just be Map<String, List<String>>
. The only reason we represented executables as AssetId
s before was for convenience when passing them to Barback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I started down that path and hit one place where it wasn't redundant and restructuring that felt like it was snowballing.
@@ -245,82 +243,6 @@ class Pubspec { | |||
|
|||
Map<String, Feature> _features; | |||
|
|||
/// The configurations of the transformers to use for this package. | |||
List<Set<TransformerConfig>> get transformers { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to add validators that produce warnings when trying to publish packages that include a transformers
field or a web.compiler
field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do that in a followup?
new Term( | ||
_systemCache.sources.hosted.refFor(name).withConstraint(constraint), | ||
false) | ||
], IncompatibilityCause.pubDependency)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also remove IncompatibilityCause.pubDependency
and its other referents.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -1,55 +0,0 @@ | |||
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should still behave nicely with old-style packages—ideally recompile them, if not that then create a .packages
file, or at the very least produce a useful error message telling users how to fix the problem.
/// pub. | ||
Future serveBarback() { | ||
return servePackages((builder) { | ||
builder.serveRealPackage('barback'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you can delete serveRealPackage()
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I suppose that's true, but you can generate a new |
Ok, I've got a change that passes the test. bcc70cd It requires passing the system cache through, we could maybe do this check earlier though to avoid it introducing a new import in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I've got a change that passes the test. bcc70cd
It requires passing the system cache through, we could maybe do this check earlier though to avoid it introducing a new import in
executable.dart
LGTM. I don't think adding a new import is a big cost, but I realized you'd still have to check to make sure that it's immutable and fall back to running from source if it's not, so just writing the .packages
file is probably fine. Make sure to re-add the test, though!
lib/src/executable.dart
Outdated
if (!fileExists(entrypoint.packagesFile)) { | ||
if (!isGlobal) return null; | ||
await writeTextFile( | ||
entrypoint.packagesFile, entrypoint.lockFile.packagesFile(cache)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment indicating why a global entrypoint without a .packages
file would exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Give me a poke when you want me to take another look. |
I think I have addressed all feedback
|
Fwiw - I am going to forgo doing an actual review here since @nex3 is more familiar with the codebase anyways and its quite large. I will note that when it comes to supporting the old lockfiles for |
lib/src/dart.dart
Outdated
Future snapshot(Uri executableUrl, String snapshotPath, | ||
{Uri packagesFile, AssetId id}) async { | ||
var name = log.bold(id == null | ||
{Uri packagesFile, String packageName, String pathInPackage}) async { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider replacing the packageName
and pathInPackage
parameters with an name
parameter and make the caller responsible for deciding what that name could look like. Then the first line could just be name ??= executableUrl.toString()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
lib/src/executable.dart
Outdated
// helpful for the subprocess to be able to spawn Dart with | ||
// Platform.executableArguments and have that work regardless of the working | ||
// directory. | ||
Uri packageConfig = p.toUri(p.absolute(entrypoint.packagesFile)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: don't type-annotate local variables.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
DeprecatedFieldsValidator(Entrypoint entrypoint) : super(entrypoint); | ||
|
||
Future validate() { | ||
return new Future.sync(() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I'd just make the method async
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
return new Future.sync(() { | ||
if (entrypoint.root.pubspec.fields.containsKey('transformers')) { | ||
warnings.add('Your pubpsec.yaml includes a "transformers" section which' | ||
' is no longer used and may be removed'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: warnings should end with a period.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
main() { | ||
setUp(d.validPackage.create); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be good to add a test that this doesn't warn for a pubspec that doesn't have either deprecated field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
I don't want to ruin the party, but running pub get/upgrade from master now hangs on windows after commit 5ca86eb. It does instead of
(notice the encoded Stumbled over it, when I tested the fix for #1756. |
This is not synced in the SDK so it is not published. What configuration are you using such that you are running this version of pub? |
@denniskaselow – could we open a separate issue for this? in the pub repo... Please be clear on the commit SHA you're hitting the issue at... |
Closes #1857
lib/src/{barback,dartdevc,asset}
and relevant testslib/src/asset/id.dart
since non-building code uses this typefrom barback.
dealing with Transformers, for example the
run
command's ability torun with transformed code, or any parsing and plumbing for transformer
config.
build or serve command.