Simple file import system #711
Replies: 7 comments 8 replies
-
My idea is this:
@import /a/b/c //for preprocessor Cons:
|
Beta Was this translation helpful? Give feedback.
-
I realized that what we really have now is a very simple By |
Beta Was this translation helpful? Give feedback.
-
I'm a bit confused by some of the complexity in the proposals above, feels like I'm missing something about why this is more complex than it seems, but I'll dump my impressions on this topic here anyway, hope it'll help. Imports probably shouldn't depend on CLI / CLI code shouldn't implement importing logic, since there can be other execution environments in which imports are needed. I believe import statements shouldn't include the raw filesystem paths, there should be an abstraction layer + probably something like I don't understand why preprocessor is needed. I imagine something like:
|
Beta Was this translation helpful? Give feedback.
-
Notes. |
Beta Was this translation helpful? Give feedback.
-
Thanks! Will you update the cli/explain how to do imports? |
Beta Was this translation helpful? Give feedback.
-
Being new to Squiggle, I'm trying to build a simple cost estimation for our IT department using the VS Code extension. How would I import my "common" functions (common.squiggle) into an actual estimate file? |
Beta Was this translation helpful? Give feedback.
-
We have something for this now (mainly for squiggle hub), will close. Feel free to make new issues/discussions for changes/improvements! |
Beta Was this translation helpful? Give feedback.
-
It seems like it's fairly important to have some sort of simple file import system.
One tricky thing is that the import system clearly requires both interpreter work, but also some command line interface / bash work. I'm not used to these things, so am guessing on what a good way would be for this.
Key Steps
My guess is something like:
import AIModel from "models/ai_model_1.squiggle"
, at the top of their Squiggle files. All file paths are absolute, from the root of the main directory (for simplicity, I'm not sure though).parseAndListImports
command.run(squiggleString, bindings, environment, jsonImports, Imports: [{fileName: "foo/bar.squiggle", contents: "..."}])
. We rename the currentimports
tojsonImports
. (Or maybe we saystaticImports
vs.dynamicImports
or something)One question is how to handle situations where A imports B which imports C. In this case, either all of that information could be brought into
squiggleImports
, or the CLI could be responsible for packaging up everything in A into B, before passing into C.CLI Work
The CLI would have a specific process for doing all of this work. First, it would have a watcher to check:
Bundling
We might want to make it possible to bundle a squiggle file; replacing all the imports with the actual code. This would make it easier to copy+paste the results into other systems. The process is pretty simple.
Beta Was this translation helpful? Give feedback.
All reactions