{"action":"created","issue":{"url":"https://api.github.com/repos/QQuick/Transcrypt/issues/596","repository_url":"https://api.github.com/repos/QQuick/Transcrypt","labels_url":"https://api.github.com/repos/QQuick/Transcrypt/issues/596/labels{/name}","comments_url":"https://api.github.com/repos/QQuick/Transcrypt/issues/596/comments","events_url":"https://api.github.com/repos/QQuick/Transcrypt/issues/596/events","html_url":"https://github.com/QQuick/Transcrypt/issues/596","id":384037829,"node_id":"MDU6SXNzdWUzODQwMzc4Mjk=","number":596,"title":"Bundling with Parcel/npm","user":{"login":"doconix","id":5728529,"node_id":"MDQ6VXNlcjU3Mjg1Mjk=","avatar_url":"https://avatars2.githubusercontent.com/u/5728529?v=4","gravatar_id":"","url":"https://api.github.com/users/doconix","html_url":"https://github.com/doconix","followers_url":"https://api.github.com/users/doconix/followers","following_url":"https://api.github.com/users/doconix/following{/other_user}","gists_url":"https://api.github.com/users/doconix/gists{/gist_id}","starred_url":"https://api.github.com/users/doconix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doconix/subscriptions","organizations_url":"https://api.github.com/users/doconix/orgs","repos_url":"https://api.github.com/users/doconix/repos","events_url":"https://api.github.com/users/doconix/events{/privacy}","received_events_url":"https://api.github.com/users/doconix/received_events","type":"User","site_admin":false},"labels":[{"id":299032446,"node_id":"MDU6TGFiZWwyOTkwMzI0NDY=","url":"https://api.github.com/repos/QQuick/Transcrypt/labels/IS:%20enhancement","name":"IS: enhancement","color":"0000ff","default":false},{"id":434074253,"node_id":"MDU6TGFiZWw0MzQwNzQyNTM=","url":"https://api.github.com/repos/QQuick/Transcrypt/labels/NEED:%20feedback","name":"NEED: feedback","color":"ffff00","default":false},{"id":473827437,"node_id":"MDU6TGFiZWw0NzM4Mjc0Mzc=","url":"https://api.github.com/repos/QQuick/Transcrypt/labels/PRIO:%201%20must","name":"PRIO: 1 must","color":"77ff77","default":false},{"id":489261811,"node_id":"MDU6TGFiZWw0ODkyNjE4MTE=","url":"https://api.github.com/repos/QQuick/Transcrypt/labels/SUB:%20core","name":"SUB: core","color":"ffeebb","default":false}],"state":"open","locked":false,"assignee":{"login":"JdeH","id":1730289,"node_id":"MDQ6VXNlcjE3MzAyODk=","avatar_url":"https://avatars2.githubusercontent.com/u/1730289?v=4","gravatar_id":"","url":"https://api.github.com/users/JdeH","html_url":"https://github.com/JdeH","followers_url":"https://api.github.com/users/JdeH/followers","following_url":"https://api.github.com/users/JdeH/following{/other_user}","gists_url":"https://api.github.com/users/JdeH/gists{/gist_id}","starred_url":"https://api.github.com/users/JdeH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JdeH/subscriptions","organizations_url":"https://api.github.com/users/JdeH/orgs","repos_url":"https://api.github.com/users/JdeH/repos","events_url":"https://api.github.com/users/JdeH/events{/privacy}","received_events_url":"https://api.github.com/users/JdeH/received_events","type":"User","site_admin":false},"assignees":[{"login":"JdeH","id":1730289,"node_id":"MDQ6VXNlcjE3MzAyODk=","avatar_url":"https://avatars2.githubusercontent.com/u/1730289?v=4","gravatar_id":"","url":"https://api.github.com/users/JdeH","html_url":"https://github.com/JdeH","followers_url":"https://api.github.com/users/JdeH/followers","following_url":"https://api.github.com/users/JdeH/following{/other_user}","gists_url":"https://api.github.com/users/JdeH/gists{/gist_id}","starred_url":"https://api.github.com/users/JdeH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JdeH/subscriptions","organizations_url":"https://api.github.com/users/JdeH/orgs","repos_url":"https://api.github.com/users/JdeH/repos","events_url":"https://api.github.com/users/JdeH/events{/privacy}","received_events_url":"https://api.github.com/users/JdeH/received_events","type":"User","site_admin":false},{"login":"doconix","id":5728529,"node_id":"MDQ6VXNlcjU3Mjg1Mjk=","avatar_url":"https://avatars2.githubusercontent.com/u/5728529?v=4","gravatar_id":"","url":"https://api.github.com/users/doconix","html_url":"https://github.com/doconix","followers_url":"https://api.github.com/users/doconix/followers","following_url":"https://api.github.com/users/doconix/following{/other_user}","gists_url":"https://api.github.com/users/doconix/gists{/gist_id}","starred_url":"https://api.github.com/users/doconix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/doconix/subscriptions","organizations_url":"https://api.github.com/users/doconix/orgs","repos_url":"https://api.github.com/users/doconix/repos","events_url":"https://api.github.com/users/doconix/events{/privacy}","received_events_url":"https://api.github.com/users/doconix/received_events","type":"User","site_admin":false}],"milestone":null,"comments":12,"created_at":"2018-11-25T01:30:41Z","updated_at":"2018-12-02T14:37:24Z","closed_at":null,"author_association":"MEMBER","body":"I just committed a branch that makes transcrypt work with [Parcel Bundler](https://parceljs.org/). Parcel is a zero-config bundler that is gaining traction. The branch is at:\r\n\r\nhttps://github.com/QQuick/Transcrypt/tree/parcel-bundler\r\n\r\nThe example run is at `transcrypt/parcel-plugin-python/`. See the [README.md](https://github.com/QQuick/Transcrypt/blob/parcel-bundler/parcel-plugin-python/README.md) file for installation instructions.\r\n\r\nWhen the test server is run, the parcel bundler starts with `index.html` and `index.js`, which contains:\r\n\r\n```\r\nimport {main} from \"./some.py\";\r\nmain();\r\n```\r\n\r\nThe `.py` extension tells parcel to run the file through transcrypt.\r\n\r\n<soapbox>\r\n\r\nI've said this before, but IMO transcrypt must work seamlessly with bundlers for it to see wide use. Modern JS projects include many coding languages (JS, CoffeeScript, TypeScript, Rust). The role of the bundler is to transpile them all to regular JS and then bundle them together.\r\n\r\nTranscrypt is fundamentally different from bundler-based transpilers because it acts both as a transpiler AND a bundler.  It doesn't just transpile single files, but it also includes everything those file import. For example, if `some.py` contains \"import mylib\", transcrypt compiles BOTH `some.py` and `mylib.py`. A single run of transcrypt usually results in a number of .js files, which are placed together in `__target__`.\r\n\r\nRegular transpilers generally stick to single files. When asked to compile `some.py`, they compile ONLY that file and don't follow any import statements. The import statements continue to keep the extensions of the files they import (transcrypt switches everything to .js). It's the job of the *bundler* to follow the imports and call the right transpiler.\r\n\r\nSo while this branch makes transcrypt work with Parcel, it is a bit of hack because transcrypt isn't meant to work this way. It also breaks the normal transcrypt process because it keeps import file extensions (in revisit* methods). See the diff in `compile.py` for where this happens.\r\n\r\nThe recent change to ES6 and units is a HUGE step toward doing things the bundler way, but a few things remain:\r\n\r\n1. Transcrypt needs to keep import extensions (e.g. not change them). Like this:\r\n\r\nPython Source:\r\n```\r\nfrom calculator import addit\r\n```\r\n\r\nJS Output:\r\n```\r\nimport {addit} from './calculator.py';\r\n```\r\n\r\nThis way the bundler knows to run transcrypt again for `calculator.py`.\r\n\r\n2. Since transcrypt will only transpile a single .js file (the __main__ one), there's no need to copy other files to the `__target__` directory. This means the `__runtime__`, imported local files, and built-in modules (`re`, `time`, etc.) DON'T need to exist as siblings. Instead, these should be put into the npm repository just like any other imports. In fact, since only a single file export is needed, we can do away with `__target__` entirely.\r\n\r\nAn example import from the built-ins:\r\n\r\nSource:\r\n```\r\nimport re\r\n```\r\n\r\nJS Output:\r\n```\r\nimport * as __module_re__ from 'transcrypt/re/__init__.py';\r\n```\r\n\r\nNote that the JS import is not relative (./), so the bundler will look in `node_modules/transcrypt/re/__init__.py` rather than in the local directory. It will expect the `re` module to be in the npm repository. Importing the `__runtime__` should be the same way.\r\n\r\nI know JdeH wants to keep the current transpiler+bundler abilities of transcrypt, and I think that's fine. But I'd really like to see transcrypt become a first-order transpiler that works with bundlers out of the box. Right now it's not quite set up right to be one, but I don't think it needs a lot of changes to get there.\r\n\r\n</soapbox>"},"comment":{"url":"https://api.github.com/repos/QQuick/Transcrypt/issues/comments/443512371","html_url":"https://github.com/QQuick/Transcrypt/issues/596#issuecomment-443512371","issue_url":"https://api.github.com/repos/QQuick/Transcrypt/issues/596","id":443512371,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MzUxMjM3MQ==","user":{"login":"JdeH","id":1730289,"node_id":"MDQ6VXNlcjE3MzAyODk=","avatar_url":"https://avatars2.githubusercontent.com/u/1730289?v=4","gravatar_id":"","url":"https://api.github.com/users/JdeH","html_url":"https://github.com/JdeH","followers_url":"https://api.github.com/users/JdeH/followers","following_url":"https://api.github.com/users/JdeH/following{/other_user}","gists_url":"https://api.github.com/users/JdeH/gists{/gist_id}","starred_url":"https://api.github.com/users/JdeH/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JdeH/subscriptions","organizations_url":"https://api.github.com/users/JdeH/orgs","repos_url":"https://api.github.com/users/JdeH/repos","events_url":"https://api.github.com/users/JdeH/events{/privacy}","received_events_url":"https://api.github.com/users/JdeH/received_events","type":"User","site_admin":false},"created_at":"2018-12-02T14:37:24Z","updated_at":"2018-12-02T14:37:24Z","author_association":"MEMBER","body":"@doconix \r\n\r\nI'd like to evaluate the changes you made, but have trouble getting an overview since lots of whitespace changes are also marked as differences. I've tried the ?w=0 option in the diff view but it doesn't solve the problem. Would it be possible for you to have only relevant (non-whitespace) etc. changes on GitHub, enabling comparison to the master branch. I've tried an external file compare tool but if failed on the  job, ignoring relevant differences. Sorry I have to ask this, but since the work on Transcrypt really takes up lots of my time now I feel forced to streamline. Know that I greatly appreciate all the effort you put in!\r\n\r\n@PythonLinks @doconix\r\n\r\nIt's agreed that Transcrypt has to stay as simple as possible. I must say I find it impossibly hard to get any kind of grip upon the explosion of half-compatible, half-contemplated approaches in the JavaScript world. The prime reason Python is becoming so popular is its simplicity, although part of that recently is getting lost in overstressing facilities like iterators, decorators, metaclasses, static typing etc.. I hope Python is spared from getting as complex as e.g.  C++, although I really like that language and have used it most of my working life. Especially with Guido no longer at the wheel I am worried that the \"the more the merrier\" approach takes over. To be honest it isn't the low threshold common sense scripting language anymore that I once bumped into.\r\n\r\nFrom the docs of Transcrypt:\r\n\r\nhttp://www.transcrypt.org/docs/html/what_why.html#what-is-transcrypt\r\n\r\n> One of the main goals of Transcrypt is to keep things simple, preventing it from disolution into an ocean of feature creep and conflicting demands. At its core it will stay lean and mean.\r\n\r\nWanting, or rather needing, this simplicity for me was the reason to abandon JS development of browsr apps and start the  Transcrypt project.\r\n\r\nTranscrypt is primarily meant for Pythonista's who want to make browser applications in Python while using JS libs. Still the possibility of tight integration with the JS world is valuable. In this JS world an ever changing diversity of bundlers seems to be a fact of life. I don't expect these to converge as many JS developers don't seem to be particularly interested in that kind of thing. While popularity may shift, I don't expect it to ever really stabilize unless the ECMA committee proclaims a standard.\r\n\r\nTo support use of Transcrypt in combination with those, I propose the following criteria:\r\n\r\n- The current simple way of working, including use of the flat __target__ directoryholding everything including sourcemaps, should be preserved as default.\r\n- Changes aimed at making Transcrypt fit in the bundler world should not complicate TS's sourcecode too much, as it will all have to be maintained.\r\n- Changes in Transcrypt itself should not be tied to one particular bundler. They should comply with emerging ECMA standards (still very virtual in this area), as does the module mechanism.\r\n\r\nAt the same time it would be very nice if Pythonista's could write e.g. datascience/AI related stuff in Python that would be available as JS compatible libraries that can be drawn into JavaScript apps the way JS programmers are used to, so using popular bundlers. This would enable Pythonista's to enter the enormous JS and Web Client world.\r\n\r\nI want to be very clear: my heart is with Python, not with JavaScript. But since it's a massive stream, Pythonista's should be able to tap into it, even if I hope their main focus will be making algorithmically interesting server applications, rather than fancy front-ends whose main purpose is to look good.\r\n\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"JdeH"}}