{"action":"created","issue":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11477","repository_url":"https://api.github.com/repos/Microsoft/TypeScript","labels_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11477/labels{/name}","comments_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11477/comments","events_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11477/events","html_url":"https://github.com/Microsoft/TypeScript/issues/11477","id":181940538,"number":11477,"title":"Suggestion: `--module ignore` option","user":{"login":"SaschaNaz","id":3396686,"avatar_url":"https://avatars.githubusercontent.com/u/3396686?v=3","gravatar_id":"","url":"https://api.github.com/users/SaschaNaz","html_url":"https://github.com/SaschaNaz","followers_url":"https://api.github.com/users/SaschaNaz/followers","following_url":"https://api.github.com/users/SaschaNaz/following{/other_user}","gists_url":"https://api.github.com/users/SaschaNaz/gists{/gist_id}","starred_url":"https://api.github.com/users/SaschaNaz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SaschaNaz/subscriptions","organizations_url":"https://api.github.com/users/SaschaNaz/orgs","repos_url":"https://api.github.com/users/SaschaNaz/repos","events_url":"https://api.github.com/users/SaschaNaz/events{/privacy}","received_events_url":"https://api.github.com/users/SaschaNaz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-10T05:43:12Z","updated_at":"2016-10-10T06:48:51Z","closed_at":null,"body":"### Background\r\n\r\nI'm planning a standalone library that does support module-supporting systems and no-module-support systems together. I'm letting my Jakefile.js to compile my files multiple times to support different module systems including native ES6, commonjs and systemjs.\r\n\r\nNow I want to support browser contexts which do not have ES6 module syntax support or any module system libraries such as requires, because I don't want to force users to deal with unwanted dependencies.\r\n\r\n### Suggested behavior\r\n\r\n`--module ignore` option should silently ignore `export` statements and must explicitly error with `import` statements. \r\n\r\nInput:\r\n\r\n```ts\r\n// with --module ignore\r\nnamespace MyNamespace {\r\n    // Do not pollute global scope and wrap everything into this namespace\r\n    // The only exception is this namespace declaration itself...\r\n}\r\n\r\nexport default MyNamespace;\r\n```\r\n\r\nOutput:\r\n\r\n```js\r\nvar MyNamespace;\r\n(function (MyNamespace) {\r\n})(MyNamespace || (MyNamespace = {}));\r\n\r\n// export statement is ignored\r\n```\r\n\r\nInput:\r\n\r\n```ts\r\n// with --module ignore\r\nimport { myFunction } from \"mymodule\";\r\n\r\nmyFunction();\r\n```\r\n\r\nOutput:\r\n\r\n`Error: Cannot import modules because module parameter is specified as 'ignore'`"},"comment":{"url":"https://api.github.com/repos/Microsoft/TypeScript/issues/comments/252546164","html_url":"https://github.com/Microsoft/TypeScript/issues/11477#issuecomment-252546164","issue_url":"https://api.github.com/repos/Microsoft/TypeScript/issues/11477","id":252546164,"user":{"login":"kitsonk","id":1282577,"avatar_url":"https://avatars.githubusercontent.com/u/1282577?v=3","gravatar_id":"","url":"https://api.github.com/users/kitsonk","html_url":"https://github.com/kitsonk","followers_url":"https://api.github.com/users/kitsonk/followers","following_url":"https://api.github.com/users/kitsonk/following{/other_user}","gists_url":"https://api.github.com/users/kitsonk/gists{/gist_id}","starred_url":"https://api.github.com/users/kitsonk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kitsonk/subscriptions","organizations_url":"https://api.github.com/users/kitsonk/orgs","repos_url":"https://api.github.com/users/kitsonk/repos","events_url":"https://api.github.com/users/kitsonk/events{/privacy}","received_events_url":"https://api.github.com/users/kitsonk/received_events","type":"User","site_admin":false},"created_at":"2016-10-10T06:48:51Z","updated_at":"2016-10-10T06:48:51Z","body":"This would raise so many issues...  While it might \"work\" for you, there would likely be so many name collisions, etc. and impose so many contraints.  For example what would you do with this:\r\n\r\n```typescript\r\nimport { myFunction as otherFunction } from 'mymodule';\r\n\r\notherFunction();\r\n```\r\n\r\nor anything with a default import/export:\r\n\r\n```typescript\r\nimport bar from 'bar';\r\n```\r\n\r\nThose not wishing to impose downstream requirements on modular code use bundlers that do not require any further steps than including a script tag on a page.  For example, [WebPack](https://webpack.github.io/), though there are many others.\r\n"}}
{"actor":{"display_login":"kitsonk"}}