Skip to content

Commit

Permalink
Remove no longer relevant usage of require.js stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
web-padawan committed May 4, 2018
1 parent 7e2ddd1 commit 9895343
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions vaadin-development-mode-detector.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,17 @@
return htmlImports;
}

function getEsModules() {
// native ES modules
const modules = document.querySelectorAll("script[type=module]");

// require.js modules
const require = document.querySelectorAll("script[data-requiremodule]");

return Array.from(modules).concat(Array.from(require));
}

function isUnbundled() {
if (useHtmlImports) {
// If the app is bundled, then polymer.html should be included in some bundle and not in `polymer/polymer.html`
const htmlImports = getHtmlImports(document, []);
return htmlImports.filter(function(href) { return endsWith(href, "polymer/polymer-element.html")}).length > 0;
} else {
const modules = getEsModules();
return modules.filter(function (m) { return m.src.indexOf("vaadin-") > -1 }).length > 0;
const scripts = Array.from(document.querySelectorAll("script"));
// TODO(web-padawan): this is not expected to work for applications using native ES modules,
// since the index.html is unlikely to contain any direct imports of Vaadin components.
// It works with the AMD transform of CLI, as the <script> tags are being added to <head>.
return scripts.filter(script => script.src.indexOf("@vaadin") > -1).length > 0;
}
}

Expand Down

0 comments on commit 9895343

Please sign in to comment.