{"action":"created","issue":{"url":"https://api.github.com/repos/webpack/webpack/issues/2883","repository_url":"https://api.github.com/repos/webpack/webpack","labels_url":"https://api.github.com/repos/webpack/webpack/issues/2883/labels{/name}","comments_url":"https://api.github.com/repos/webpack/webpack/issues/2883/comments","events_url":"https://api.github.com/repos/webpack/webpack/issues/2883/events","html_url":"https://github.com/webpack/webpack/issues/2883","id":171761791,"number":2883,"title":"System.import(module) should not show a warning","user":{"login":"hansl","id":681969,"avatar_url":"https://avatars1.githubusercontent.com/u/681969?v=4","gravatar_id":"","url":"https://api.github.com/users/hansl","html_url":"https://github.com/hansl","followers_url":"https://api.github.com/users/hansl/followers","following_url":"https://api.github.com/users/hansl/following{/other_user}","gists_url":"https://api.github.com/users/hansl/gists{/gist_id}","starred_url":"https://api.github.com/users/hansl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hansl/subscriptions","organizations_url":"https://api.github.com/users/hansl/orgs","repos_url":"https://api.github.com/users/hansl/repos","events_url":"https://api.github.com/users/hansl/events{/privacy}","received_events_url":"https://api.github.com/users/hansl/received_events","type":"User","site_admin":false},"labels":[{"id":1089820,"url":"https://api.github.com/repos/webpack/webpack/labels/bug","name":"bug","color":"fbca04","default":true},{"id":665191202,"url":"https://api.github.com/repos/webpack/webpack/labels/inactive","name":"inactive","color":"000000","default":false},{"id":428473237,"url":"https://api.github.com/repos/webpack/webpack/labels/P2:%20Very%20Important","name":"P2: Very Important","color":"ef7675","default":false},{"id":428472624,"url":"https://api.github.com/repos/webpack/webpack/labels/S2:%20Inconvenient","name":"S2: Inconvenient","color":"0052cc","default":false},{"id":90419071,"url":"https://api.github.com/repos/webpack/webpack/labels/webpack-2","name":"webpack-2","color":"c5def5","default":false},{"id":398105880,"url":"https://api.github.com/repos/webpack/webpack/labels/X4:%20work%20required","name":"X4: work required","color":"c2e0c6","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-17T21:13:14Z","updated_at":"2017-08-26T11:41:57Z","closed_at":"2017-08-26T11:41:56Z","body":"## This is a bug report.\n#### Webpack Version\n\n2.1.0-beta.18\n#### Environment\n\nAny.\n#### Current behavior\n\nThe following code actually generates a warning (obfuscation to prevent webpack from being too clever):\n\n``` typescript\nconst module = ['a', '/', 'string'].join('');\nSystem.import(module).then(function() { console.log('loaded'); });\n```\n\nThe warning is the following:\n\n```\nWARNING in ./src/main.ts\n2:0 Critical dependency: the request of a dependency is an expression\n```\n\nThe problem is this code: ([link](https://github.com/webpack/webpack/blob/b0fffd50d35dd0eef734d189928c1ac4c5c9fb97/lib/dependencies/ContextDependencyHelpers.js#L27))\n\n``` javascript\n    if(param.isWrapped() && (param.prefix && param.prefix.isString() || param.postfix && param.postfix.isString())) {\n        var prefix = param.prefix && param.prefix.isString() ? param.prefix.string : \"\";\n        var postfix = param.postfix && param.postfix.isString() ? param.postfix.string : \"\";\n        var prefixRange = param.prefix && param.prefix.isString() ? param.prefix.range : null;\n        var valueRange = [prefixRange ? prefixRange[1] : param.range[0], param.range[1]];\n        var idx = prefix.lastIndexOf(\"/\");\n        var context = \".\";\n        if(idx >= 0) {\n            context = prefix.substr(0, idx);\n            prefix = \".\" + prefix.substr(idx);\n        }\n        var regExp = new RegExp(\"^\" +\n            prefix.replace(/[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\") +\n            options.wrappedContextRegExp.source +\n            postfix.replace(/[\\-\\[\\]\\/\\{\\}\\(\\)\\*\\+\\?\\.\\\\\\^\\$\\|]/g, \"\\\\$&\") + \"$\");\n        dep = new Dep(context, options.wrappedContextRecursive, regExp, range, valueRange);\n        dep.loc = expr.loc;\n        dep.prepend = param.prefix && param.prefix.isString() ? prefix : null;\n        dep.critical = options.wrappedContextCritical && \"a part of the request of a dependency is an expression\";\n        return dep;\n    } else {\n        dep = new Dep(options.exprContextRequest, options.exprContextRecursive, options.exprContextRegExp, range, param.range);\n        dep.loc = expr.loc;\n        dep.critical = options.exprContextCritical && \"the request of a dependency is an expression\";\n        return dep;\n    }\n```\n\nChanging the import line to `System.import(\"\" + module)` or `System.import(module + \"\")` fixes the problem.\n\nThe problem is that it checks if it has a prefix or suffix, but not if the expression has neither (and yet still valid). Having a single variable as an expression should be allowed without a warning.\n#### Expected/desired behavior\n\nNo warning for the code above should be shown.\n"},"comment":{"url":"https://api.github.com/repos/webpack/webpack/issues/comments/325118556","html_url":"https://github.com/webpack/webpack/issues/2883#issuecomment-325118556","issue_url":"https://api.github.com/repos/webpack/webpack/issues/2883","id":325118556,"user":{"login":"webpack-bot","id":26676291,"avatar_url":"https://avatars0.githubusercontent.com/u/26676291?v=4","gravatar_id":"","url":"https://api.github.com/users/webpack-bot","html_url":"https://github.com/webpack-bot","followers_url":"https://api.github.com/users/webpack-bot/followers","following_url":"https://api.github.com/users/webpack-bot/following{/other_user}","gists_url":"https://api.github.com/users/webpack-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/webpack-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webpack-bot/subscriptions","organizations_url":"https://api.github.com/users/webpack-bot/orgs","repos_url":"https://api.github.com/users/webpack-bot/repos","events_url":"https://api.github.com/users/webpack-bot/events{/privacy}","received_events_url":"https://api.github.com/users/webpack-bot/received_events","type":"User","site_admin":false},"created_at":"2017-08-26T11:41:57Z","updated_at":"2017-08-26T11:41:57Z","body":"Issue was closed because of inactivity.\n\nIf you think this is still a valid issue, please file a new issue with additional information."}}
{"actor":{"display_login":"webpack-bot"}}