{"action":"closed","issue":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5601","repository_url":"https://api.github.com/repos/silverstripe/silverstripe-framework","labels_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5601/labels{/name}","comments_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5601/comments","events_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/issues/5601/events","html_url":"https://github.com/silverstripe/silverstripe-framework/issues/5601","id":157100447,"number":5601,"title":"Automatically expose all ES6 imports in core modules ","user":{"login":"chillu","id":111025,"avatar_url":"https://avatars.githubusercontent.com/u/111025?v=3","gravatar_id":"","url":"https://api.github.com/users/chillu","html_url":"https://github.com/chillu","followers_url":"https://api.github.com/users/chillu/followers","following_url":"https://api.github.com/users/chillu/following{/other_user}","gists_url":"https://api.github.com/users/chillu/gists{/gist_id}","starred_url":"https://api.github.com/users/chillu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chillu/subscriptions","organizations_url":"https://api.github.com/users/chillu/orgs","repos_url":"https://api.github.com/users/chillu/repos","events_url":"https://api.github.com/users/chillu/events{/privacy}","received_events_url":"https://api.github.com/users/chillu/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/labels/affects/v4","name":"affects/v4","color":"5319e7"},{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/labels/effort/hard","name":"effort/hard","color":"f9d0c4"},{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/labels/impact/medium","name":"impact/medium","color":"f7c6c7"},{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/labels/type/enhancement","name":"type/enhancement","color":"0e8a16"},{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/labels/type/frontend","name":"type/frontend","color":"c5def5"}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/silverstripe/silverstripe-framework/milestones/7","html_url":"https://github.com/silverstripe/silverstripe-framework/milestones/4.0.0","labels_url":"https://api.github.com/repos/silverstripe/silverstripe-framework/milestones/7/labels","id":598745,"number":7,"title":"4.0.0","description":"Things we would like to see in 4.0 but are too large/break too much for a 3.x release.","creator":{"login":"simonwelsh","id":125915,"avatar_url":"https://avatars.githubusercontent.com/u/125915?v=3","gravatar_id":"","url":"https://api.github.com/users/simonwelsh","html_url":"https://github.com/simonwelsh","followers_url":"https://api.github.com/users/simonwelsh/followers","following_url":"https://api.github.com/users/simonwelsh/following{/other_user}","gists_url":"https://api.github.com/users/simonwelsh/gists{/gist_id}","starred_url":"https://api.github.com/users/simonwelsh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonwelsh/subscriptions","organizations_url":"https://api.github.com/users/simonwelsh/orgs","repos_url":"https://api.github.com/users/simonwelsh/repos","events_url":"https://api.github.com/users/simonwelsh/events{/privacy}","received_events_url":"https://api.github.com/users/simonwelsh/received_events","type":"User","site_admin":false},"open_issues":43,"closed_issues":43,"state":"open","created_at":"2014-03-15T20:48:10Z","updated_at":"2016-09-26T02:44:04Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2016-05-26T23:26:34Z","updated_at":"2016-09-26T02:44:04Z","closed_at":"2016-09-26T02:44:04Z","body":"The `framework/Gulpfile.js` exposes a lot of ES6 modules (both vendor and custom code). This is used to avoid duplicating code in bundle files in other modules. For example, the JS code for the `react` ES6 module is only included once in `framework`, and then referenced in `asset-admin/Gulpfile.js`.\r\n\r\nThis approach leads to fragile bundles: If a developer forgets to expose an ES6 module in `framework` , it'll be inaccessible to other SilverStripe modules. If other SilverStripe modules pull in NPM dependencies for those ES6 modules as well, this can lead to the same JavaScript code being bundled twice. This works, due to the closure isolation in individual bundle files. But it makes it very hard to debug and set breakpoints.\r\n\r\n`framework/Gulpfile.js`\r\n\r\n```\r\n.require(`${PATHS.MODULES}/bootstrap/dist/js/umd/collapse.js`,\r\n  { expose: 'bootstrap-collapse' }\r\n)\r\n.require(`${PATHS.ADMIN_JS_SRC}/components/Form/Form`,\r\n  { expose: 'components/Form/Form' }\r\n)\r\n.require(`${PATHS.ADMIN_JS_SRC}/components/Form/FormConstants`,\r\n  { expose: 'components/Form/FormConstants' }\r\n)\r\n.require(`${PATHS.ADMIN_JS_SRC}/components/FormAction/FormAction`,\r\n  { expose: 'components/FormAction/FormAction' }\r\n)\r\n.require(`${PATHS.ADMIN_JS_SRC}/components/FormBuilder/FormBuilder`,\r\n  { expose: 'components/FormBuilder/FormBuilder' }\r\n)\r\n.require(`${PATHS.ADMIN_JS_SRC}/components/GridField/GridField`,\r\n  { expose: 'components/GridField/GridField' }\r\n)\r\n...\r\n```\r\n\r\n`asset-admin/Gulpfile.js`\r\n\r\n```\r\n.external('components/TextField/TextField')\r\n.external('components/FormAction/FormAction')\r\n.external('deep-freeze')\r\n.external('lib/Config')\r\n.external('react')\r\n.external('jQuery')\r\n.external('i18n')\r\n.external('lib/SilverStripeComponent')\r\n.external('lib/Backend')\r\n.external('react-dom')\r\n.external('react-addons-test-utils')\r\n...\r\n```\r\n\r\nOptions:\r\n\r\n * Create a browserify plugin which automatically exposes all modules it loads through `require`/`import`\r\n * Publish SilverStripe's custom ES6 code in `framework` as an NPM repo, add it to other SilverStripe modules as a dependency - and live with the bundle code duplication and potential version mismatches. This would still require `expose` on `react` and other \"heavy\" dependencies, we can't duplicate those in each bundle. Would also fix the current NPM include path issues (IDEs don't pick up `import components/Form/Form` in `asset-admin` since it's not defined in `node_modules`)."}}
{"actor":{"display_login":"sminnee"}}