-
-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect reference to source-map-support/register when using backpack in yarn workspaces #165
Comments
I've just run into a similar issue as well. Seems to be caused here: backpack/packages/backpack-core/config/webpack.config.js Lines 121 to 128 in cf489d6
Looks like the |
Hi, thanks for figuring out the problem source. If you need a quick solution for this, you can follow the solution in this post: #42 (comment) It would be better to fix this issue directly, but if you adjust the backpack.config.js as described in that post and add the dependency to source-map-support manually, there should be no problems with the dependency and you should still be able to get proper source maps. |
Thanks for the link. Ended up doing something similar, but kept the plugin. I was using // Quick fix for source-map-support path resolution
if (config.plugins[1] && config.plugins[1].options && config.plugins[1].options.banner){
config.plugins[1] = new webpack.BannerPlugin({
raw: true,
entryOnly: false,
banner: "require('source-map-support/register');",
})
} |
Hi, I tested your code in my small test project and it worked! Thanks a lot. This solution is better than the other one as I do not need to add source-map-support dependency manually. Meanwhile I also had a look into the source code and was thinking about how to fix this problem. As mentioned above, aside from the absolute path I also had a problem with missing backslashes. I think there must be an escaping problem somewhere, but I did not figure out where the actual problem occurs as the path itself is built correctly (apart from the fact that it is an absolute one), Anyway, maybe the problem could be solved by changing the code as depicted in the following: banner: `require('${
// Is source-map-support installed as project dependency, or linked?
require.resolve('source-map-support').indexOf(process.cwd()) === 0
? // If it's resolvable from the project root, it's a project dependency.
'source-map-support/register'
: // It's not under the project, it's linked via lerna.
path.isAbsolute(require.resolve('source-map-support/register'))
?
process.platform === 'win32'
?
path.relative(config.buildPath, require.resolve('source-map-support/register')).replace(/\\/g,`/`)
:
path.relative(config.buildPath, require.resolve('source-map-support/register'))
:
process.platform === 'win32'
?
require.resolve('source-map-support/register').replace(/\\/g,`/`)
:
require.resolve('source-map-support/register')
}'); It looks a bit ugly, but this code works for me and should not break anything as on non-Windows OS no backslashes will be replaced. Furthermore, relative paths will only be built if they are absolute ones. I think I will make a pull request the next days. Will in this context also try to clean up the code a bit. |
Glad I could help! I tried something similar with |
Hi,
when calling backpack build on a Windows OS in a project that is contained in a yarn workspace, the reference to the module source-map-support/register will not be added correctly to the built main.js
Here is my example:
package.json of workspace:
package.json of check-backpack:
.babelrc of check-backpack:
src/index.js of check-backpack
build/main.js of check-backpack after running yarn backpack build
The correct path to source-map-support\register would be C:\VSC_Projects\check-backpack-workspace\node_modules\source-map-support\register.js . So there are three backslashes missing in build\main.js. Apart from that, the referenced path should also be a relative one, because even if the path was correct, it would only work on my computer otherwise.
The text was updated successfully, but these errors were encountered: