-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Building project results in dart packages not being in appropriate location #21127
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
Comments
This comment was originally written by [email protected] The link to the github repo has changed, you can now use eith master or dev branches to achieve the exact same result, the integration-test branch has been merged down to both |
Part of the point of "pub build" is that it doesn't produce any symlinks, since they're not portable. At the same time, we don't want it to copy the packages directory into every place that it could possibly be used. For now, the best solution is to use absolute URLs to refer to the packages directory in the root of your application. Issue #15808 is tracking the addition of a transformer to fix up URLs automatically. Added AsDesigned label. |
This comment was originally written by [email protected] so its preferable to use: import '../../../packages/package/name/lib.dart' rather than: import 'package:package/name/lib.dart'; I would have assumed that the latter should always "just work" |
This comment was originally written by [email protected] also ../../../packages is to get from the source file location in the project to the packages directory in the project root, but that doesn't match with in my particular case which would require the build file editing to ../../packages since the built packages directory is inside build/test not the root build folder. |
Currently "pub build" isn't really designed to deploy Dart entrypoints that aren't compiled to Javascript, since there aren't browser that support that in the wild. Once there are, the suggested means of deployment will be using dart2dart to compile them to a single file. |
This comment was originally written by [email protected] there isn't support in the wild? one of my dart entry points is for a stand alone console app that is just run directly in the dartVM so doesnt have the lack of native browser support issue, also the other 2 entry points in my app are browser side entry points which are compiled to javascript, but the index files fail to start because it can't find the dart.js file required to boot the application on page load. |
"pub build" doesn't really support deploying code to the VM yet (issue #20248). As for browser entrypoints, the .dart.js files should end up in the same location that the Dart source files were originally. |
This comment was originally written by [email protected] yest the .dart.js files do end up where they originally where but when the .html file references <script src="packages/browser/dart.js"></script> it fails to find the actual "dart.js" file because it can't find the packages directory, and as I said in my previous comment making the path relative to "../../../packages/browser/dart.js" isn't particularly nice because when you build the project you then need to manually change that relative path to have one less ../ in it as the packages directory in the build folders is in a different relative location. At the end of the day it just isn't very nice and doesn't work, which is odd because I've had similar projects in the past which did work. I remember certain builds that had multiple package directories throughout them and those package directories only contained the packages that were required in that location, so typically just browser with interop.js and dart.js in it, and everything just worked, now it doesn't sadly. |
Why not just use the root-relative URL "/packages/browser/dart.js"? Way back when we first introduced "pub build", it had specific special-case handling for the browser package that put its JS files in packages directories throughout the output. We decided that wasn't something we wanted to do for all packages, though, so we discontinued that behavior. |
This issue has been moved to dart-lang/pub#1151. |
This issue was originally filed by [email protected]
Expect the program to start running, but it fails as it cannot find the packages directory, if I manually copy the packages folder from build/test to build/test/integration/bin then it does work:
Unhandled exception:
Uncaught Error: FileSystemException: Cannot open file, path = 'D:\Projects\purity_oauth2\build\test\integration\bin\packages\purity\host.dart' (OS Error: The system cannot find the path specified.
Dart Editor version 1.6.0.release (STABLE)
Dart SDK version 1.6.0
Windows 8.1 x64
The text was updated successfully, but these errors were encountered: