{"id":23209060,"url":"https://github.com/soiu/rapydscript-plugin","last_synced_at":"2025-04-05T12:10:02.273Z","repository":{"id":48962264,"uuid":"364842090","full_name":"soIu/rapydscript-plugin","owner":"soIu","description":"Babel plugin to load Python/RapydScript code","archived":false,"fork":false,"pushed_at":"2022-02-15T14:30:23.000Z","size":378,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-16T18:04:53.648Z","etag":null,"topics":["babel","babel-plugin","loader","python","rapydscript","transpiler"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/soIu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-06T08:40:11.000Z","updated_at":"2022-09-15T14:53:19.000Z","dependencies_parsed_at":"2022-09-24T00:51:57.877Z","dependency_job_id":null,"html_url":"https://github.com/soIu/rapydscript-plugin","commit_stats":null,"previous_names":["rafi16jan/babel-plugin-rapydscript"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soIu%2Frapydscript-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soIu%2Frapydscript-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soIu%2Frapydscript-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/soIu%2Frapydscript-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/soIu","download_url":"https://codeload.github.com/soIu/rapydscript-plugin/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332610,"owners_count":20921853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["babel","babel-plugin","loader","python","rapydscript","transpiler"],"created_at":"2024-12-18T18:14:20.495Z","updated_at":"2025-04-05T12:10:02.238Z","avatar_url":"https://github.com/soIu.png","language":"JavaScript","readme":"# babel-plugin-rapydscript\nBabel plugin to load Python/RapydScript code\n\n# Installation\n\n```\nnpm install babel-plugin-rapydscript\n```\n\nThen add 'rapydscript' to your babel plugins wether it's on babelrc, babel.config.json or if you use a bundler usually they add directives for you to add babel plugins (if the bundler use babel or is configured to use babel as a loader).\n\n# Example Usage\n\nIn any of your JS code, require a py file:\n\n```js\n//index.js\n\n//Either ES6 import or CommonJS' require works, dynamic import is still on the work\nimport from_python from './test.py';\nconst same_object_from_python = require('./test.py');\n\nconsole.log(from_python === same_object_from_python);\nconsole.log(from_python);\n```\n\nAnd in your Python/RapydScript code:\n\n```python\n#test.py\n\ndef some_function():\n    print('I log some string')\n    return 'and return another string'\n    \nclass SomeClass:\n    some_class_property = [1, {}]\n    another_property = 'could be anything'\n    \n    def __init__(self):\n        self.some_object_property = 'not a class one'\n    \nmodule.exports = [some_function, SomeClass(), SomeClass.some_class_property, SomeClass().some_object_property, some_function()]\n```\n\n# Known Limitation\n\nWe choose to make this module a babel plugin instead of a webpack loader because we want to target bundlers as much as possible. Unfortunately making this plugin to be compatible to all bundler forces us to make some sacrifices:\n\n- Because most bundlers ignore loading files outside of project directory to babel loader and sometimes ignore them too in node_modules, there will be some `rapydscript-cache-*` folders that are created on project root during transpilation.\n- Not only the most compatible location is on project root, but metro bundler seems to be a bitch in handling files/folders that have a dot at the start of the name. So the `rapydscript-cache-*` folders can't be hidden with dot (unix).\n- Fortunately these folders will only appear at transpilation. This doesn't have major effects when building for production, but at development (watch mode) the folders will be there until you stop the dev server. Feel free to add `rapydscript-cache-*` to .gitignore to prevent acidentally adding them to your commits.\n\n# Async/Await\n\nBecause we use Kovid Goyal's [fork](https://github.com/kovidgoyal/rapydscript-ng) of RapydScript (for stability and good support, and also baselib compatibility), it still doesn't support `async def` and `await` keyword natively. We implement a nice workaround that makes async/asynchronous as a decorator:\n\n```python\n@async #Or @asynchronous if your IDE complains about the syntax\ndef do_something_async():\n    response = await fetch('/some/route')\n    text = await response.text()\n    return text\n    \ndo_something_async().then(console.log)\n```\n\n`await` is still available as a keyword.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoiu%2Frapydscript-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoiu%2Frapydscript-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoiu%2Frapydscript-plugin/lists"}