@atlaspack/core 2.20.1-typescript-17c3d1dec.0 → 2.22.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,56 @@
1
1
  # @atlaspack/core
2
2
 
3
+ ## 2.22.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#731](https://github.com/atlassian-labs/atlaspack/pull/731) [`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2) Thanks [@marcins](https://github.com/marcins)! - Implement "inline isolated" scripts
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
12
+ - @atlaspack/feature-flags@2.21.0
13
+ - @atlaspack/utils@2.18.0
14
+ - @atlaspack/rust@3.5.0
15
+ - @atlaspack/cache@3.2.18
16
+ - @atlaspack/fs@2.15.18
17
+ - @atlaspack/graph@3.5.12
18
+ - @atlaspack/package-manager@2.14.23
19
+ - @atlaspack/workers@2.14.23
20
+ - @atlaspack/logger@2.14.15
21
+ - @atlaspack/profiler@2.14.20
22
+ - @atlaspack/types@2.15.13
23
+ - @atlaspack/plugin@2.14.23
24
+
25
+ ## 2.21.0
26
+
27
+ ### Minor Changes
28
+
29
+ - [#723](https://github.com/atlassian-labs/atlaspack/pull/723) [`43fdd22`](https://github.com/atlassian-labs/atlaspack/commit/43fdd223860fbc97af17d68c65419b97412cb888) Thanks [@vykimnguyen](https://github.com/vykimnguyen)! - adding projectRoot option
30
+
31
+ ### Patch Changes
32
+
33
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
34
+
35
+ - [#725](https://github.com/atlassian-labs/atlaspack/pull/725) [`12bee0e`](https://github.com/atlassian-labs/atlaspack/commit/12bee0e23f0464d7f6bd3e24fbe0d19c126d587d) Thanks [@marcins](https://github.com/marcins)! - Clean up `atlaspackV3CleanShutdown` feature flag.
36
+
37
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94), [`12bee0e`](https://github.com/atlassian-labs/atlaspack/commit/12bee0e23f0464d7f6bd3e24fbe0d19c126d587d)]:
38
+ - @atlaspack/package-manager@2.14.22
39
+ - @atlaspack/feature-flags@2.20.1
40
+ - @atlaspack/build-cache@2.13.4
41
+ - @atlaspack/diagnostic@2.14.2
42
+ - @atlaspack/profiler@2.14.19
43
+ - @atlaspack/workers@2.14.22
44
+ - @atlaspack/events@2.14.2
45
+ - @atlaspack/logger@2.14.14
46
+ - @atlaspack/plugin@2.14.22
47
+ - @atlaspack/cache@3.2.17
48
+ - @atlaspack/graph@3.5.11
49
+ - @atlaspack/types@2.15.12
50
+ - @atlaspack/utils@2.17.4
51
+ - @atlaspack/rust@3.4.2
52
+ - @atlaspack/fs@2.15.17
53
+
3
54
  ## 2.20.0
4
55
 
5
56
  ### Minor Changes
package/lib/Atlaspack.js CHANGED
@@ -226,13 +226,12 @@ class Atlaspack {
226
226
  env: resolvedOptions.env,
227
227
  fs: inputFS && new _atlaspackV.FileSystemV3(inputFS),
228
228
  defaultTargetOptions: resolvedOptions.defaultTargetOptions,
229
- lmdb
229
+ lmdb,
230
+ featureFlags: resolvedOptions.featureFlags
231
+ });
232
+ this.#disposable.add(() => {
233
+ rustAtlaspack.end();
230
234
  });
231
- if (featureFlags.atlaspackV3CleanShutdown) {
232
- this.#disposable.add(() => {
233
- rustAtlaspack.end();
234
- });
235
- }
236
235
  }
237
236
  // @ts-expect-error TS2454
238
237
  this.rustAtlaspack = rustAtlaspack;
@@ -930,7 +930,7 @@ class BundleGraph {
930
930
  isAssetReachableFromBundle(asset, bundle) {
931
931
  // If a bundle's environment is isolated, it can't access assets present
932
932
  // in any ancestor bundles. Don't consider any assets reachable.
933
- if (_Environment.ISOLATED_ENVS.has((0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline) {
933
+ if (_Environment.ISOLATED_ENVS.has((0, _EnvironmentManager.fromEnvironmentId)(bundle.env).context) || !bundle.isSplittable || bundle.bundleBehavior === _types.BundleBehavior.isolated || bundle.bundleBehavior === _types.BundleBehavior.inline || bundle.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
934
934
  return false;
935
935
  }
936
936
 
@@ -940,7 +940,7 @@ class BundleGraph {
940
940
  return bundleGroups.every(bundleGroup => {
941
941
  // If the asset is in any sibling bundles of the original bundle, it is reachable.
942
942
  let bundles = this.getBundlesInBundleGroup(bundleGroup);
943
- if (bundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
943
+ if (bundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && b.bundleBehavior !== _types.BundleBehavior.inlineIsolated && this.bundleHasAsset(b, asset))) {
944
944
  return true;
945
945
  }
946
946
 
@@ -950,7 +950,7 @@ class BundleGraph {
950
950
  // Check that every parent bundle has a bundle group in its ancestry that contains the asset.
951
951
  return parentBundleNodes.every(bundleNodeId => {
952
952
  let bundleNode = (0, _nullthrows().default)(this._graph.getNode(bundleNodeId));
953
- if (bundleNode.type !== 'bundle' || bundleNode.value.bundleBehavior === _types.BundleBehavior.isolated || bundleNode.value.bundleBehavior === _types.BundleBehavior.inline) {
953
+ if (bundleNode.type !== 'bundle' || bundleNode.value.bundleBehavior === _types.BundleBehavior.isolated || bundleNode.value.bundleBehavior === _types.BundleBehavior.inline || bundleNode.value.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
954
954
  return false;
955
955
  }
956
956
  let isReachable = true;
@@ -965,7 +965,7 @@ class BundleGraph {
965
965
  }
966
966
  if (node.type === 'bundle_group') {
967
967
  let childBundles = this.getBundlesInBundleGroup(node.value);
968
- if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && this.bundleHasAsset(b, asset))) {
968
+ if (childBundles.some(b => b.id !== bundle.id && b.bundleBehavior !== _types.BundleBehavior.isolated && b.bundleBehavior !== _types.BundleBehavior.inline && b.bundleBehavior !== _types.BundleBehavior.inlineIsolated && this.bundleHasAsset(b, asset))) {
969
969
  actions.skipChildren();
970
970
  return;
971
971
  }
@@ -1057,7 +1057,7 @@ class BundleGraph {
1057
1057
  getBundles(opts) {
1058
1058
  let bundles = [];
1059
1059
  this.traverseBundles(bundle => {
1060
- if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline) {
1060
+ if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1061
1061
  bundles.push(bundle);
1062
1062
  }
1063
1063
  });
@@ -1108,7 +1108,7 @@ class BundleGraph {
1108
1108
  let bundleNode = (0, _nullthrows().default)(this._graph.getNode(bundleNodeId));
1109
1109
  (0, _assert().default)(bundleNode.type === 'bundle');
1110
1110
  let bundle = bundleNode.value;
1111
- if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline) {
1111
+ if (opts !== null && opts !== void 0 && opts.includeInline || bundle.bundleBehavior !== _types.BundleBehavior.inline && bundle.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1112
1112
  bundles.add(bundle);
1113
1113
  }
1114
1114
  for (let referencedBundle of this.getReferencedBundles(bundle, {
@@ -1132,7 +1132,7 @@ class BundleGraph {
1132
1132
  if (node.value.id === bundle.id) {
1133
1133
  return;
1134
1134
  }
1135
- if (includeInline || node.value.bundleBehavior !== _types.BundleBehavior.inline) {
1135
+ if (includeInline || node.value.bundleBehavior !== _types.BundleBehavior.inline && node.value.bundleBehavior !== _types.BundleBehavior.inlineIsolated) {
1136
1136
  referencedBundles.add(node.value);
1137
1137
  }
1138
1138
  if (!recursive) {
@@ -1445,7 +1445,7 @@ class BundleGraph {
1445
1445
  includeInline: true
1446
1446
  });
1447
1447
  for (let referenced of referencedBundles) {
1448
- if (referenced.bundleBehavior === _types.BundleBehavior.inline) {
1448
+ if (referenced.bundleBehavior === _types.BundleBehavior.inline || referenced.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
1449
1449
  bundles.push(referenced);
1450
1450
  addReferencedBundles(referenced);
1451
1451
  }
@@ -1453,7 +1453,7 @@ class BundleGraph {
1453
1453
  };
1454
1454
  addReferencedBundles(bundle);
1455
1455
  this.traverseBundles((childBundle, _, traversal) => {
1456
- if (childBundle.bundleBehavior === _types.BundleBehavior.inline) {
1456
+ if (childBundle.bundleBehavior === _types.BundleBehavior.inline || childBundle.bundleBehavior === _types.BundleBehavior.inlineIsolated) {
1457
1457
  bundles.push(childBundle);
1458
1458
  } else if (childBundle.id !== bundle.id) {
1459
1459
  traversal.skipChildren();
@@ -254,7 +254,7 @@ class PackagerRunner {
254
254
  };
255
255
  }
256
256
  getSourceMapReference(bundle, map) {
257
- if (map && bundle.env.sourceMap && bundle.bundleBehavior !== 'inline') {
257
+ if (map && bundle.env.sourceMap && bundle.bundleBehavior !== 'inline' && bundle.bundleBehavior !== 'inlineIsolated') {
258
258
  if (bundle.env.sourceMap && bundle.env.sourceMap.inline) {
259
259
  return this.generateSourceMap((0, _Bundle.bundleToInternalBundle)(bundle), map);
260
260
  } else {
@@ -300,7 +300,7 @@ class PackagerRunner {
300
300
  category: 'package'
301
301
  }),
302
302
  getInlineBundleContents: async (bundle, bundleGraph) => {
303
- if (bundle.bundleBehavior !== 'inline') {
303
+ if (bundle.bundleBehavior !== 'inline' && bundle.bundleBehavior !== 'inlineIsolated') {
304
304
  throw new Error('Bundle is not inline and unable to retrieve contents');
305
305
  }
306
306
  let res = await this.getBundleResult((0, _Bundle.bundleToInternalBundle)(bundle), (0, _BundleGraph.bundleGraphToInternalBundleGraph)(bundleGraph), configs, bundleConfigs);
@@ -52,7 +52,8 @@ class BitFlags {
52
52
  exports.BitFlags = BitFlags;
53
53
  const bundleBehaviorMap = exports.bundleBehaviorMap = new BitFlags({
54
54
  inline: 0,
55
- isolated: 1
55
+ isolated: 1,
56
+ inlineIsolated: 2
56
57
  });
57
58
  const dependencyPriorityMap = exports.dependencyPriorityMap = new BitFlags({
58
59
  sync: 0,
@@ -82,9 +82,9 @@ async function run({
82
82
  const allBundles = bundleGraph.getBundles({
83
83
  includeInline: (0, _featureFlags().getFeatureFlag)('inlineBundlesSourceMapFixes')
84
84
  });
85
- const bundles = allBundles
85
+ const bundles = allBundles.filter(
86
86
  // @ts-expect-error TS7006
87
- .filter(bundle => bundle.bundleBehavior !== 'inline')
87
+ bundle => bundle.bundleBehavior !== 'inline' && bundle.bundleBehavior !== 'inline-isolated')
88
88
  // @ts-expect-error TS7006
89
89
  .filter(bundle => {
90
90
  // Do not package and write placeholder bundles to disk. We just
@@ -115,13 +115,21 @@ async function resolveOptions(initialOptions) {
115
115
  // ignore failing stat call
116
116
  }
117
117
  }
118
+ let projectRoot;
119
+ if (initialOptions.projectRoot) {
120
+ // Use explicitly provided projectRoot
121
+ if (!_path().default.isAbsolute(initialOptions.projectRoot)) {
122
+ throw new Error('Specified project root must be an absolute path');
123
+ }
124
+ projectRoot = initialOptions.projectRoot;
125
+ } else {
126
+ // getRootDir treats the input as files, so getRootDir(["/home/user/myproject"]) returns "/home/user".
127
+ // Instead we need to make the the entry refer to some file inside the specified folders if entries refers to the directory.
128
+ let entryRoot = (0, _utils().getRootDir)(shouldMakeEntryReferFolder ? [_path().default.join(entries[0], 'index')] : entries);
129
+ let projectRootFile = (await (0, _utils().resolveConfig)(inputFS, _path().default.join(entryRoot, 'index'), [...LOCK_FILE_NAMES, '.git', '.hg'], _path().default.parse(entryRoot).root)) || _path().default.join(inputCwd, 'index'); // ? Should this just be rootDir
118
130
 
119
- // getRootDir treats the input as files, so getRootDir(["/home/user/myproject"]) returns "/home/user".
120
- // Instead we need to make the the entry refer to some file inside the specified folders if entries refers to the directory.
121
- let entryRoot = (0, _utils().getRootDir)(shouldMakeEntryReferFolder ? [_path().default.join(entries[0], 'index')] : entries);
122
- let projectRootFile = (await (0, _utils().resolveConfig)(inputFS, _path().default.join(entryRoot, 'index'), [...LOCK_FILE_NAMES, '.git', '.hg'], _path().default.parse(entryRoot).root)) || _path().default.join(inputCwd, 'index'); // ? Should this just be rootDir
123
-
124
- let projectRoot = _path().default.dirname(projectRootFile);
131
+ projectRoot = _path().default.dirname(projectRootFile);
132
+ }
125
133
  const gitRoot = await findGitRepositoryRoot(inputFS, projectRoot);
126
134
  if (inputFS instanceof _fs().NodeVCSAwareFS) {
127
135
  inputFS.setGitRepoPath(gitRoot);
package/lib/types.d.ts CHANGED
@@ -123,6 +123,7 @@ export type Dependency = {
123
123
  export declare const BundleBehavior: {
124
124
  readonly inline: 0;
125
125
  readonly isolated: 1;
126
+ readonly inlineIsolated: 2;
126
127
  };
127
128
  export declare const BundleBehaviorNames: Array<keyof typeof BundleBehavior>;
128
129
  export type Asset = {
package/lib/types.js CHANGED
@@ -32,7 +32,8 @@ const ExportsCondition = exports.ExportsCondition = {
32
32
  };
33
33
  const BundleBehavior = exports.BundleBehavior = {
34
34
  inline: 0,
35
- isolated: 1
35
+ isolated: 1,
36
+ inlineIsolated: 2
36
37
  };
37
38
 
38
39
  // @ts-expect-error TS2322
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/core",
3
- "version": "2.20.1-typescript-17c3d1dec.0",
3
+ "version": "2.22.0",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -22,22 +22,22 @@
22
22
  "check-ts": "tsc --emitDeclarationOnly --rootDir src"
23
23
  },
24
24
  "dependencies": {
25
- "@atlaspack/build-cache": "2.13.4-typescript-17c3d1dec.0",
26
- "@atlaspack/cache": "3.2.17-typescript-17c3d1dec.0",
27
- "@atlaspack/diagnostic": "2.14.2-typescript-17c3d1dec.0",
28
- "@atlaspack/events": "2.14.2-typescript-17c3d1dec.0",
29
- "@atlaspack/feature-flags": "2.20.1-typescript-17c3d1dec.0",
30
- "@atlaspack/fs": "2.15.17-typescript-17c3d1dec.0",
31
- "@atlaspack/graph": "3.5.11-typescript-17c3d1dec.0",
32
- "@atlaspack/logger": "2.14.14-typescript-17c3d1dec.0",
33
- "@atlaspack/package-manager": "2.14.22-typescript-17c3d1dec.0",
34
- "@atlaspack/plugin": "2.14.22-typescript-17c3d1dec.0",
35
- "@atlaspack/profiler": "2.14.19-typescript-17c3d1dec.0",
36
- "@atlaspack/rust": "3.4.2-typescript-17c3d1dec.0",
37
- "@atlaspack/types": "2.15.12-typescript-17c3d1dec.0",
38
- "@atlaspack/utils": "2.17.4-typescript-17c3d1dec.0",
39
- "@atlaspack/workers": "2.14.22-typescript-17c3d1dec.0",
40
25
  "@mischnic/json-sourcemap": "^0.1.0",
26
+ "@atlaspack/build-cache": "2.13.4",
27
+ "@atlaspack/cache": "3.2.18",
28
+ "@atlaspack/diagnostic": "2.14.2",
29
+ "@atlaspack/events": "2.14.2",
30
+ "@atlaspack/feature-flags": "2.21.0",
31
+ "@atlaspack/fs": "2.15.18",
32
+ "@atlaspack/graph": "3.5.12",
33
+ "@atlaspack/logger": "2.14.15",
34
+ "@atlaspack/package-manager": "2.14.23",
35
+ "@atlaspack/plugin": "2.14.23",
36
+ "@atlaspack/profiler": "2.14.20",
37
+ "@atlaspack/rust": "3.5.0",
38
+ "@atlaspack/types": "2.15.13",
39
+ "@atlaspack/utils": "2.18.0",
40
+ "@atlaspack/workers": "2.14.23",
41
41
  "@parcel/source-map": "^2.1.1",
42
42
  "base-x": "^3.0.8",
43
43
  "browserslist": "^4.6.6",
@@ -50,16 +50,15 @@
50
50
  "semver": "^7.5.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@atlaspack/babel-register": "2.14.2-typescript-17c3d1dec.0",
53
+ "@atlaspack/babel-register": "2.14.2",
54
54
  "@types/node": ">= 18",
55
- "graphviz": "^0.0.9",
56
- "jest-diff": "*",
57
55
  "rfdc": "1",
56
+ "jest-diff": "*",
57
+ "graphviz": "^0.0.9",
58
58
  "tempy": "^0.2.1"
59
59
  },
60
60
  "browser": {
61
61
  "./src/serializerCore.js": "./src/serializerCore.browser.js"
62
62
  },
63
- "type": "commonjs",
64
- "gitHead": "17c3d1decf641e688fcfe3ca985e80e9897b7573"
63
+ "type": "commonjs"
65
64
  }
package/src/Atlaspack.ts CHANGED
@@ -199,12 +199,11 @@ export default class Atlaspack {
199
199
  fs: inputFS && new FileSystemV3(inputFS),
200
200
  defaultTargetOptions: resolvedOptions.defaultTargetOptions,
201
201
  lmdb,
202
+ featureFlags: resolvedOptions.featureFlags,
203
+ });
204
+ this.#disposable.add(() => {
205
+ rustAtlaspack.end();
202
206
  });
203
- if (featureFlags.atlaspackV3CleanShutdown) {
204
- this.#disposable.add(() => {
205
- rustAtlaspack.end();
206
- });
207
- }
208
207
  }
209
208
  // @ts-expect-error TS2454
210
209
  this.rustAtlaspack = rustAtlaspack;
@@ -1455,7 +1455,8 @@ export default class BundleGraph {
1455
1455
  ISOLATED_ENVS.has(fromEnvironmentId(bundle.env).context) ||
1456
1456
  !bundle.isSplittable ||
1457
1457
  bundle.bundleBehavior === BundleBehavior.isolated ||
1458
- bundle.bundleBehavior === BundleBehavior.inline
1458
+ bundle.bundleBehavior === BundleBehavior.inline ||
1459
+ bundle.bundleBehavior === BundleBehavior.inlineIsolated
1459
1460
  ) {
1460
1461
  return false;
1461
1462
  }
@@ -1472,6 +1473,7 @@ export default class BundleGraph {
1472
1473
  b.id !== bundle.id &&
1473
1474
  b.bundleBehavior !== BundleBehavior.isolated &&
1474
1475
  b.bundleBehavior !== BundleBehavior.inline &&
1476
+ b.bundleBehavior !== BundleBehavior.inlineIsolated &&
1475
1477
  this.bundleHasAsset(b, asset),
1476
1478
  )
1477
1479
  ) {
@@ -1490,7 +1492,8 @@ export default class BundleGraph {
1490
1492
  if (
1491
1493
  bundleNode.type !== 'bundle' ||
1492
1494
  bundleNode.value.bundleBehavior === BundleBehavior.isolated ||
1493
- bundleNode.value.bundleBehavior === BundleBehavior.inline
1495
+ bundleNode.value.bundleBehavior === BundleBehavior.inline ||
1496
+ bundleNode.value.bundleBehavior === BundleBehavior.inlineIsolated
1494
1497
  ) {
1495
1498
  return false;
1496
1499
  }
@@ -1522,6 +1525,7 @@ export default class BundleGraph {
1522
1525
  b.id !== bundle.id &&
1523
1526
  b.bundleBehavior !== BundleBehavior.isolated &&
1524
1527
  b.bundleBehavior !== BundleBehavior.inline &&
1528
+ b.bundleBehavior !== BundleBehavior.inlineIsolated &&
1525
1529
  this.bundleHasAsset(b, asset),
1526
1530
  )
1527
1531
  ) {
@@ -1664,7 +1668,8 @@ export default class BundleGraph {
1664
1668
  this.traverseBundles((bundle) => {
1665
1669
  if (
1666
1670
  opts?.includeInline ||
1667
- bundle.bundleBehavior !== BundleBehavior.inline
1671
+ (bundle.bundleBehavior !== BundleBehavior.inline &&
1672
+ bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
1668
1673
  ) {
1669
1674
  bundles.push(bundle);
1670
1675
  }
@@ -1748,7 +1753,8 @@ export default class BundleGraph {
1748
1753
  let bundle = bundleNode.value;
1749
1754
  if (
1750
1755
  opts?.includeInline ||
1751
- bundle.bundleBehavior !== BundleBehavior.inline
1756
+ (bundle.bundleBehavior !== BundleBehavior.inline &&
1757
+ bundle.bundleBehavior !== BundleBehavior.inlineIsolated)
1752
1758
  ) {
1753
1759
  bundles.add(bundle);
1754
1760
  }
@@ -1786,7 +1792,8 @@ export default class BundleGraph {
1786
1792
 
1787
1793
  if (
1788
1794
  includeInline ||
1789
- node.value.bundleBehavior !== BundleBehavior.inline
1795
+ (node.value.bundleBehavior !== BundleBehavior.inline &&
1796
+ node.value.bundleBehavior !== BundleBehavior.inlineIsolated)
1790
1797
  ) {
1791
1798
  referencedBundles.add(node.value);
1792
1799
  }
@@ -2161,7 +2168,10 @@ export default class BundleGraph {
2161
2168
  includeInline: true,
2162
2169
  });
2163
2170
  for (let referenced of referencedBundles) {
2164
- if (referenced.bundleBehavior === BundleBehavior.inline) {
2171
+ if (
2172
+ referenced.bundleBehavior === BundleBehavior.inline ||
2173
+ referenced.bundleBehavior === BundleBehavior.inlineIsolated
2174
+ ) {
2165
2175
  bundles.push(referenced);
2166
2176
  addReferencedBundles(referenced);
2167
2177
  }
@@ -2171,7 +2181,10 @@ export default class BundleGraph {
2171
2181
  addReferencedBundles(bundle);
2172
2182
 
2173
2183
  this.traverseBundles((childBundle, _, traversal) => {
2174
- if (childBundle.bundleBehavior === BundleBehavior.inline) {
2184
+ if (
2185
+ childBundle.bundleBehavior === BundleBehavior.inline ||
2186
+ childBundle.bundleBehavior === BundleBehavior.inlineIsolated
2187
+ ) {
2175
2188
  bundles.push(childBundle);
2176
2189
  } else if (childBundle.id !== bundle.id) {
2177
2190
  traversal.skipChildren();
@@ -377,7 +377,12 @@ export default class PackagerRunner {
377
377
  bundle: NamedBundle,
378
378
  map?: SourceMap | null,
379
379
  ): Async<string | null | undefined> {
380
- if (map && bundle.env.sourceMap && bundle.bundleBehavior !== 'inline') {
380
+ if (
381
+ map &&
382
+ bundle.env.sourceMap &&
383
+ bundle.bundleBehavior !== 'inline' &&
384
+ bundle.bundleBehavior !== 'inlineIsolated'
385
+ ) {
381
386
  if (bundle.env.sourceMap && bundle.env.sourceMap.inline) {
382
387
  return this.generateSourceMap(bundleToInternalBundle(bundle), map);
383
388
  } else {
@@ -427,7 +432,10 @@ export default class PackagerRunner {
427
432
  bundle: BundleType,
428
433
  bundleGraph: BundleGraphType<NamedBundleType>,
429
434
  ) => {
430
- if (bundle.bundleBehavior !== 'inline') {
435
+ if (
436
+ bundle.bundleBehavior !== 'inline' &&
437
+ bundle.bundleBehavior !== 'inlineIsolated'
438
+ ) {
431
439
  throw new Error(
432
440
  'Bundle is not inline and unable to retrieve contents',
433
441
  );
@@ -62,6 +62,7 @@ export const bundleBehaviorMap: BitFlags<BundleBehavior, number> = new BitFlags(
62
62
  {
63
63
  inline: 0,
64
64
  isolated: 1,
65
+ inlineIsolated: 2,
65
66
  },
66
67
  );
67
68
 
@@ -86,8 +86,12 @@ async function run({input, api, farm, options}) {
86
86
  includeInline: getFeatureFlag('inlineBundlesSourceMapFixes'),
87
87
  });
88
88
  const bundles = allBundles
89
- // @ts-expect-error TS7006
90
- .filter((bundle) => bundle.bundleBehavior !== 'inline')
89
+ .filter(
90
+ // @ts-expect-error TS7006
91
+ (bundle) =>
92
+ bundle.bundleBehavior !== 'inline' &&
93
+ bundle.bundleBehavior !== 'inline-isolated',
94
+ )
91
95
  // @ts-expect-error TS7006
92
96
  .filter((bundle) => {
93
97
  // Do not package and write placeholder bundles to disk. We just
@@ -101,20 +101,29 @@ export default async function resolveOptions(
101
101
  }
102
102
  }
103
103
 
104
- // getRootDir treats the input as files, so getRootDir(["/home/user/myproject"]) returns "/home/user".
105
- // Instead we need to make the the entry refer to some file inside the specified folders if entries refers to the directory.
106
- let entryRoot = getRootDir(
107
- shouldMakeEntryReferFolder ? [path.join(entries[0], 'index')] : entries,
108
- );
109
- let projectRootFile =
110
- (await resolveConfig(
111
- inputFS,
112
- path.join(entryRoot, 'index'),
113
- [...LOCK_FILE_NAMES, '.git', '.hg'],
114
- path.parse(entryRoot).root,
115
- )) || path.join(inputCwd, 'index'); // ? Should this just be rootDir
116
-
117
- let projectRoot = path.dirname(projectRootFile);
104
+ let projectRoot;
105
+ if (initialOptions.projectRoot) {
106
+ // Use explicitly provided projectRoot
107
+ if (!path.isAbsolute(initialOptions.projectRoot)) {
108
+ throw new Error('Specified project root must be an absolute path');
109
+ }
110
+ projectRoot = initialOptions.projectRoot;
111
+ } else {
112
+ // getRootDir treats the input as files, so getRootDir(["/home/user/myproject"]) returns "/home/user".
113
+ // Instead we need to make the the entry refer to some file inside the specified folders if entries refers to the directory.
114
+ let entryRoot = getRootDir(
115
+ shouldMakeEntryReferFolder ? [path.join(entries[0], 'index')] : entries,
116
+ );
117
+ let projectRootFile =
118
+ (await resolveConfig(
119
+ inputFS,
120
+ path.join(entryRoot, 'index'),
121
+ [...LOCK_FILE_NAMES, '.git', '.hg'],
122
+ path.parse(entryRoot).root,
123
+ )) || path.join(inputCwd, 'index'); // ? Should this just be rootDir
124
+
125
+ projectRoot = path.dirname(projectRootFile);
126
+ }
118
127
 
119
128
  const gitRoot = await findGitRepositoryRoot(inputFS, projectRoot);
120
129
  if (inputFS instanceof NodeVCSAwareFS) {
package/src/types.ts CHANGED
@@ -179,6 +179,7 @@ export type Dependency = {
179
179
  export const BundleBehavior = {
180
180
  inline: 0,
181
181
  isolated: 1,
182
+ inlineIsolated: 2,
182
183
  } as const;
183
184
 
184
185
  // @ts-expect-error TS2322
package/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- http://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright (c) 2024 Atlassian US., Inc.
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- http://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.