Comments (3)
@jchip this should be reliable, if it is not that is a bug. There were a bunch of refactorings to this code in eg #2116 and #2114.
If you would like to work on a fix that would be very welcome.
from systemjs.
@guybedford I observed this periodically. It happens a little more as the number of <script>
tags increases. Looking at James Greene's work https://github.com/JamesMGreene/document.currentScript and https://github.com/JamesMGreene/currentExecutingScript it seems we can improve this a bit.
I think a potential change could be:
- Use
document.currentScript
https://developer.mozilla.org/en-US/docs/Web/API/Document/currentScript - Add a
getCurrentScript
hook in case someone wants to provide different logic, such as use James'currentExecutingScript
- Add documentation to note this
A sample proposal for 1 and 2:
systemJSPrototype.getCurrentScript = function () {
if (hasDocument && document.readyState === 'loading') {
if (document.currentScript) {
return document.currentScript;
}
var scripts = document.querySelectorAll('script[src]');
return scripts[scripts.length - 1];
}
return undefined;
};
from systemjs.
I'm open to it - this project once had to support IE, so the constraints may have changed. It's important that whatever is done is tested and correct though!
from systemjs.
Related Issues (20)
- setupProxy.js file not working in single-spa-react
- Apply CSS from nested dependency HOT 2
- worker-load.js conflicts with fetch-load.js and prevents systemjs-babel from working in a web worker
- Updating systemjs from 0.21.5 to latest (6.14.1)
- [NodeJS] Should System.import('my-module') refetch if called twice? HOT 2
- Multiple dependencies bundled in one file (previously "bundles" config option)
- Distribution Files published to npm do not match what is in GitHub for version 16.14.2 (have windows style line breaks)
- Definitelytyped types for system-node.cjs HOT 1
- Top-level await does not wait for its dependencies
- system.min.js doesn't include latest version HOT 1
- Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection') HOT 1
- Support fetchPriority with external import maps HOT 1
- Conflicting SystemJS instances — how to resolve? HOT 6
- Content Security Policy `unsafe-eval` and `unsafe-inline` still required? HOT 1
- I need to prevent SystemJS attempting to load dependencies on Shopify site, urls require a version parameter that SystemJS doesn't know HOT 1
- importMap dependencies error
- Should consumers be aware of `process.env.SYSTEM_PRODUCTION`
- Logging for SystemJS Error#3
- Wrong module content when importing latest react-router-dom versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from systemjs.