Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html><head>
<script>(function(a){var b=a.babelHelpers={};b.interopRequireDefault=function(a){return a&&a.__esModule?a:{default:a}},b.interopRequireWildcard=function(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)if(Object.prototype.hasOwnProperty.call(a,c)){var d=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(a,c):{};d.get||d.set?Object.defineProperty(b,c,d):b[c]=a[c]}return b.default=a,b}})("undefined"===typeof global?self:global);</script>
<script>"use strict";(function(){function a(a){var b=i[a];return void 0===b&&(b=i[a]={url:a,urlBase:g(a),exports:Object.create(null),isTopLevel:!1,resolved:!1,needsLoad:!0,error:void 0,onResolve:[],onError:[]}),b}function b(a,b,e){d(a,b,function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];e!==void 0&&e.apply(null,b),a.resolved=!0;for(var d,f=0,g=a.onResolve;f<g.length;f++)d=g[f],d()},function(b){return c(a,b)})}function c(a,b){a.error=b;for(var c,d=0,e=a.onError;d<e.length;d++)c=e[d],c(b)}function d(b,c,f,g){function i(){n--,k()}function j(a){g!==void 0&&!1===o&&(g(a),o=!0)}function k(){0==n&&f!==void 0&&f.apply(null,m)}for(var l,m=[],n=c.length,o=!1,p=0,q=c;p<q.length;p++)if(l=q[p],"exports"===l)n--,m.push(b.exports);else if("require"===l)n--,m.push(function(a,c,e){return d(b,a,c,e)});else if("meta"===l)n--,m.push({url:b.url});else{var r=a(h(b.urlBase,l));if(m.push(r.exports),!0===r.resolved)n--;else{var s=!0===r.isTopLevel?i:j;void 0===r.error?(r.onResolve.push(i),r.onError.push(s),e(r)):s(r.error)}}k()}function e(a){if(!1!==a.needsLoad){a.needsLoad=!1;var d=document.createElement("script");d.src=a.url,d.onload=function(){void 0===j?b(a,[]):j(a)},d.onerror=function(){return c(a,new TypeError("Failed to fetch "+a.url))},document.head.appendChild(d)}}function f(a){return m.href=a,m.href}function g(a){return a=a.split("?")[0],a=a.split("#")[0],a.substring(0,a.lastIndexOf("/")+1)}function h(a,b){return-1===b.indexOf("://")?f(a+b):b}var i=Object.create(null),j=void 0,k=0,l=void 0;window.define=function(c,d){var e=!1;j=function(a){e=!0,j=void 0,b(a,c,d)},setTimeout(function(){if(!1==e){j=void 0;var f=document.baseURI+"#"+k++,g=a(f);g.isTopLevel=!0,g.needsLoad=!1,l!==void 0&&c.push(l),l=f,b(g,c,d)}},0)},window.define._reset=function(){for(var a in i)delete i[a];j=void 0,k=0,l=void 0};var m=document.createElement("a")})();</script>
<script>"use strict";(function(){function a(a){var b=i[a];return void 0===b&&(b=i[a]={url:a,urlBase:g(a),exports:Object.create(null),isTopLevel:!1,resolved:!1,needsLoad:!0,error:void 0,onResolve:[],onError:[]}),b}function b(a,b,e){d(a,b,function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];e!==void 0&&e.apply(null,b),a.resolved=!0;for(var d,f=0,g=a.onResolve;f<g.length;f++)d=g[f],d()},function(b){return c(a,b)})}function c(a,b){a.error=b;for(var c,d=0,e=a.onError;d<e.length;d++)c=e[d],c(b)}function d(b,c,f,g){function i(){n--,k()}function j(a){g!==void 0&&!1===o&&(g(a),o=!0)}function k(){0==n&&f!==void 0&&f.apply(null,m)}for(var l,m=[],n=c.length,o=!1,p=0,q=c;p<q.length;p++)if(l=q[p],"exports"===l)n--,m.push(b.exports);else if("require"===l)n--,m.push(function(a,c,e){return d(b,a,c,e)});else if("meta"===l)n--,m.push({url:!0===b.isTopLevel?b.url.substring(0,b.url.lastIndexOf("#")):b.url});else{var r=a(h(b.urlBase,l));if(m.push(r.exports),!0===r.resolved)n--;else{var s=!0===r.isTopLevel?i:j;void 0===r.error?(r.onResolve.push(i),r.onError.push(s),e(r)):s(r.error)}}k()}function e(a){if(!1!==a.needsLoad){a.needsLoad=!1;var d=document.createElement("script");d.src=a.url,d.onload=function(){void 0===j?b(a,[]):j(a)},d.onerror=function(){return c(a,new TypeError("Failed to fetch "+a.url))},document.head.appendChild(d)}}function f(a){return m.href=a,m.href}function g(a){return a=a.split("?")[0],a=a.split("#")[0],a.substring(0,a.lastIndexOf("/")+1)}function h(a,b){return-1===b.indexOf("://")?f(a+b):b}var i=Object.create(null),j=void 0,k=0,l=void 0;window.define=function(c,d){var e=!1;j=function(a){e=!0,j=void 0,b(a,c,d)},setTimeout(function(){if(!1==e){j=void 0;var f=document.baseURI+"#"+k++,g=a(f);g.isTopLevel=!0,g.needsLoad=!1,l!==void 0&&c.push(l),l=f,b(g,c,d)}},0)},window.define._reset=function(){for(var a in i)delete i[a];j=void 0,k=0,l=void 0};var m=document.createElement("a")})();</script>
<script>define(['shared_bundle_1.js']);</script>
</head>
<body>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<html><head>
<script>(function(a){var b=a.babelHelpers={};b.interopRequireDefault=function(a){return a&&a.__esModule?a:{default:a}},b.interopRequireWildcard=function(a){if(a&&a.__esModule)return a;var b={};if(null!=a)for(var c in a)if(Object.prototype.hasOwnProperty.call(a,c)){var d=Object.defineProperty&&Object.getOwnPropertyDescriptor?Object.getOwnPropertyDescriptor(a,c):{};d.get||d.set?Object.defineProperty(b,c,d):b[c]=a[c]}return b.default=a,b}})("undefined"===typeof global?self:global);</script>
<script>"use strict";(function(){function a(a){var b=i[a];return void 0===b&&(b=i[a]={url:a,urlBase:g(a),exports:Object.create(null),isTopLevel:!1,resolved:!1,needsLoad:!0,error:void 0,onResolve:[],onError:[]}),b}function b(a,b,e){d(a,b,function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];e!==void 0&&e.apply(null,b),a.resolved=!0;for(var d,f=0,g=a.onResolve;f<g.length;f++)d=g[f],d()},function(b){return c(a,b)})}function c(a,b){a.error=b;for(var c,d=0,e=a.onError;d<e.length;d++)c=e[d],c(b)}function d(b,c,f,g){function i(){n--,k()}function j(a){g!==void 0&&!1===o&&(g(a),o=!0)}function k(){0==n&&f!==void 0&&f.apply(null,m)}for(var l,m=[],n=c.length,o=!1,p=0,q=c;p<q.length;p++)if(l=q[p],"exports"===l)n--,m.push(b.exports);else if("require"===l)n--,m.push(function(a,c,e){return d(b,a,c,e)});else if("meta"===l)n--,m.push({url:b.url});else{var r=a(h(b.urlBase,l));if(m.push(r.exports),!0===r.resolved)n--;else{var s=!0===r.isTopLevel?i:j;void 0===r.error?(r.onResolve.push(i),r.onError.push(s),e(r)):s(r.error)}}k()}function e(a){if(!1!==a.needsLoad){a.needsLoad=!1;var d=document.createElement("script");d.src=a.url,d.onload=function(){void 0===j?b(a,[]):j(a)},d.onerror=function(){return c(a,new TypeError("Failed to fetch "+a.url))},document.head.appendChild(d)}}function f(a){return m.href=a,m.href}function g(a){return a=a.split("?")[0],a=a.split("#")[0],a.substring(0,a.lastIndexOf("/")+1)}function h(a,b){return-1===b.indexOf("://")?f(a+b):b}var i=Object.create(null),j=void 0,k=0,l=void 0;window.define=function(c,d){var e=!1;j=function(a){e=!0,j=void 0,b(a,c,d)},setTimeout(function(){if(!1==e){j=void 0;var f=document.baseURI+"#"+k++,g=a(f);g.isTopLevel=!0,g.needsLoad=!1,l!==void 0&&c.push(l),l=f,b(g,c,d)}},0)},window.define._reset=function(){for(var a in i)delete i[a];j=void 0,k=0,l=void 0};var m=document.createElement("a")})();</script>
<script>"use strict";(function(){function a(a){var b=i[a];return void 0===b&&(b=i[a]={url:a,urlBase:g(a),exports:Object.create(null),isTopLevel:!1,resolved:!1,needsLoad:!0,error:void 0,onResolve:[],onError:[]}),b}function b(a,b,e){d(a,b,function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];e!==void 0&&e.apply(null,b),a.resolved=!0;for(var d,f=0,g=a.onResolve;f<g.length;f++)d=g[f],d()},function(b){return c(a,b)})}function c(a,b){a.error=b;for(var c,d=0,e=a.onError;d<e.length;d++)c=e[d],c(b)}function d(b,c,f,g){function i(){n--,k()}function j(a){g!==void 0&&!1===o&&(g(a),o=!0)}function k(){0==n&&f!==void 0&&f.apply(null,m)}for(var l,m=[],n=c.length,o=!1,p=0,q=c;p<q.length;p++)if(l=q[p],"exports"===l)n--,m.push(b.exports);else if("require"===l)n--,m.push(function(a,c,e){return d(b,a,c,e)});else if("meta"===l)n--,m.push({url:!0===b.isTopLevel?b.url.substring(0,b.url.lastIndexOf("#")):b.url});else{var r=a(h(b.urlBase,l));if(m.push(r.exports),!0===r.resolved)n--;else{var s=!0===r.isTopLevel?i:j;void 0===r.error?(r.onResolve.push(i),r.onError.push(s),e(r)):s(r.error)}}k()}function e(a){if(!1!==a.needsLoad){a.needsLoad=!1;var d=document.createElement("script");d.src=a.url,d.onload=function(){void 0===j?b(a,[]):j(a)},d.onerror=function(){return c(a,new TypeError("Failed to fetch "+a.url))},document.head.appendChild(d)}}function f(a){return m.href=a,m.href}function g(a){return a=a.split("?")[0],a=a.split("#")[0],a.substring(0,a.lastIndexOf("/")+1)}function h(a,b){return-1===b.indexOf("://")?f(a+b):b}var i=Object.create(null),j=void 0,k=0,l=void 0;window.define=function(c,d){var e=!1;j=function(a){e=!0,j=void 0,b(a,c,d)},setTimeout(function(){if(!1==e){j=void 0;var f=document.baseURI+"#"+k++,g=a(f);g.isTopLevel=!0,g.needsLoad=!1,l!==void 0&&c.push(l),l=f,b(g,c,d)}},0)},window.define._reset=function(){for(var a in i)delete i[a];j=void 0,k=0,l=void 0};var m=document.createElement("a")})();</script>
<script>define(['./mod1.js']);</script>
</head>
<body>
Expand Down
4 changes: 3 additions & 1 deletion packages/esm-amd-loader/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

<!-- # Unreleased -->
# Unreleased
* Fix bug where the `import.meta.url` of a top-level module had an artificial
anchor suffix (e.g. "http://example.com/foo#3").
<!-- Add new, unreleased changes here. -->

## [0.1.0] - 2018-05-01
Expand Down
10 changes: 9 additions & 1 deletion packages/esm-amd-loader/src/esm-amd-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,15 @@ function require(

} else if (depSpec === 'meta') {
numUnresolvedDeps--;
args.push({url: mod.url});
args.push({
// We append "#<script index>" to top-level scripts so that they have
// unique keys in the registry. We don't want to see that here. Note
// that the real base URL may legitimately have an anchor, so it's not
// safe to trim the anchor of non-top-level script URLs.
url: mod.isTopLevel === true ?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style nit: I definitely prefer putting parens around the ternary condition.

mod.url.substring(0, mod.url.lastIndexOf('#')) :
mod.url
});

} else {
const depMod = getModule(resolveUrl(mod.urlBase, depSpec));
Expand Down
2 changes: 1 addition & 1 deletion packages/esm-amd-loader/test/src/suite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ suite('dynamic require', () => {
suite('meta.url', () => {
test('top-level HTML document', (done) => {
define(['meta'], (meta: any) => {
assert.equal(meta.url.split('#')[0], document.baseURI);
assert.equal(meta.url, document.baseURI);
done();
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html><html><body>
<script>"use strict";(function(){function a(a){var b=i[a];return void 0===b&&(b=i[a]={url:a,urlBase:g(a),exports:Object.create(null),isTopLevel:!1,resolved:!1,needsLoad:!0,error:void 0,onResolve:[],onError:[]}),b}function b(a,b,e){d(a,b,function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];e!==void 0&&e.apply(null,b),a.resolved=!0;for(var d,f=0,g=a.onResolve;f<g.length;f++)d=g[f],d()},function(b){return c(a,b)})}function c(a,b){a.error=b;for(var c,d=0,e=a.onError;d<e.length;d++)c=e[d],c(b)}function d(b,c,f,g){function i(){n--,k()}function j(a){g!==void 0&&!1===o&&(g(a),o=!0)}function k(){0==n&&f!==void 0&&f.apply(null,m)}for(var l,m=[],n=c.length,o=!1,p=0,q=c;p<q.length;p++)if(l=q[p],"exports"===l)n--,m.push(b.exports);else if("require"===l)n--,m.push(function(a,c,e){return d(b,a,c,e)});else if("meta"===l)n--,m.push({url:b.url});else{var r=a(h(b.urlBase,l));if(m.push(r.exports),!0===r.resolved)n--;else{var s=!0===r.isTopLevel?i:j;void 0===r.error?(r.onResolve.push(i),r.onError.push(s),e(r)):s(r.error)}}k()}function e(a){if(!1!==a.needsLoad){a.needsLoad=!1;var d=document.createElement("script");d.src=a.url,d.onload=function(){void 0===j?b(a,[]):j(a)},d.onerror=function(){return c(a,new TypeError("Failed to fetch "+a.url))},document.head.appendChild(d)}}function f(a){return m.href=a,m.href}function g(a){return a=a.split("?")[0],a=a.split("#")[0],a.substring(0,a.lastIndexOf("/")+1)}function h(a,b){return-1===b.indexOf("://")?f(a+b):b}var i=Object.create(null),j=void 0,k=0,l=void 0;window.define=function(c,d){var e=!1;j=function(a){e=!0,j=void 0,b(a,c,d)},setTimeout(function(){if(!1==e){j=void 0;var f=document.baseURI+"#"+k++,g=a(f);g.isTopLevel=!0,g.needsLoad=!1,l!==void 0&&c.push(l),l=f,b(g,c,d)}},0)},window.define._reset=function(){for(var a in i)delete i[a];j=void 0,k=0,l=void 0};var m=document.createElement("a")})();</script>
<script>"use strict";(function(){function a(a){var b=i[a];return void 0===b&&(b=i[a]={url:a,urlBase:g(a),exports:Object.create(null),isTopLevel:!1,resolved:!1,needsLoad:!0,error:void 0,onResolve:[],onError:[]}),b}function b(a,b,e){d(a,b,function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];e!==void 0&&e.apply(null,b),a.resolved=!0;for(var d,f=0,g=a.onResolve;f<g.length;f++)d=g[f],d()},function(b){return c(a,b)})}function c(a,b){a.error=b;for(var c,d=0,e=a.onError;d<e.length;d++)c=e[d],c(b)}function d(b,c,f,g){function i(){n--,k()}function j(a){g!==void 0&&!1===o&&(g(a),o=!0)}function k(){0==n&&f!==void 0&&f.apply(null,m)}for(var l,m=[],n=c.length,o=!1,p=0,q=c;p<q.length;p++)if(l=q[p],"exports"===l)n--,m.push(b.exports);else if("require"===l)n--,m.push(function(a,c,e){return d(b,a,c,e)});else if("meta"===l)n--,m.push({url:!0===b.isTopLevel?b.url.substring(0,b.url.lastIndexOf("#")):b.url});else{var r=a(h(b.urlBase,l));if(m.push(r.exports),!0===r.resolved)n--;else{var s=!0===r.isTopLevel?i:j;void 0===r.error?(r.onResolve.push(i),r.onError.push(s),e(r)):s(r.error)}}k()}function e(a){if(!1!==a.needsLoad){a.needsLoad=!1;var d=document.createElement("script");d.src=a.url,d.onload=function(){void 0===j?b(a,[]):j(a)},d.onerror=function(){return c(a,new TypeError("Failed to fetch "+a.url))},document.head.appendChild(d)}}function f(a){return m.href=a,m.href}function g(a){return a=a.split("?")[0],a=a.split("#")[0],a.substring(0,a.lastIndexOf("/")+1)}function h(a,b){return-1===b.indexOf("://")?f(a+b):b}var i=Object.create(null),j=void 0,k=0,l=void 0;window.define=function(c,d){var e=!1;j=function(a){e=!0,j=void 0,b(a,c,d)},setTimeout(function(){if(!1==e){j=void 0;var f=document.baseURI+"#"+k++,g=a(f);g.isTopLevel=!0,g.needsLoad=!1,l!==void 0&&c.push(l),l=f,b(g,c,d)}},0)},window.define._reset=function(){for(var a in i)delete i[a];j=void 0,k=0,l=void 0};var m=document.createElement("a")})();</script>
<script>define(["./lib.js"], function (_lib) {
"use strict";
});</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
<script nomodule="">const foo = 'bar';</script>


</body></html>
</body></html>
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</head>

<body>
<script>"use strict";(function(){function a(a){var b=i[a];return void 0===b&&(b=i[a]={url:a,urlBase:g(a),exports:Object.create(null),isTopLevel:!1,resolved:!1,needsLoad:!0,error:void 0,onResolve:[],onError:[]}),b}function b(a,b,e){d(a,b,function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];e!==void 0&&e.apply(null,b),a.resolved=!0;for(var d,f=0,g=a.onResolve;f<g.length;f++)d=g[f],d()},function(b){return c(a,b)})}function c(a,b){a.error=b;for(var c,d=0,e=a.onError;d<e.length;d++)c=e[d],c(b)}function d(b,c,f,g){function i(){n--,k()}function j(a){g!==void 0&&!1===o&&(g(a),o=!0)}function k(){0==n&&f!==void 0&&f.apply(null,m)}for(var l,m=[],n=c.length,o=!1,p=0,q=c;p<q.length;p++)if(l=q[p],"exports"===l)n--,m.push(b.exports);else if("require"===l)n--,m.push(function(a,c,e){return d(b,a,c,e)});else if("meta"===l)n--,m.push({url:b.url});else{var r=a(h(b.urlBase,l));if(m.push(r.exports),!0===r.resolved)n--;else{var s=!0===r.isTopLevel?i:j;void 0===r.error?(r.onResolve.push(i),r.onError.push(s),e(r)):s(r.error)}}k()}function e(a){if(!1!==a.needsLoad){a.needsLoad=!1;var d=document.createElement("script");d.src=a.url,d.onload=function(){void 0===j?b(a,[]):j(a)},d.onerror=function(){return c(a,new TypeError("Failed to fetch "+a.url))},document.head.appendChild(d)}}function f(a){return m.href=a,m.href}function g(a){return a=a.split("?")[0],a=a.split("#")[0],a.substring(0,a.lastIndexOf("/")+1)}function h(a,b){return-1===b.indexOf("://")?f(a+b):b}var i=Object.create(null),j=void 0,k=0,l=void 0;window.define=function(c,d){var e=!1;j=function(a){e=!0,j=void 0,b(a,c,d)},setTimeout(function(){if(!1==e){j=void 0;var f=document.baseURI+"#"+k++,g=a(f);g.isTopLevel=!0,g.needsLoad=!1,l!==void 0&&c.push(l),l=f,b(g,c,d)}},0)},window.define._reset=function(){for(var a in i)delete i[a];j=void 0,k=0,l=void 0};var m=document.createElement("a")})();</script>
<script>"use strict";(function(){function a(a){var b=i[a];return void 0===b&&(b=i[a]={url:a,urlBase:g(a),exports:Object.create(null),isTopLevel:!1,resolved:!1,needsLoad:!0,error:void 0,onResolve:[],onError:[]}),b}function b(a,b,e){d(a,b,function(){for(var b=[],c=0;c<arguments.length;c++)b[c]=arguments[c];e!==void 0&&e.apply(null,b),a.resolved=!0;for(var d,f=0,g=a.onResolve;f<g.length;f++)d=g[f],d()},function(b){return c(a,b)})}function c(a,b){a.error=b;for(var c,d=0,e=a.onError;d<e.length;d++)c=e[d],c(b)}function d(b,c,f,g){function i(){n--,k()}function j(a){g!==void 0&&!1===o&&(g(a),o=!0)}function k(){0==n&&f!==void 0&&f.apply(null,m)}for(var l,m=[],n=c.length,o=!1,p=0,q=c;p<q.length;p++)if(l=q[p],"exports"===l)n--,m.push(b.exports);else if("require"===l)n--,m.push(function(a,c,e){return d(b,a,c,e)});else if("meta"===l)n--,m.push({url:!0===b.isTopLevel?b.url.substring(0,b.url.lastIndexOf("#")):b.url});else{var r=a(h(b.urlBase,l));if(m.push(r.exports),!0===r.resolved)n--;else{var s=!0===r.isTopLevel?i:j;void 0===r.error?(r.onResolve.push(i),r.onError.push(s),e(r)):s(r.error)}}k()}function e(a){if(!1!==a.needsLoad){a.needsLoad=!1;var d=document.createElement("script");d.src=a.url,d.onload=function(){void 0===j?b(a,[]):j(a)},d.onerror=function(){return c(a,new TypeError("Failed to fetch "+a.url))},document.head.appendChild(d)}}function f(a){return m.href=a,m.href}function g(a){return a=a.split("?")[0],a=a.split("#")[0],a.substring(0,a.lastIndexOf("/")+1)}function h(a,b){return-1===b.indexOf("://")?f(a+b):b}var i=Object.create(null),j=void 0,k=0,l=void 0;window.define=function(c,d){var e=!1;j=function(a){e=!0,j=void 0,b(a,c,d)},setTimeout(function(){if(!1==e){j=void 0;var f=document.baseURI+"#"+k++,g=a(f);g.isTopLevel=!0,g.needsLoad=!1,l!==void 0&&c.push(l),l=f,b(g,c,d)}},0)},window.define._reset=function(){for(var a in i)delete i[a];j=void 0,k=0,l=void 0};var m=document.createElement("a")})();</script>
<script>
// Injected by polymer-build to defer WCT until all AMD modules are loaded.
(function() {
Expand Down