-
-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reusable third-party module support #98
Comments
Dome Module ImportsFor simplifying code reutilization and modularization, modules.wrenThis is a simple wren file that contains var Imports = {
"domepunk": "modules/domepunk/dp.wren",
"domepunk/": "modules/domepunk", // allow imports for files inside the domepunk/ dir
} On startup DOME will load this file (if exists) and store the paths for reference later The filename could be overrited using tar filesPaths that end with tar will be considered as a tar file. var Imports = {
"domepunk": "modules/domepunk.tar",
"domepunk/math": "modules/domepunk.tar@science/math"
} importing
// Will use the math module path defined in modules.wren
import "@math" for Math
// Will use the same path for the _dome_ executable as the base path. if not found will look into the modules.wren path
import "/math" for Math
// Will use the _file_ path as base path. Then it will look for the _main.wren_ base path. Then it will look for _modules.wren_ path. Finally it will look for the _dome_ executable base path.
import "./math" for Math
// First it will look for the internal modules. Then it will use the _main.wren_ base path. Then it will look for the _file_ base path. if not found will look into the modules.wren path. Finally it will use the _dome_ executable base path.
import "hello" for Hello default nameModules can define a default main.wren file that will be loaded by default if no file is specified for the path. |
Based on the proof on concept. This is the proposed algorithm for resolving imports.
import "domepunk" for Dp
import "domepunk/utils/clock" for Clock
import "../domepunk/utils/clock" for Clock
[imports]
domepunk = examples/ |
The goal of this issue is to discuss the implementation of something like NodeJS or Python modules, which can be developed and distributed for use across multiple projects with ease.
Any changes to the module-loading system should be backwards compatible with current projects, otherwise we will have to defer it to DOME 2.0.0
I think my own preference would be to extend the
.egg/.tar
loading system and use that file format for distributing modules.As far as indicating that part of a module is being imported, I'd expect something like:
or, possibly allowing access to sub-files within a module using:
The hard bit is that DOME would need to keep track of which "module context" it was in, in order to resolve modules properly, as well as other rabbit-hole issues.
The text was updated successfully, but these errors were encountered: