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

Deployed Angular 5 app results in 404 for require.js #896

Open
chalin opened this issue Jan 23, 2018 · 12 comments
Open

Deployed Angular 5 app results in 404 for require.js #896

chalin opened this issue Jan 23, 2018 · 12 comments
Labels
package:build_web_compilers type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@chalin
Copy link
Contributor

chalin commented Jan 23, 2018

TL;DR <base href> is ignored by main.dart.js generated for Angular 5 app.


The deployed version of the 5.0.0-alpha+4 version of the quickstart example app fails to load with the following error appearing in the console:

GET http://angular-examples.github.io/packages/$sdk/dev_compiler/web/dart_stack_trace_mapper.js net::ERR_ABORTED
(anonymous) @ main.dart.js:50

GET http://angular-examples.github.io/packages/$sdk/dev_compiler/amd/require.js net::ERR_ABORTED
(anonymous) @ main.dart.js:56

To reproduce, visit: http://angular-examples.github.io/quickstart/5 [Edit(2018/01/24): the app has been replaced by the dart2js version so you won't be able to see a hosted version of the dartdevc-built app anymore.]

This problem did not appear using the old build system under Angular 4.

What seems to be happening is that the <base href="/quickstart/5/"> contained in index.html is being ignored by by main.dart.js:

  var baseUrl = ...
  var el;
  el = document.createElement("script");
  ...
  el.src =
    baseUrl + "packages/$sdk/dev_compiler/web/dart_stack_trace_mapper.js";
 ...

The setting of the baseUrl doesn't seem to take the <base href>.

cc @kwalrath @kevmoo @matanlurey

@matanlurey
Copy link
Contributor

matanlurey commented Jan 23, 2018

The example you are showing is with dartdevc, did you use to do that with v4, or dart2js?

@chalin
Copy link
Contributor Author

chalin commented Jan 23, 2018

No, under v4 we used dart2js.

@matanlurey
Copy link
Contributor

So that's not comparing apples and oranges then :)

Any reason you'd want to deploy dartdevc? That usually isn't desired.

@chalin
Copy link
Contributor Author

chalin commented Jan 23, 2018

Sure, the goal wasn't to compare but to point out the issue.

Any reason you'd want to deploy dartdevc? That usually isn't desired.

Jan 17, 18:13, on Gitter dart-lang/source_gen, we were discussing the building and testing of the Angular example apps. In the end you wrote:

There probably isn’t huge value in running in dart2js
We don’t internally

To which Jacob agreed. Until there is an easier way to switch between web compilers (#801), I was planning on building, testing and deploying using dartdevc.

In any case, if this is a real problem with dartdevc, should I be reporting the issue over dartdevc?

@matanlurey
Copy link
Contributor

@chalin:

deploying using dartdevc

This definitely isn't desirable, for lots of reasons. We don't do this internally.

In any case, if this is a real problem with dartdevc, should I be reporting the issue over dartdevc?

It's not clear to me if this is an issue with dartdevc or not. I'll let @jakemac53 weigh in.

@matanlurey matanlurey added the needs-info Additional information needed from the issue author label Jan 23, 2018
@chalin
Copy link
Contributor Author

chalin commented Jan 23, 2018

My bad, I misunderstood. I'll switch back to deploying using dart2js.

@jakemac53
Copy link
Contributor

The issue here is that it is being deployed under a subdirectory, we don't really have a good solution for that at this time with dartdevc. We should keep this issue open anyways as actually solving it would also allow us to remove some hacks that are currently in place for package:test.

@chalin
Copy link
Contributor Author

chalin commented Jan 24, 2018

Thanks for the feedback @jakemac53.

@matanlurey asked:

The example you are showing is with dartdevc, did you use to do that with v4, or dart2js?

I've tested this locally and I can confirm that this problem doesn't manifest itself when using dart2js.

Note that the script paths created by the default dart2js transformer (or whatever a "transformer" is called under the new build system), have no leading /, e.g.:

<script defer src="packages/browser/dart.js"></script>

As you probably know, the dynamically generated path to, say, require.js does start with a /, e.g.:

<script defer="" src="/packages/$sdk/dev_compiler/amd/require.js" data-main="http://angular-examples.github.io/quickstart/5/main.dart.bootstrap"></script>

(1) So one thing would be to have the dynamic baseUrl computation use "" as a default path rather than /.

(2) The other problem seems to be that required scripts like the following are being dynamically added to the top of the <head> element, before the <base href>:

<script type="text/javascript" charset="utf-8" async="" data-requirecontext="_" data-requiremodule="main.dart.bootstrap" src="http://localhost:8080/web/main.dart.bootstrap.js"></script>

These are async, so couldn't they be added at the end of head? If not, I suppose it is ok for them to be added to the top, but if they are, then any <base href> element should then be relocated to the top too.

WDYT?

@chalin
Copy link
Contributor Author

chalin commented Jan 25, 2018

FYI, the app at http://angular-examples.github.io/quickstart/5 has been replaced by the dart2js version so you won't be able to see a hosted version of the dartdevc-built app anymore.

@matanlurey
Copy link
Contributor

Any actionable item here @chalin?

@chalin
Copy link
Contributor Author

chalin commented Jan 26, 2018

Yes, the problem still stands and, as @jacob314 wrote:

We should keep this issue open anyways as actually solving it would also allow us to remove some hacks that are currently in place for package:test.

@matanlurey
Copy link
Contributor

Great!

@matanlurey matanlurey added type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed needs-info Additional information needed from the issue author labels Jan 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:build_web_compilers type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

3 participants