Skip to content
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

Recognize file entry-points that should be accessed as package URIs #33076

Closed
lrhn opened this issue May 8, 2018 · 17 comments
Closed

Recognize file entry-points that should be accessed as package URIs #33076

lrhn opened this issue May 8, 2018 · 17 comments
Assignees
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-fasta type-enhancement A request for a change that isn't a bug

Comments

@lrhn
Copy link
Member

lrhn commented May 8, 2018

Users provide entry points to our tools as command line arguments. In some cases those entry points are inside a the lib directory of the package the user is working on, but are specified as file paths.
This can cause the same library file to be imported both using a file URI and a package URI, causing it to be interpreted as two different libraries.

To help users, we should vet the entry point path against its package configuration, and if the entry point could be referenced using a package URI, use that package URI as the URI of the entry-point instead.

@natebosch
Copy link
Member

What does "entry point" mean in this context? Is it "Dart library with a main() method?"

@peter-ahe-google
Copy link
Contributor

It means a reference to something you can run the tool on. It doesn't need to have a main method, and it doesn't need to be a library. For example, you can run both dartfmt and the analyzer on part files.

@lrhn
Copy link
Member Author

lrhn commented May 9, 2018

Yes, any user supplied file name, as long as there is also a way to resolve package URIs.

For application entry points (library containing the main method), we search for a .packages file relative to that library.

Purely single-file or source based tools, like the formatter, usually don't care what URI the library is identified by, so there is no reason to exempt them.

@peter-ahe-google
Copy link
Contributor

For application entry points (library containing the main method), we search for a .packages file relative to that library.

Actually, we would search for a .packages file for any entry point.

@anders-sandholm anders-sandholm added the area-front-end Use area-front-end for front end / CFE / kernel format related issues. label May 9, 2018
@brianegan
Copy link

This would be amazing! I've had a lot of issues filed on my projects related to this very problem. A few examples:

flutter_redux:
brianegan/flutter_redux#35
brianegan/flutter_redux#36

scoped_model:
brianegan/scoped_model#15

This is just the tip of the iceberg :)

@lrhn
Copy link
Member Author

lrhn commented Jun 19, 2018

@matanlurey
Copy link
Contributor

This is now the main issue for tracking this problem.

What does this have to do with the CFE, though? Wouldn't this be handled by the analyzer?

@natebosch
Copy link
Member

What does this have to do with the CFE

My understanding of the proposal is that the CFE would automatically treat lib/some_file.dart as package:the_package/some_file.dart. This isn't a warning to the user - it's accepting the pattern and attempting to do what the user expects.

@matanlurey
Copy link
Contributor

Oh, love it!

@xster
Copy link
Contributor

xster commented Jul 26, 2018

Until this is solved, can we add a TL;DR for users that followed the various bug threads to here for what the bug is and what is the temporary workaround?

@zoechi
Copy link
Contributor

zoechi commented Jul 27, 2018

@xster I was thinking if it were a good idea to add a comment to lib/main.dart generated by flutter create to not use relative imports in this file and to not import this file from anywhere.

@xuexin
Copy link

xuexin commented Sep 12, 2018

Face the same problem.
This problem is easily overlooked during development, please fix it.

@mit-mit
Copy link
Member

mit-mit commented Sep 24, 2018

@peter-ahe-google are you still looking at this?

@peter-ahe-google
Copy link
Contributor

It's next on my todo list.

@peter-ahe-google
Copy link
Contributor

Proposed fix https://dart-review.googlesource.com/c/sdk/+/78246

@roman-vanesyan
Copy link
Contributor

Is it possible that the fix will be included in the Dart 2.1 release?

@peter-ahe-google
Copy link
Contributor

@vanesyan it's looking good, but I can't promise anything.

roman-vanesyan added a commit to roman-vanesyan/logger.dart that referenced this issue Nov 17, 2018
Bump SDK version from 2.0 to 2.1 (required by change of importing rules in logger.dart and internals/logger.dart, see more dart-lang/sdk#33076)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-front-end Use area-front-end for front end / CFE / kernel format related issues. front-end-fasta type-enhancement A request for a change that isn't a bug
Projects
None yet
Development

No branches or pull requests