@parcel/packager-js 2.0.0-dev.1789 → 2.0.0-dev.1795

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -174,7 +174,12 @@ class DevPackager {
174
174
  contents += ', null';
175
175
  }
176
176
  if (usedHelpers & 2) {
177
- contents += ', ' + JSON.stringify(this.bundle.target.publicUrl);
177
+ // Ensure the public url always ends with a slash to code can easily join paths to it.
178
+ let publicUrl = this.bundle.target.publicUrl;
179
+ if (!publicUrl.endsWith('/')) {
180
+ publicUrl += '/';
181
+ }
182
+ contents += ', ' + JSON.stringify(publicUrl);
178
183
  }
179
184
  contents += ')\n';
180
185
 
@@ -1011,7 +1011,7 @@ ${code}
1011
1011
  // Add the prelude if this is potentially the first JS bundle to load in a
1012
1012
  // particular context (e.g. entry scripts in HTML, workers, etc.).
1013
1013
  let parentBundles = this.bundleGraph.getParentBundles(this.bundle);
1014
- let mightBeFirstJS = parentBundles.length === 0 || parentBundles.some(b => b.type !== 'js') || this.bundleGraph.getBundleGroupsContainingBundle(this.bundle).some(g => this.bundleGraph.isEntryBundleGroup(g)) || this.bundle.env.isIsolated() || this.bundle.bundleBehavior === 'isolated';
1014
+ let mightBeFirstJS = parentBundles.length === 0 || parentBundles.some(b => b.type !== 'js' || b.env.context !== this.bundle.env.context) || this.bundleGraph.getBundleGroupsContainingBundle(this.bundle).some(g => this.bundleGraph.isEntryBundleGroup(g)) || this.bundle.env.isIsolated() || this.bundle.bundleBehavior === 'isolated';
1015
1015
  if (mightBeFirstJS) {
1016
1016
  let preludeCode = (0, _helpers.prelude)(this.parcelRequireName);
1017
1017
  res += preludeCode;
package/lib/helpers.js CHANGED
@@ -144,7 +144,12 @@ const $parcel$distDir = (env, bundle) => {
144
144
  return `var $parcel$distDir = ${JSON.stringify(distDir)};\n`;
145
145
  };
146
146
  const $parcel$publicUrl = (env, bundle) => {
147
- return `var $parcel$publicUrl = ${JSON.stringify(bundle.target.publicUrl)};\n`;
147
+ // Ensure the public url always ends with a slash to code can easily join paths to it.
148
+ let publicUrl = bundle.target.publicUrl;
149
+ if (!publicUrl.endsWith('/')) {
150
+ publicUrl += '/';
151
+ }
152
+ return `var $parcel$publicUrl = ${JSON.stringify(publicUrl)};\n`;
148
153
  };
149
154
  const $parcel$import = env => {
150
155
  return `var $parcel$import = ${fnExpr(env, ['url'], ['return import($parcel$distDir + "/" + url);'])};\n`;
package/lib/index.js CHANGED
@@ -56,7 +56,7 @@ var _default = exports.default = new (_plugin().Packager)({
56
56
  config,
57
57
  options
58
58
  }) {
59
- var _packageName$contents, _conf$contents;
59
+ var _conf$contents;
60
60
  let packageKey = '@parcel/packager-js';
61
61
  let conf = await config.getConfigFrom(options.projectRoot + '/index', [], {
62
62
  packageKey
@@ -75,7 +75,7 @@ var _default = exports.default = new (_plugin().Packager)({
75
75
  let packageName = await config.getConfigFrom(options.projectRoot + '/index', [], {
76
76
  packageKey: 'name'
77
77
  });
78
- let name = (packageName === null || packageName === void 0 || (_packageName$contents = packageName.contents) === null || _packageName$contents === void 0 ? void 0 : _packageName$contents.name) ?? '';
78
+ let name = (packageName === null || packageName === void 0 ? void 0 : packageName.contents) ?? '';
79
79
  return {
80
80
  parcelRequireName: 'parcelRequire' + (0, _rust().hashString)(name).slice(-4),
81
81
  unstable_asyncBundleRuntime: Boolean(conf === null || conf === void 0 || (_conf$contents = conf.contents) === null || _conf$contents === void 0 ? void 0 : _conf$contents.unstable_asyncBundleRuntime)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/packager-js",
3
- "version": "2.0.0-dev.1789+0b82b13d6",
3
+ "version": "2.0.0-dev.1795+9f297b15c",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,17 +17,17 @@
17
17
  "source": "src/index.js",
18
18
  "engines": {
19
19
  "node": ">= 16.0.0",
20
- "parcel": "^2.0.0-dev.1787+0b82b13d6"
20
+ "parcel": "^2.0.0-dev.1793+9f297b15c"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/diagnostic": "2.0.0-dev.1789+0b82b13d6",
24
- "@parcel/plugin": "2.0.0-dev.1789+0b82b13d6",
25
- "@parcel/rust": "2.13.3-dev.3412+0b82b13d6",
23
+ "@parcel/diagnostic": "2.0.0-dev.1795+9f297b15c",
24
+ "@parcel/plugin": "2.0.0-dev.1795+9f297b15c",
25
+ "@parcel/rust": "2.13.3-dev.3418+9f297b15c",
26
26
  "@parcel/source-map": "^2.1.1",
27
- "@parcel/types": "2.0.0-dev.1789+0b82b13d6",
28
- "@parcel/utils": "2.0.0-dev.1789+0b82b13d6",
27
+ "@parcel/types": "2.0.0-dev.1795+9f297b15c",
28
+ "@parcel/utils": "2.0.0-dev.1795+9f297b15c",
29
29
  "globals": "^13.2.0",
30
30
  "nullthrows": "^1.1.1"
31
31
  },
32
- "gitHead": "0b82b13d6c0dae58ae636983bbd57dbcf94fff89"
32
+ "gitHead": "9f297b15c3cc3b74136232040b3149f0baae0060"
33
33
  }
@@ -220,7 +220,12 @@ export class DevPackager {
220
220
  }
221
221
 
222
222
  if (usedHelpers & 2) {
223
- contents += ', ' + JSON.stringify(this.bundle.target.publicUrl);
223
+ // Ensure the public url always ends with a slash to code can easily join paths to it.
224
+ let publicUrl = this.bundle.target.publicUrl;
225
+ if (!publicUrl.endsWith('/')) {
226
+ publicUrl += '/';
227
+ }
228
+ contents += ', ' + JSON.stringify(publicUrl);
224
229
  }
225
230
 
226
231
  contents += ')\n';
@@ -1398,7 +1398,9 @@ ${code}
1398
1398
  let parentBundles = this.bundleGraph.getParentBundles(this.bundle);
1399
1399
  let mightBeFirstJS =
1400
1400
  parentBundles.length === 0 ||
1401
- parentBundles.some(b => b.type !== 'js') ||
1401
+ parentBundles.some(
1402
+ b => b.type !== 'js' || b.env.context !== this.bundle.env.context,
1403
+ ) ||
1402
1404
  this.bundleGraph
1403
1405
  .getBundleGroupsContainingBundle(this.bundle)
1404
1406
  .some(g => this.bundleGraph.isEntryBundleGroup(g)) ||
package/src/helpers.js CHANGED
@@ -172,9 +172,12 @@ const $parcel$distDir = (env: Environment, bundle: NamedBundle): string => {
172
172
  };
173
173
 
174
174
  const $parcel$publicUrl = (env: Environment, bundle: NamedBundle): string => {
175
- return `var $parcel$publicUrl = ${JSON.stringify(
176
- bundle.target.publicUrl,
177
- )};\n`;
175
+ // Ensure the public url always ends with a slash to code can easily join paths to it.
176
+ let publicUrl = bundle.target.publicUrl;
177
+ if (!publicUrl.endsWith('/')) {
178
+ publicUrl += '/';
179
+ }
180
+ return `var $parcel$publicUrl = ${JSON.stringify(publicUrl)};\n`;
178
181
  };
179
182
 
180
183
  const $parcel$import = (env: Environment): string => {
package/src/index.js CHANGED
@@ -60,7 +60,7 @@ export default (new Packager({
60
60
  },
61
61
  );
62
62
 
63
- let name = packageName?.contents?.name ?? '';
63
+ let name = packageName?.contents ?? '';
64
64
  return {
65
65
  parcelRequireName: 'parcelRequire' + hashString(name).slice(-4),
66
66
  unstable_asyncBundleRuntime: Boolean(