Skip to content
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

Imports (Clio modules) #72

Closed
5 tasks done
pouya-eghbali opened this issue Dec 24, 2019 · 0 comments · Fixed by #118
Closed
5 tasks done

Imports (Clio modules) #72

pouya-eghbali opened this issue Dec 24, 2019 · 0 comments · Fixed by #118

Comments

@pouya-eghbali
Copy link
Member

pouya-eghbali commented Dec 24, 2019

An import pattern should be added to the lexer, rules should be written for parser and generator, and the necessary runtime (if needed) should be created.

  • Add import pattern in core/patterns.js
  • Add from pattern in core/patterns.js
  • Add parser rules in core/clio.beef
  • Add generator rules in core/generator.js
  • Add required builtins and runtime in core/internals

Import statement should work with below patterns:

import * from module
import name1 name2 name3 from module
import module
import name1 as name2 from module
import module as name

For beef files, there's a vscode addon hosted here:
https://github.com/pouya-eghbali/bean/tree/master/vscode-beef


Discussion:

We need to know how where the compile modules should be stored and how they should be compiled. There are several approaches to this:

  1. Modules are compiled on publish: This will simplify requiring them in compiled code, but it'll make it impossible to import modules from git or other places (not published to Clio package repository).

  2. Modules are fetched and compiled on install:

    • Modules are fetched, compiled, and stored in a clio_modules directory. The clio_modules directory will be published to npm (If the user wants to publish their project to npm). This makes the project size huge. require function should be patched to make this work.

    • Modules are fetched, compiled, and stored in node_modules/clio_modules. This method does not need patching require function, however, if user publishes the package to npm, since the node_modules directory isn't published it will break the module.

    • Fetch and compile Clio dependencies on npm install. We can put Clio dependencies in clioDependencies field of package.json and write a postinstall hook for the package. This way all compiled packages will depend on Clio cli and tools.

@garritfra garritfra changed the title New compiler: Imports (Clio modules) Imports (Clio modules) Dec 24, 2019
@garritfra garritfra mentioned this issue Dec 30, 2019
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants