bpstrngr / interface Goto Github PK
View Code? Open in Web Editor NEWEcmascript module interface for clients/imports/functions.
Ecmascript module interface for clients/imports/functions.
Interfacing from command line on Node v20.7 blocked by nodejs/node#40110 (comment)
Synchronous circular requires (commonjs equivalent of static default imports)
are individually edited in some sources (CSSOM, JSDOM),
but a generic pattern can be recognized.
The edits are always a delayed reassignment from dynamic import
(const a=require("a")
-> let a;setTimeout(async function expect_hoisted_a()
{import("a").then(({default:module})=>a=module)},3000)
- note that dynamic import is only supported for requires in already async scopes; see issue #9 ),
supported by an equal timeout before the default export of module.exports in the
entry module since the dynamic imports become promise resolutions of hoisted variables
of co-dependent modules stacked lower in the module scope when bundled:
// entry module:
await new Promise(resolve=>setTimeout(resolve,3000));
export default module.exports;
// dependent module:
var codependent;
setTimeout(async function expect_hoisted_dependency()
{import("codependent").then(({default:module})=>codependent=module)
},3000);
export default module.exports;
// codependent module:
import dependent from "dependent";
module.exports={dependent}
export default module.exports;
// bundle:
var codependent;
setTimeout(async function expect_hoisted_a()
{Promise.resolve(dependency).then(({default:module})=>codependent=module)
},3000);
var dependent={default};
var dependency={default:dependent};
await new Promise(resolve=>setTimeout(resolve,3000));
export default module.exports;
Collecting and awaiting the dynamic import reassignments instead of the arbitrary delay at the end of bundle,
as well as gaining access to rollup's hoisted variable name to recursively ascertain the local reassignments,
or potential modifications to the module hierarchy could be further improvements to this generalization.
Git urls in sources currently support an irregular "https://github.com/user/repo/path" signature, with branch nam expected in the value key. A more conventional format would be "https://github.com/user/repo/tree/branch/path", with the value being the entry array directly, and branch name parsed from the url just like the path for parse-checkout.
This should be a minor change.
meta/sanitize currently converts dynamic requires to awaited dynamic imports,
along with making their corresponding enclosing functions async.
This was a tradeoff to support conditional dependency (if(true)require()
) instead of all being hoisted as a static import to keep them synchronous.
Synchronous internal or peer dependant calls to the resulting asynchronized functions can be edited to be async as well, but this can get complex beyond simple library initializations, in eg. opaque object hierarchies.
Such peers, relying extensively on commonjs's synchronous loading of what are supposed to be modules, may deserve to be deprecated.
makes eg. deferred re-import for tests lower in the same function return empty modules unless source buffers are refilled in precedent.
will influence inference - avoid making it monadic here if possible, otherwise merge the #2 issues.
Given the standardized AST-s we have at disposal composably with meta/parse and meta/sanitize, merger and reconciliation of imported namespaces shouldn't be too difficult.
current support is only for committing in astring's format, while original authoring is in aphoristic tacit, but there might be popular demand for eg. prettier too...
depends on #2
sanitization will need to reflect the new AST specification.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.