Skip to content

Commit

Permalink
Merge branch v2 into lettertwo/merge-v2-01-20-23
Browse files Browse the repository at this point in the history
* upstream/v2:
  Sort global deps before injecting imports (parcel-bundler#8818)
  Sort CSS module exports (parcel-bundler#8817)
  fix: add extra information to unique bundles (parcel-bundler#8784)
  Don't blow up HMR when <link />s don't have hrefs (parcel-bundler#8800)
  • Loading branch information
lettertwo committed Feb 8, 2023
2 parents 547da8d + adb01fe commit 0eb7f22
Show file tree
Hide file tree
Showing 12 changed files with 129 additions and 117 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions packages/core/core/src/requests/BundleGraphRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import MutableBundleGraph from '../public/MutableBundleGraph';
import {Bundle, NamedBundle} from '../public/Bundle';
import {report} from '../ReporterRunner';
import dumpGraphToGraphViz from '../dumpGraphToGraphViz';
import {unique} from '@parcel/utils';
import {unique, setDifference} from '@parcel/utils';
import {hashString} from '@parcel/hash';
import PluginOptions from '../public/PluginOptions';
import applyRuntimes from '../applyRuntimes';
Expand Down Expand Up @@ -420,7 +420,10 @@ class BundlerRunner {
assert.deepEqual(
bundleNames,
unique(bundleNames),
'Bundles must have unique names',
'Bundles must have unique name. Conflicting names: ' +
[
...setDifference(new Set(bundleNames), new Set(unique(bundleNames))),
].join(),
);
}

Expand Down
2 changes: 1 addition & 1 deletion packages/optimizers/image/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@parcel/utils": "2.0.43",
"@parcel/workers": "2.0.43",
"detect-libc": "^1.0.3",
"self-published": "npm:@parcel/optimizer-image@2.8.4-nightly.2867"
"self-published": "npm:@parcel/optimizer-image@2.8.4-nightly.2871"
},
"devDependencies": {
"@napi-rs/cli": "^2.6.2",
Expand Down
7 changes: 6 additions & 1 deletion packages/runtimes/hmr/src/loaders/hmr-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,11 @@ function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */ {
}

function updateLink(link) {
var href = link.getAttribute('href');

if (!href) {
return;
}
var newLink = link.cloneNode();
newLink.onload = function () {
if (link.parentNode !== null) {
Expand All @@ -313,7 +318,7 @@ function updateLink(link) {
newLink.setAttribute(
'href',
// $FlowFixMe
link.getAttribute('href').split('?')[0] + '?' + Date.now(),
href.split('?')[0] + '?' + Date.now(),
);
// $FlowFixMe
link.parentNode.insertBefore(newLink, link.nextSibling);
Expand Down
4 changes: 3 additions & 1 deletion packages/transformers/css/src/CSSTransformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ export default (new Transformer({
js += s;
};

for (let key in exports) {
// It's possible that the exports can be ordered differently between builds.
// Sorting by key is safe as the order is irrelevant but needs to be deterministic.
for (let key of Object.keys(exports).sort()) {
asset.symbols.set(key, exports[key].name);
add(key);
}
Expand Down
1 change: 1 addition & 0 deletions packages/transformers/js/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ sha-1 = "0.10.0"
dunce = "1.0.1"
pathdiff = "0.2.0"
path-slash = "0.1.4"
indexmap = "1.9.2"
5 changes: 3 additions & 2 deletions packages/transformers/js/core/src/global_replacer.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use indexmap::IndexMap;
use path_slash::PathBufExt;
use std::collections::{HashMap, HashSet};
use std::collections::HashSet;
use std::path::Path;

use swc_atoms::JsWord;
Expand All @@ -14,7 +15,7 @@ pub struct GlobalReplacer<'a> {
pub source_map: &'a SourceMap,
pub items: &'a mut Vec<DependencyDescriptor>,
pub global_mark: Mark,
pub globals: HashMap<JsWord, (SyntaxContext, ast::Stmt)>,
pub globals: IndexMap<JsWord, (SyntaxContext, ast::Stmt)>,
pub project_root: &'a Path,
pub filename: &'a Path,
pub decls: &'a mut HashSet<Id>,
Expand Down
3 changes: 2 additions & 1 deletion packages/transformers/js/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use std::collections::{HashMap, HashSet};
use std::path::{Path, PathBuf};
use std::str::FromStr;

use indexmap::IndexMap;
use path_slash::PathExt;
use serde::{Deserialize, Serialize};
use swc_common::comments::SingleThreadedComments;
Expand Down Expand Up @@ -369,7 +370,7 @@ pub fn transform(config: Config) -> Result<TransformResult, std::io::Error> {
source_map: &source_map,
items: &mut global_deps,
global_mark,
globals: HashMap::new(),
globals: IndexMap::new(),
project_root: Path::new(&config.project_root),
filename: Path::new(&config.filename),
decls: &mut decls,
Expand Down
2 changes: 1 addition & 1 deletion packages/transformers/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"detect-libc": "^1.0.3",
"nullthrows": "^1.1.1",
"regenerator-runtime": "^0.13.7",
"self-published": "npm:@parcel/transformer-js@2.0.0-nightly.1244",
"self-published": "npm:@parcel/transformer-js@2.0.0-nightly.1248",
"semver": "^5.7.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/fs-search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"dependencies": {
"detect-libc": "^1.0.3",
"self-published": "npm:@parcel/fs-search@2.8.4-nightly.2867"
"self-published": "npm:@parcel/fs-search@2.8.4-nightly.2871"
},
"devDependencies": {
"@napi-rs/cli": "^2.6.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/hash/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
},
"dependencies": {
"detect-libc": "^1.0.3",
"self-published": "npm:@parcel/hash@2.8.4-nightly.2867",
"self-published": "npm:@parcel/hash@2.8.4-nightly.2871",
"xxhash-wasm": "^0.4.2"
},
"devDependencies": {
Expand Down
Loading

0 comments on commit 0eb7f22

Please sign in to comment.