DanielSchaffer/webpack-babel-multi-target-plugin

Encountered unexpected blind targeting request on Windows 10

vesanieminen opened this issue ยท 12 comments

The following error happens on Windows 10 when using a prepackaged Juicy Ace Editor npm dependency that has been transpiled and minified to ES5 already:

ERROR in ./node_modules/ace-builds/src-noconflict/ace.js?babel-target=es5
Module not found: Error: Encountered unexpected blind targeting request for C:\Users\user\Downloads\webpack-wc-demo-ace\webpack-wc-demo-ace\node_modules\babel-loader\lib\index.js??ref--4-0!C:\Users\user\Downloads\webpack-wc-demo-ace\webpack-wc-demo-ace\node_modules\webpack\buildin\harmony-module.js.Please see http://github.com/DanielSchaffer/webpack-babel-multi-target-plugin#blind-targeting for more information.
 @ ./node_modules/ace-builds/src-noconflict/ace.js?babel-target=es5 1:0-52
 @ ./src/juicy-ace-editor-npm.min.js?babel-target=es5
 @ ./src/hello-world.js?babel-target=es5
 @ ./src?babel-target=es5

This error does not happen on MacOS.

Minimally reproducible project.

Note, we tried exclude to workaround that (avoid passing ace-builds to Babel) but looks like exclude is broken, see #38

It's a bit odd that this is a Windows-only issue ... I just checked and I don't see anything obvious like I'm hardcoding path separators anywhere it'd cause an issue like this. I'll get #38 released for you and see if that can at least help you work around it. Unfortunately, I don't have a straightforward way to reproduce/debug with Win10 as I'm running MacOS and don't have a license to run it in a VM or anything.

Actually, I take that back - I've got regexps in excluded.packages.ts with forward slashes for path separators. These are paths with packages that should never be transpiled, and always excluded - so I think this is an issue for Windows in general, not just for the ACE package you're working with. Those regexps should probably be replaced with strings that use path.join(...) instead.

@vesanieminen @web-padawan Can you try using v2.3.1-next.2 and let me know if that fixes the issue on Win10 (without using exclusions)?

Unfortunately, I don't have a straightforward way to reproduce/debug with Win10 as I'm running MacOS and don't have a license to run it in a VM or anything.

I'm running MacOS as well and am using a free Windows 10 VM available from Microsoft to test this. The environment is slow to run but it's a good option for testing

@vesanieminen @web-padawan Can you try using v2.3.1-next.2 and let me know if that fixes the issue on Win10 (without using exclusions)?

Sure, I can test it.

I tested with a new branch where I changed to the new v.2.3.1-next.2 version.
I'm using these:

Works fine on Mac but with Windows 10 I get this:

C:\Users\user\Downloads\webpack-wc-demo-ace\webpack-wc-demo-ace>npm start

> webpack-wc-demo@ start C:\Users\user\Downloads\webpack-wc-demo-ace\webpack-wc-demo-ace
> webpack-dev-server

C:\Users\user\Downloads\webpack-wc-demo-ace\webpack-wc-demo-ace\node_modules\webpack-babel-multi-target-plugin\dist\src\excluded.packages.js:5
    return new RegExp(path_1.join('node_modules', ...name));
           ^

SyntaxError: Invalid regular expression: /node_modules\([\w-_]+)-loader/: Unmatched ')'
    at new RegExp (<anonymous>)
    at excludeNodeModulesPackage (C:\Users\user\Downloads\webpack-wc-demo-ace\webpack-wc-demo-ace\node_modules\webpack-babel-multi-target-plugin\dist\src\excluded.packages.js:5:12)
    at Object.<anonymous> (C:\Users\user\Downloads\webpack-wc-demo-ace\webpack-wc-demo-ace\node_modules\webpack-babel-multi-target-plugin\dist\src\excluded.packages.js:14:5)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webpack-wc-demo@ start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack-wc-demo@ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2019-10-18T07_46_11_545Z-debug.log

Contents of the 2019-10-18T07_46_11_545Z-debug.log file:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle webpack-wc-demo@~prestart: webpack-wc-demo@
6 info lifecycle webpack-wc-demo@~start: webpack-wc-demo@
7 verbose lifecycle webpack-wc-demo@~start: unsafe-perm in lifecycle true
8 verbose lifecycle webpack-wc-demo@~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\user\Downloads\webpack-wc-demo-ace\webpack-wc-demo-ace\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\nodejs\;C:\Users\user\AppData\Local\Microsoft\WindowsApps;C:\Users\user\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\user\Downloads\apache-maven-3.6.2-bin\apache-maven-3.6.2\bin;C:\Users\user\AppData\Roaming\npm
9 verbose lifecycle webpack-wc-demo@~start: CWD: C:\Users\user\Downloads\webpack-wc-demo-ace\webpack-wc-demo-ace
10 silly lifecycle webpack-wc-demo@~start: Args: [ '/d /s /c', 'webpack-dev-server' ]
11 silly lifecycle webpack-wc-demo@~start: Returned: code: 1  signal: null
12 info lifecycle webpack-wc-demo@~start: Failed to exec start script
13 verbose stack Error: webpack-wc-demo@ start: `webpack-dev-server`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid webpack-wc-demo@
15 verbose cwd C:\Users\user\Downloads\webpack-wc-demo-ace\webpack-wc-demo-ace
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v10.16.3
19 verbose npm  v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error webpack-wc-demo@ start: `webpack-dev-server`
22 error Exit status 1
23 error Failed at the webpack-wc-demo@ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@DanielSchaffer am I doing something wrong or is this a real issue?

@vesanieminen nope, that's me forgetting to double-escape the path separator for the regexp ๐Ÿคฆโ€โ™‚๏ธ

@vesanieminen pushed a fix for my missing path separator escaping. I'm downloading that VM to try and set up and check it, but if you see this in the next hour or so while that's happening, you can try 2.3.1-next.3

@DanielSchaffer still doesn't work. Here are the logs:

C:\Users\user\Downloads\webpack-wc-demo-vesa\webpack-wc-demo-ace>npm start

> webpack-wc-demo@ start C:\Users\user\Downloads\webpack-wc-demo-vesa\webpack-wc-demo-ace
> webpack-dev-server

C:\Users\user\Downloads\webpack-wc-demo-vesa\webpack-wc-demo-ace\node_modules\webpack-babel-multi-target-plugin\dist\src\excluded.packages.js:8
    return new RegExp(pathPattern);
           ^

SyntaxError: Invalid regular expression: /node_modules\\(webpack\)-dev-server/: Unterminated group
    at new RegExp (<anonymous>)
    at excludeNodeModulesPackage (C:\Users\user\Downloads\webpack-wc-demo-vesa\webpack-wc-demo-ace\node_modules\webpack-babel-multi-target-plugin\dist\src\excluded.packages.js:8:12)
    at Object.<anonymous> (C:\Users\user\Downloads\webpack-wc-demo-vesa\webpack-wc-demo-ace\node_modules\webpack-babel-multi-target-plugin\dist\src\excluded.packages.js:20:5)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webpack-wc-demo@ start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack-wc-demo@ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\user\AppData\Roaming\npm-cache\_logs\2019-10-21T12_02_58_147Z-debug.log

logfile:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle webpack-wc-demo@~prestart: webpack-wc-demo@
6 info lifecycle webpack-wc-demo@~start: webpack-wc-demo@
7 verbose lifecycle webpack-wc-demo@~start: unsafe-perm in lifecycle true
8 verbose lifecycle webpack-wc-demo@~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\user\Downloads\webpack-wc-demo-vesa\webpack-wc-demo-ace\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files\nodejs\;C:\Users\user\AppData\Local\Microsoft\WindowsApps;C:\Users\user\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\user\Downloads\apache-maven-3.6.2-bin\apache-maven-3.6.2\bin;C:\Users\user\AppData\Roaming\npm
9 verbose lifecycle webpack-wc-demo@~start: CWD: C:\Users\user\Downloads\webpack-wc-demo-vesa\webpack-wc-demo-ace
10 silly lifecycle webpack-wc-demo@~start: Args: [ '/d /s /c', 'webpack-dev-server' ]
11 silly lifecycle webpack-wc-demo@~start: Returned: code: 1  signal: null
12 info lifecycle webpack-wc-demo@~start: Failed to exec start script
13 verbose stack Error: webpack-wc-demo@ start: `webpack-dev-server`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid webpack-wc-demo@
15 verbose cwd C:\Users\user\Downloads\webpack-wc-demo-vesa\webpack-wc-demo-ace
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v10.16.3
19 verbose npm  v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error webpack-wc-demo@ start: `webpack-dev-server`
22 error Exit status 1
23 error Failed at the webpack-wc-demo@ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

@vesanieminen @web-padawan @bitfella okay, .next-8 worked for me on my Win10 VM

Yep, now it works for me as well with .next-8. Thanks a lot ๐Ÿ‘
Here's the project I tested with: https://github.com/vesanieminen/webpack-wc-demo/tree/db38af014fb47678012dee6e2e75fcf904ec236c