Skip to content

Commit d872e62

Browse files
authored
Merge branch 'v2' into mszczepanski/use-parking_lot-locks
2 parents 2125d8f + 89a69f5 commit d872e62

File tree

4 files changed

+77
-4
lines changed

4 files changed

+77
-4
lines changed

crates/node-bindings/src/init_sentry/sentry.rs

+12
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ static SENTRY_GUARD: Lazy<Arc<Mutex<Option<ClientInitGuard>>>> =
1818
Lazy::new(|| Arc::new(Mutex::new(None)));
1919
const TIMEOUT: Duration = Duration::from_secs(2);
2020

21+
fn value_to_string(value: &serde_json::Value) -> String {
22+
match value {
23+
serde_json::Value::String(inner) => inner.clone(),
24+
other => other.to_string(),
25+
}
26+
}
27+
2128
#[napi]
2229
fn init_sentry() -> Result<(), Status> {
2330
if std::env::var("PARCEL_ENABLE_SENTRY").is_err() {
@@ -51,6 +58,11 @@ fn init_sentry() -> Result<(), Status> {
5158
..Default::default()
5259
};
5360

61+
let sentry_tags: HashMap<String, String> = sentry_tags
62+
.iter()
63+
.map(|(k, v)| (k.clone(), value_to_string(v)))
64+
.collect::<HashMap<String, String>>();
65+
5466
if let Some(release) = sentry_tags.get("release") {
5567
sentry_client_options.release = Some(release.to_string().into());
5668
}

packages/bundlers/default/src/DefaultBundler.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,9 @@ function createIdealGraph(
476476
node.type === 'asset' &&
477477
(!Array.isArray(c.types) || c.types.includes(node.value.type))
478478
) {
479-
// +1 accounts for leading slash
480-
let projectRelativePath = node.value.filePath.slice(
481-
config.projectRoot.length + 1,
479+
let projectRelativePath = path.relative(
480+
config.projectRoot,
481+
node.value.filePath,
482482
);
483483
if (!assetRegexes.some(regex => regex.test(projectRelativePath))) {
484484
return;

packages/core/core/src/requests/WriteBundlesRequest.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ async function run({input, api, farm, options}) {
6767
if (bundle.isPlaceholder) {
6868
let hash = bundle.id.slice(-8);
6969
hashRefToNameHash.set(bundle.hashReference, hash);
70-
let name = nullthrows(bundle.name).replace(bundle.hashReference, hash);
70+
let name = nullthrows(
71+
bundle.name,
72+
`Expected ${bundle.type} bundle to have a name`,
73+
).replace(bundle.hashReference, hash);
7174
res.set(bundle.id, {
7275
filePath: joinProjectPath(bundle.target.distDir, name),
7376
type: bundle.type, // FIXME: this is wrong if the packager changes the type...

packages/core/integration-tests/test/bundler.js

+58
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,64 @@ describe('bundler', function () {
17691769
},
17701770
]);
17711771
});
1772+
1773+
it('should support globs matching outside of the project root', async function () {
1774+
const rootDir = path.join(dir, 'root');
1775+
overlayFS.mkdirp(rootDir);
1776+
await fsFixture(overlayFS, rootDir)`
1777+
yarn.lock:
1778+
// Required for config loading
1779+
1780+
package.json:
1781+
{
1782+
"@parcel/bundler-default": {
1783+
"minBundleSize": 0,
1784+
"manualSharedBundles": [{
1785+
"name": "vendor",
1786+
"root": "vendor.js",
1787+
"assets": [
1788+
"in-project.js",
1789+
"../outside-project.js"
1790+
]
1791+
}]
1792+
}
1793+
}
1794+
1795+
index.html:
1796+
<script type="module" src="./index.js"></script>
1797+
1798+
in-project.js:
1799+
export default 'in-project';
1800+
1801+
vendor.js:
1802+
export * from './in-project';
1803+
export * from '../outside-project';
1804+
1805+
index.js:
1806+
import * as vendor from './vendor';
1807+
1808+
console.log(vendor.inProj);
1809+
console.log(vendor.outProj);`;
1810+
1811+
await fsFixture(overlayFS, dir)`
1812+
outside-project.js:
1813+
export default 'outside-project';`;
1814+
1815+
let b = await bundle(path.join(rootDir, 'index.html'), {
1816+
defaultTargetOptions: {
1817+
shouldScopeHoist: false,
1818+
shouldOptimize: false,
1819+
sourceMaps: false,
1820+
},
1821+
inputFS: overlayFS,
1822+
});
1823+
1824+
assertBundles(b, [
1825+
{assets: ['index.html']},
1826+
{assets: ['in-project.js', 'outside-project.js']},
1827+
{assets: ['esmodule-helpers.js', 'index.js', 'vendor.js']},
1828+
]);
1829+
});
17721830
});
17731831

17741832
it('should reuse type change bundles from parent bundle groups', async function () {

0 commit comments

Comments
 (0)