jaredpalmer / jaredpalmer/backpack

Incorrect reference to source-map-support/register when using backpack in yarn workspaces

Open
#165 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
4.4k
Forks
164
PR merge metrics
No merged PRs in 30d

Description

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:
```
{
"private": true,
"workspaces": ["check-backpack"]
}
```

package.json of check-backpack:
```
{
"name": "ckeck-backpack",
"version": "1.0.0",
"main": "src/index.js",
"license": "MIT",
"devDependencies": {
"backpack-core": "^0.8.4"
}
}
```

.babelrc of check-backpack:
```
{
"presets": [
"backpack-core/babel"
]
}
```

src/index.js of check-backpack
```
console.log('Hello World!')
```

build/main.js of check-backpack after running yarn backpack build
```
require("C:VSC_Projectscheck-backpack-workspace\node_modulessource-map-support\register.js"),module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="/",t(t.s=0)}([function(e,r,t){e.exports=t(1)},function(e,r){console.log("Hello World!")}]);
//# sourceMappingURL=main.map
```

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.

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue on Windows using the shown workspace package.json, .babelrc, and src/index.js, then run yarn backpack build. Inspect build/main.js and the Backpack build entry point to trace how source-map-support/register is written. Done means the generated reference preserves the Windows path correctly and is relative rather than tied to the reporter’s machine.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js, webpack
Domain
build-system
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.