{"action":"opened","issue":{"url":"https://api.github.com/repos/sourcelair/xterm.js/issues/1018","repository_url":"https://api.github.com/repos/sourcelair/xterm.js","labels_url":"https://api.github.com/repos/sourcelair/xterm.js/issues/1018/labels{/name}","comments_url":"https://api.github.com/repos/sourcelair/xterm.js/issues/1018/comments","events_url":"https://api.github.com/repos/sourcelair/xterm.js/issues/1018/events","html_url":"https://github.com/sourcelair/xterm.js/issues/1018","id":262114495,"number":1018,"title":"Master issue for webpack/loadAddon issues","user":{"login":"Tyriar","id":2193314,"avatar_url":"https://avatars0.githubusercontent.com/u/2193314?v=4","gravatar_id":"","url":"https://api.github.com/users/Tyriar","html_url":"https://github.com/Tyriar","followers_url":"https://api.github.com/users/Tyriar/followers","following_url":"https://api.github.com/users/Tyriar/following{/other_user}","gists_url":"https://api.github.com/users/Tyriar/gists{/gist_id}","starred_url":"https://api.github.com/users/Tyriar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tyriar/subscriptions","organizations_url":"https://api.github.com/users/Tyriar/orgs","repos_url":"https://api.github.com/users/Tyriar/repos","events_url":"https://api.github.com/users/Tyriar/events{/privacy}","received_events_url":"https://api.github.com/users/Tyriar/received_events","type":"User","site_admin":false},"labels":[{"id":664163509,"url":"https://api.github.com/repos/sourcelair/xterm.js/labels/breaking-change","name":"breaking-change","color":"b60205","default":false},{"id":559726399,"url":"https://api.github.com/repos/sourcelair/xterm.js/labels/help%20wanted","name":"help wanted","color":"0e8a16","default":true},{"id":323589242,"url":"https://api.github.com/repos/sourcelair/xterm.js/labels/proposal","name":"proposal","color":"fe9753","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/sourcelair/xterm.js/milestones/8","html_url":"https://github.com/sourcelair/xterm.js/milestone/8","labels_url":"https://api.github.com/repos/sourcelair/xterm.js/milestones/8/labels","id":2195297,"number":8,"title":"3.0.0","description":"","creator":{"login":"parisk","id":1188592,"avatar_url":"https://avatars3.githubusercontent.com/u/1188592?v=4","gravatar_id":"","url":"https://api.github.com/users/parisk","html_url":"https://github.com/parisk","followers_url":"https://api.github.com/users/parisk/followers","following_url":"https://api.github.com/users/parisk/following{/other_user}","gists_url":"https://api.github.com/users/parisk/gists{/gist_id}","starred_url":"https://api.github.com/users/parisk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parisk/subscriptions","organizations_url":"https://api.github.com/users/parisk/orgs","repos_url":"https://api.github.com/users/parisk/repos","events_url":"https://api.github.com/users/parisk/events{/privacy}","received_events_url":"https://api.github.com/users/parisk/received_events","type":"User","site_admin":false},"open_issues":24,"closed_issues":102,"state":"open","created_at":"2016-12-13T23:08:56Z","updated_at":"2017-10-02T14:58:27Z","due_on":"2017-11-06T08:00:00Z","closed_at":null},"comments":0,"created_at":"2017-10-02T14:58:27Z","updated_at":"2017-10-02T14:58:27Z","closed_at":null,"author_association":"COLLABORATOR","body":"I've seen a bunch of issues recently come in around how loadAddon works and I wonder if we're over complicating things. In today's world of bundlers and source maps, it appears very difficult to get this right in a way that will work across all build systems.\r\n\r\n## Goals\r\n\r\n- We need an easy way to load addons without forcing the user to download and parse/run the script. The core should be as slim as possible, leaving out optional components.\r\n- It should work with webpack, browserify and vscode's module system (and more?)\r\n- It should work nicely with TypeScript\r\n\r\n### Current Situation\r\n\r\n- We wrap addons in UMD which allows handling of the addon script in a plan browser environment, CommonJS environment and require.js environment. A problem here is that we needed to reorder the UMD definition as VS Code defines the `define` global, messing with the typical format and introducing issues for people eg. https://github.com/sourcelair/xterm.js/pull/994\r\n- In a CommonJS environment the addon script attempts to load in the `Terminal` object via `require`, this causes issues for webpack https://github.com/sourcelair/xterm.js/issues/927\r\n- `Terminal` inside addons is not typed currently as the definition for `Terminal` lies outside of the addon folder\r\n\r\n## Potential Solutions\r\n\r\nI'm not attempting to solve the problem right now, here are some ideas though:\r\n\r\n- Have `loadAddon` pull in the script addon object and apply it to `Terminal`, as opposed to leaving it up to the addon to load `Terminal` (see https://github.com/sourcelair/xterm.js/issues/927#issuecomment-325210992)\r\n\r\n  ```js\r\n  public static loadAddon(addon: string, callback?: Function): boolean | any {\r\n      // TODO: Improve return type and documentation\r\n      if (typeof exports === 'object' && typeof module === 'object') {\r\n        // CommonJS\r\n        return require('./addons/' + addon + '/' + addon)(Terminal);\r\n      } else if (typeof define === 'function') {\r\n  ...\r\n  ```\r\n- Require bundling or concatenation when using addons?\r\n\r\nIf anyone has more insights into how this sort of dynamic loading at runtime issue is typically handled, I'd love to hear it :smiley: \r\n\r\nCCing people from related issues: @parisk @mofux @ficristo @dgriffen @ebertmi @rdicroce @jclangst @LucaT1 @jan0e @KagamiChan "}}
{"actor":{"display_login":"Tyriar"}}