Skip to content

Commit

Permalink
Avoid breaking backwards compatibility for asset URLs.
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamn committed Dec 11, 2017
1 parent 5df915b commit 5db2bc6
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/http/httpcall_tests.js
Expand Up @@ -487,7 +487,7 @@ if (Meteor.isServer) {

function do_test(path, code, match) {
const prefix = Meteor.isModern
? "/__browser"
? "" // No prefix for web.browser (modern).
: "/__browser.legacy";

HTTP.get(url_base() + prefix + path, {
Expand Down
3 changes: 3 additions & 0 deletions packages/modern-browsers/TODO.md
Expand Up @@ -12,6 +12,9 @@
- [x] Really vet the set of imported `core-js` polyfills based on known
minimum versions imposed by `setMinimumBrowserVersions`.

- [x] Make sure the new url prefixes aren't too disruptive for public
assets like images.

- [ ] Create an `isobuild:web-browser-legacy` pseudopackage.

- [ ] Add tests to the `modules` test app.
Expand Down
15 changes: 14 additions & 1 deletion tools/isobuild/bundler.js
Expand Up @@ -576,7 +576,20 @@ class File {
this.url = null;

// A prefix that will be prepended to this.url.
if (options.arch.startsWith("web.")) {
if (options.arch.startsWith("web.") &&
// Use /__browser.legacy/... as a prefix for web.browser.legacy
// URLs, but avoid adding a special prefix to resource URLs for
// modern browsers. Though boilerplate-generator will happily use
// whatever URLs we invent here, it's important that assets like
// images are available from predictable URLs (without any
// arch-specific prefixes), since humans might use those URLs in
// hand-written code. Moreover, non-JS assets are typically the
// same for both modern and legacy browsers, so the URL prefix
// doesn't actually make a difference. In the unlikely event that
// someone adds different assets with the same path to web.browser
// and web.browser.legacy, the legacy version can always be
// fetched from the /__browser.legacy/... URL.
options.arch !== "web.browser") {
this.urlPrefix = "/__" +
options.arch.split(".").slice(1).join(".");
} else {
Expand Down
5 changes: 4 additions & 1 deletion tools/tests/compiler-plugins.js
Expand Up @@ -393,7 +393,10 @@ selftest.define("compiler plugins - compiler throws", () => {
});

function checkModernAndLegacyUrls(path, test) {
test(getUrl("http://localhost:3000/__browser" + path));
if (! path.startsWith("/")) {
path = "/" + path;
}
test(getUrl("http://localhost:3000" + path));
test(getUrl("http://localhost:3000/__browser.legacy" + path));
}

Expand Down
6 changes: 5 additions & 1 deletion tools/tests/modules.js
Expand Up @@ -11,6 +11,7 @@ function startRun(sandbox) {
run.match("myapp");
run.match("proxy");
run.tellMongo(MONGO_LISTENING);
run.waitSecs(20);
run.match("MongoDB");
return run;
};
Expand Down Expand Up @@ -94,6 +95,9 @@ selftest.define("modules - import chain for packages", () => {
});

function checkModernAndLegacyUrls(path, test) {
test(getUrl("http://localhost:3000/__browser" + path));
if (! path.startsWith("/")) {
path = "/" + path;
}
test(getUrl("http://localhost:3000" + path));
test(getUrl("http://localhost:3000/__browser.legacy" + path));
}

0 comments on commit 5db2bc6

Please sign in to comment.