Skip to content

Commit

Permalink
experimental remove of throwing exceptions when module loading
Browse files Browse the repository at this point in the history
SQUASHED: AUTO-COMMIT-src-client-tree-sitter.js,AUTO-COMMIT-src-external-systemjs-system.6.14.js,AUTO-COMMIT-src-systemjs-config.js,
  • Loading branch information
JensLincke committed Oct 5, 2023
1 parent 212102a commit 175febb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/client/tree-sitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
[test](edit://test/tree-sitter-test.js) [demo](browse://demos/tree-sitter/matches.md)
MD*/

import PriorityQueue from "src/external/priority-queue.js"
import _ from 'src/external/lodash/lodash.js'

Expand Down
8 changes: 7 additions & 1 deletion src/external/systemjs/system.6.14.js
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,13 @@
};

function throwUnresolved (id, parentUrl) {
throw Error(errMsg(8, "Unable to resolve bare specifier '" + id + (parentUrl ? "' from " + parentUrl : "'")));
// BEGIN Lively4 Modification
if (systemJSPrototype.throwUnresolved) {
return systemJSPrototype.throwUnresolved(id, parentUrl)
} else {
throw Error(errMsg(8, "Unable to resolve bare specifier '" + id + (parentUrl ? "' from " + parentUrl : "'")));
}
// END Lively4 Modification
}

var systemInstantiate = systemJSPrototype.instantiate;
Expand Down
20 changes: 20 additions & 0 deletions src/systemjs-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ async function systemFetch(url, options) {
systemJSPrototype.fetch = systemFetch




systemJSPrototype.shouldFetch = function () {
return true;
};
Expand Down Expand Up @@ -633,6 +635,15 @@ function systemResolve(id, parentUrl) {
} catch(e) {
result = orginalResolve.call(this, lively4url + "/" + id, parentUrl) // try harder!
}
if (!result) {
result = orginalResolve.call(this, lively4url + "/" + id, parentUrl) // try harder! new version without exceptions

// throw Error("Unable to resolve " + id + " in " + parentUrl)
}
if (!result) {
throw Error("Unable to resolve " + id + " in " + parentUrl)
}

result = result.replace(/([^:]\/)\/+/g, "$1"); // remove double slashes

// #TODO maybe use this browser API to resolve id in parentUrl
Expand All @@ -642,6 +653,15 @@ function systemResolve(id, parentUrl) {
}
systemResolve.originalFunction = orginalResolve

// Lively4 introduced custom hook to prevent throwing an error
systemJSPrototype.throwUnresolved = function(id, parentUrl) {
// console.warn("SYSTEMJS could not resolve " + id + " in " + parentUrl)
// throw new Error("could not resolve " + id + " in " + parentUrl)

return false // do nothing
}


System.constructor.prototype.resolve = systemResolve
System.constructor.prototype.normalizeSync = systemResolve

Expand Down

0 comments on commit 175febb

Please sign in to comment.