Override babel module loading more generally, to ensure proper state is picked up for the Syndicate extensions
This commit is contained in:
parent
e8f6337266
commit
a0c6b54d55
|
@ -16,8 +16,7 @@
|
|||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
const Timer = activate require("@syndicate-lang/driver-timer");
|
||||
const TimeLaterThan = Timer.TimeLaterThan;
|
||||
const { TimeLaterThan } = activate require("@syndicate-lang/driver-timer");
|
||||
|
||||
spawn named 'ticker' {
|
||||
field this.counter = 0;
|
||||
|
@ -34,4 +33,3 @@ spawn named 'ticker' {
|
|||
|
||||
stop on (this.counter == 5);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
- [DONE] `during/spawn`
|
||||
- [DONE] `during`
|
||||
- [DONE] `let { TimeLaterThan } = activate require("@syndicate-lang/driver-timer");`
|
||||
- [DONE] `react`
|
||||
- [DONE] `spawn*` or similar - looks like `spawn on start { ... }` will do the trick
|
||||
- [DONE] activation
|
||||
- [DONE] remove ground dataspace syntax
|
||||
|
||||
- `defer` statement
|
||||
- `define/query`
|
||||
- `let { TimeLaterThan } = activate require("@syndicate-lang/driver-timer");`
|
||||
- some kind of `stop facet` statement - put a Symbol on the fields blob?
|
||||
- web pack
|
||||
|
||||
|
|
|
@ -98,6 +98,7 @@ BabelParser.__setParser(require("./parser").default);
|
|||
// This is mostly optional, unless for some reason we want only the
|
||||
// syntax extension but not the transform (e.g. if the plugin omitted
|
||||
// its `visitor`).
|
||||
var Generator = require("@babel/generator"); // needed for _load override, below
|
||||
var Generators = require("@babel/generator/lib/generators");
|
||||
var SyndicateGenerators = require("./generators");
|
||||
Object.keys(SyndicateGenerators).forEach((f) => {
|
||||
|
@ -105,5 +106,24 @@ Object.keys(SyndicateGenerators).forEach((f) => {
|
|||
});
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// (5) At this point, we should (?) be able to load and use Babel
|
||||
// (5) Ensure that, no matter where we are when some module `require`s
|
||||
// one of our patched modules, we give them the patched version. This
|
||||
// is ultra disgusting.
|
||||
|
||||
(function () {
|
||||
const Module = require('module');
|
||||
const _oldLoad = Module._load;
|
||||
Module._load = function (request, parent) {
|
||||
if (!parent) return _oldLoad.apply(this, arguments);
|
||||
switch (request) {
|
||||
case "@babel/parser": return BabelParser;
|
||||
case "@babel/types": return Types;
|
||||
case "@babel/generator": return Generator;
|
||||
default: return _oldLoad.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
// (6) At this point, we should (?) be able to load and use Babel
|
||||
// somewhat normally.
|
||||
|
|
Loading…
Reference in New Issue