@parcel/packager-js 2.8.4-nightly.0 → 2.9.1

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.
package/lib/helpers.js CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.prelude = exports.helpers = void 0;
7
-
8
7
  const prelude = parcelRequireName => `var $parcel$modules = {};
9
8
  var $parcel$inits = {};
10
9
 
@@ -34,7 +33,6 @@ if (parcelRequire == null) {
34
33
  $parcel$global[${JSON.stringify(parcelRequireName)}] = parcelRequire;
35
34
  }
36
35
  `;
37
-
38
36
  exports.prelude = prelude;
39
37
  const helpers = {
40
38
  $parcel$export: `function $parcel$export(e, n, v, s) {
package/lib/index.js CHANGED
@@ -4,70 +4,50 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  function _plugin() {
9
8
  const data = require("@parcel/plugin");
10
-
11
9
  _plugin = function () {
12
10
  return data;
13
11
  };
14
-
15
12
  return data;
16
13
  }
17
-
18
14
  function _utils() {
19
15
  const data = require("@parcel/utils");
20
-
21
16
  _utils = function () {
22
17
  return data;
23
18
  };
24
-
25
19
  return data;
26
20
  }
27
-
28
21
  function _hash() {
29
22
  const data = require("@parcel/hash");
30
-
31
23
  _hash = function () {
32
24
  return data;
33
25
  };
34
-
35
26
  return data;
36
27
  }
37
-
38
28
  function _path() {
39
29
  const data = _interopRequireDefault(require("path"));
40
-
41
30
  _path = function () {
42
31
  return data;
43
32
  };
44
-
45
33
  return data;
46
34
  }
47
-
48
35
  function _nullthrows() {
49
36
  const data = _interopRequireDefault(require("nullthrows"));
50
-
51
37
  _nullthrows = function () {
52
38
  return data;
53
39
  };
54
-
55
40
  return data;
56
41
  }
57
-
58
42
  var _DevPackager = require("./DevPackager");
59
-
60
43
  var _ScopeHoistingPackager = require("./ScopeHoistingPackager");
61
-
62
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
63
-
64
45
  var _default = new (_plugin().Packager)({
65
46
  async loadConfig({
66
47
  config,
67
48
  options
68
49
  }) {
69
50
  var _pkg$contents$name, _pkg$contents;
70
-
71
51
  // Generate a name for the global parcelRequire function that is unique to this project.
72
52
  // This allows multiple parcel builds to coexist on the same page.
73
53
  let pkg = await config.getConfigFrom(_path().default.join(options.projectRoot, 'index'), ['package.json']);
@@ -76,7 +56,6 @@ var _default = new (_plugin().Packager)({
76
56
  parcelRequireName: 'parcelRequire' + (0, _hash().hashString)(name).slice(-4)
77
57
  };
78
58
  },
79
-
80
59
  async package({
81
60
  bundle,
82
61
  bundleGraph,
@@ -88,16 +67,13 @@ var _default = new (_plugin().Packager)({
88
67
  // If this is a non-module script, and there is only one asset with no dependencies,
89
68
  // then we don't need to package at all and can pass through the original code un-wrapped.
90
69
  let contents, map;
91
-
92
70
  if (bundle.env.sourceType === 'script') {
93
71
  let entries = bundle.getEntryAssets();
94
-
95
72
  if (entries.length === 1 && bundleGraph.getDependencies(entries[0]).length === 0) {
96
73
  contents = await entries[0].getCode();
97
74
  map = await entries[0].getMap();
98
75
  }
99
76
  }
100
-
101
77
  if (contents == null) {
102
78
  let packager = bundle.env.shouldScopeHoist ? new _ScopeHoistingPackager.ScopeHoistingPackager(options, bundleGraph, bundle, (0, _nullthrows().default)(config).parcelRequireName) : new _DevPackager.DevPackager(options, bundleGraph, bundle, (0, _nullthrows().default)(config).parcelRequireName);
103
79
  ({
@@ -105,10 +81,10 @@ var _default = new (_plugin().Packager)({
105
81
  map
106
82
  } = await packager.package());
107
83
  }
84
+ contents += '\n' + (await getSourceMapSuffix(getSourceMapReference, map));
108
85
 
109
- contents += '\n' + (await getSourceMapSuffix(getSourceMapReference, map)); // For library builds, we need to replace URL references with their final resolved paths.
86
+ // For library builds, we need to replace URL references with their final resolved paths.
110
87
  // For non-library builds, this is handled in the JS runtime.
111
-
112
88
  if (bundle.env.isLibrary) {
113
89
  ({
114
90
  contents,
@@ -121,7 +97,6 @@ var _default = new (_plugin().Packager)({
121
97
  getReplacement: s => JSON.stringify(s).slice(1, -1)
122
98
  }));
123
99
  }
124
-
125
100
  return (0, _utils().replaceInlineReferences)({
126
101
  bundle,
127
102
  bundleGraph,
@@ -134,14 +109,10 @@ var _default = new (_plugin().Packager)({
134
109
  map
135
110
  });
136
111
  }
137
-
138
112
  });
139
-
140
113
  exports.default = _default;
141
-
142
114
  async function getSourceMapSuffix(getSourceMapReference, map) {
143
115
  let sourcemapReference = await getSourceMapReference(map);
144
-
145
116
  if (sourcemapReference != null) {
146
117
  return '//# sourceMappingURL=' + sourcemapReference + '\n';
147
118
  } else {
package/lib/utils.js CHANGED
@@ -5,19 +5,14 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getSpecifier = getSpecifier;
7
7
  exports.replaceScriptDependencies = replaceScriptDependencies;
8
-
9
8
  function _nullthrows() {
10
9
  const data = _interopRequireDefault(require("nullthrows"));
11
-
12
10
  _nullthrows = function () {
13
11
  return data;
14
12
  };
15
-
16
13
  return data;
17
14
  }
18
-
19
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
20
-
21
16
  // This replaces __parcel__require__ references left by the transformer with
22
17
  // parcelRequire calls of the resolved asset id. This lets runtimes work within
23
18
  // script bundles, which must be outside the bundle wrapper so their variables are global.
@@ -33,30 +28,24 @@ function replaceScriptDependencies(bundleGraph, bundle, code, map, parcelRequire
33
28
  lineCount++;
34
29
  return '\n';
35
30
  }
36
-
37
31
  let dep = (0, _nullthrows().default)(dependencies.find(d => getSpecifier(d) === s));
38
32
  let resolved = (0, _nullthrows().default)(bundleGraph.getResolvedAsset(dep, bundle));
39
33
  let publicId = bundleGraph.getAssetPublicId(resolved);
40
34
  let replacement = `${parcelRequireName}("${publicId}")`;
41
-
42
35
  if (map) {
43
36
  let lengthDifference = replacement.length - m.length;
44
-
45
37
  if (lengthDifference !== 0) {
46
38
  map.offsetColumns(lineCount + 1, i + offset - columnStartIndex + m.length, lengthDifference);
47
39
  offset += lengthDifference;
48
40
  }
49
41
  }
50
-
51
42
  return replacement;
52
43
  });
53
44
  return code;
54
45
  }
55
-
56
46
  function getSpecifier(dep) {
57
47
  if (typeof dep.meta.placeholder === 'string') {
58
48
  return dep.meta.placeholder;
59
49
  }
60
-
61
50
  return dep.specifier;
62
51
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@parcel/packager-js",
3
- "version": "2.8.4-nightly.0+7b79c6d",
3
+ "version": "2.9.1",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -17,16 +17,16 @@
17
17
  "source": "src/index.js",
18
18
  "engines": {
19
19
  "node": ">= 12.0.0",
20
- "parcel": "2.8.4-nightly.0+7b79c6d"
20
+ "parcel": "^2.9.1"
21
21
  },
22
22
  "dependencies": {
23
- "@parcel/diagnostic": "2.8.4-nightly.0+7b79c6d",
24
- "@parcel/hash": "2.8.4-nightly.0+7b79c6d",
25
- "@parcel/plugin": "2.8.4-nightly.0+7b79c6d",
23
+ "@parcel/diagnostic": "2.9.1",
24
+ "@parcel/hash": "2.9.1",
25
+ "@parcel/plugin": "2.9.1",
26
26
  "@parcel/source-map": "^2.1.1",
27
- "@parcel/utils": "2.8.4-nightly.0+7b79c6d",
27
+ "@parcel/utils": "2.9.1",
28
28
  "globals": "^13.2.0",
29
29
  "nullthrows": "^1.1.1"
30
30
  },
31
- "gitHead": "7b79c6d69ffabef89810a8db61e9abdeb70d6990"
31
+ "gitHead": "5c5dc302b559f0b0d8c57b4d638aac521c879b70"
32
32
  }
@@ -18,7 +18,9 @@ import {
18
18
  import SourceMap from '@parcel/source-map';
19
19
  import nullthrows from 'nullthrows';
20
20
  import invariant from 'assert';
21
- import ThrowableDiagnostic from '@parcel/diagnostic';
21
+ import ThrowableDiagnostic, {
22
+ convertSourceLocationToHighlight,
23
+ } from '@parcel/diagnostic';
22
24
  import globals from 'globals';
23
25
  import path from 'path';
24
26
 
@@ -682,12 +684,7 @@ ${code}
682
684
  {
683
685
  filePath: nullthrows(dep.sourcePath),
684
686
  codeHighlights: dep.loc
685
- ? [
686
- {
687
- start: dep.loc.start,
688
- end: dep.loc.end,
689
- },
690
- ]
687
+ ? [convertSourceLocationToHighlight(dep.loc)]
691
688
  : [],
692
689
  },
693
690
  ],