{"action":"created","issue":{"url":"https://api.github.com/repos/less/less.js/issues/3178","repository_url":"https://api.github.com/repos/less/less.js","labels_url":"https://api.github.com/repos/less/less.js/issues/3178/labels{/name}","comments_url":"https://api.github.com/repos/less/less.js/issues/3178/comments","events_url":"https://api.github.com/repos/less/less.js/issues/3178/events","html_url":"https://github.com/less/less.js/issues/3178","id":299357470,"number":3178,"title":"bundling less 3.0.1 with web-pack, targeting web-worker.","user":{"login":"dasdeck","id":1512038,"avatar_url":"https://avatars2.githubusercontent.com/u/1512038?v=4","gravatar_id":"","url":"https://api.github.com/users/dasdeck","html_url":"https://github.com/dasdeck","followers_url":"https://api.github.com/users/dasdeck/followers","following_url":"https://api.github.com/users/dasdeck/following{/other_user}","gists_url":"https://api.github.com/users/dasdeck/gists{/gist_id}","starred_url":"https://api.github.com/users/dasdeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dasdeck/subscriptions","organizations_url":"https://api.github.com/users/dasdeck/orgs","repos_url":"https://api.github.com/users/dasdeck/repos","events_url":"https://api.github.com/users/dasdeck/events{/privacy}","received_events_url":"https://api.github.com/users/dasdeck/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-22T13:39:33Z","updated_at":"2018-04-09T09:13:11Z","closed_at":null,"author_association":"NONE","body":"Hi!\r\n\r\nI can not get less 3.0.1 to bundle properly into my web worker code.\r\nLess 2 was working flawlessly with the same setup.\r\n\r\nWhen I import less like this:\r\n```\r\nimport less from 'less';\r\n```\r\nI get `less.js:78 Uncaught ReferenceError: window is not defined` in the browser console, which kind of makes sense, as the bundle uses the `dist` version for the browser but a worker has no `window`.\r\n\r\nsince the imports are static, I see no way of shimming the window away.\r\n\r\nin the old version we did it like this:\r\n\r\n```\r\nimport browser from 'less/browser'\r\nconst less = browser({},{});\r\n```\r\nwhich would set a window object.\r\n\r\nThis bundle, however, throws an error:\r\n```\r\nCannot find module \".\"\r\n```\r\n\r\nwhich seems to be related to this particular line of code:\r\n./browser/plugin-loader.js:9\r\n```\r\nvar PluginLoader = function(less) {\r\n    this.less = less;\r\n    // shim for browser require?\r\n    this.require = require;    <----------\r\n};\r\n```\r\n\r\nhere is my web-pack conf.\r\n```\r\n/* eslint-env node */\r\n\r\nconst conf = {\r\n\r\n    entry: {\r\n        'sidebar/test/app': './sidebar/test/app',\r\n        'fields/test/app': './fields/test/app',\r\n        'layout-editor/test/app': './layout-editor/test/app',\r\n        'styler/test/app': './styler/test/app',\r\n    },\r\n\r\n    output: {\r\n        filename: './[name].min.js'\r\n    },\r\n\r\n    externals: {\r\n        vue: 'Vue',\r\n        uikit: 'UIkit'\r\n    },\r\n\r\n    node: {\r\n        fs: 'empty'\r\n    },\r\n\r\n    target: 'web',\r\n\r\n    module: {\r\n\r\n        rules: [\r\n            {\r\n                test: /\\.vue$/,\r\n                use: {\r\n                    loader: 'vue-loader',\r\n                    options: {\r\n                        loaders: {\r\n                            js: 'babel-loader?presets[]=env&plugins[]=lodash&plugins[]=transform-object-rest-spread'\r\n                        }\r\n                    }\r\n                }\r\n            },\r\n            {\r\n                test: /\\.js$/,\r\n                exclude: /node_modules/,\r\n                use: {\r\n                    loader: 'babel-loader',\r\n                    options: {\r\n                        presets: ['env'],\r\n                        plugins: ['lodash', 'transform-object-rest-spread']\r\n                    }\r\n                }\r\n            }\r\n        ]\r\n    }\r\n\r\n}\r\n\r\nmodule.exports = (env, argv) => ([conf, \r\n    {...conf, \r\n        entry: {'styler/lib/worker': './styler/lib/worker'}, \r\n        target: 'webworker',\r\n    }]);\r\n\r\n```\r\n\r\nCheers!\r\n\r\nJM"},"comment":{"url":"https://api.github.com/repos/less/less.js/issues/comments/379687088","html_url":"https://github.com/less/less.js/issues/3178#issuecomment-379687088","issue_url":"https://api.github.com/repos/less/less.js/issues/3178","id":379687088,"user":{"login":"dasdeck","id":1512038,"avatar_url":"https://avatars2.githubusercontent.com/u/1512038?v=4","gravatar_id":"","url":"https://api.github.com/users/dasdeck","html_url":"https://github.com/dasdeck","followers_url":"https://api.github.com/users/dasdeck/followers","following_url":"https://api.github.com/users/dasdeck/following{/other_user}","gists_url":"https://api.github.com/users/dasdeck/gists{/gist_id}","starred_url":"https://api.github.com/users/dasdeck/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dasdeck/subscriptions","organizations_url":"https://api.github.com/users/dasdeck/orgs","repos_url":"https://api.github.com/users/dasdeck/repos","events_url":"https://api.github.com/users/dasdeck/events{/privacy}","received_events_url":"https://api.github.com/users/dasdeck/received_events","type":"User","site_admin":false},"created_at":"2018-04-09T09:13:11Z","updated_at":"2018-04-09T09:13:11Z","author_association":"NONE","body":"Thanks for your help!\r\nThis did not help me yet, but it gets me some ideas for more things to try, so thanks for the input!\r\nWe need to use our plugin though, which might make it more difficult.\r\n\r\nCheers!"}}
{"actor":{"display_login":"dasdeck"}}