@atlaspack/optimizer-inline-requires 2.12.1-dev.3367 → 2.12.1-dev.3398

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.
@@ -37,7 +37,7 @@ class RequireInliningVisitor extends _Visitor().Visitor {
37
37
  visitFunctionExpression(n) {
38
38
  // This visitor tries to find module definition functions, these are of the form:
39
39
  //
40
- // atlaspackRequire.register("moduleId", function (require, module, exports) { ... });
40
+ // parcelRequire.register("moduleId", function (require, module, exports) { ... });
41
41
  //
42
42
  // We do this to set the vistior variable `inModuleDefinition` for subsequent visits,
43
43
  // and also reset the module variable tracking data structures.
@@ -70,8 +70,8 @@ class RequireInliningVisitor extends _Visitor().Visitor {
70
70
  if (!init || init.type !== 'CallExpression') {
71
71
  continue;
72
72
  }
73
- if ((init.callee.type === 'Identifier' && init.callee.value === 'require' || init.callee.value === 'atlaspackRequire') && decl.id.value !== 'atlaspackHelpers' &&
74
- // ignore var atlaspackHelpers = require("@atlaspack/transformer-js/src/esmodule-helpers.js");
73
+ if ((init.callee.type === 'Identifier' && init.callee.value === 'require' || init.callee.value === 'parcelRequire') && decl.id.value !== 'parcelHelpers' &&
74
+ // ignore var parcelHelpers = require("@atlaspack/transformer-js/src/esmodule-helpers.js");
75
75
  init.arguments[0].expression.type === 'StringLiteral' && typeof decl.id.value === 'string' && decl.id.value.startsWith('$')) {
76
76
  const variable = decl.id.value;
77
77
  const assetPublicId = variable.substring(1);
@@ -104,7 +104,7 @@ class RequireInliningVisitor extends _Visitor().Visitor {
104
104
  // Handle modules with default values, these look like this in the source:
105
105
  // ```
106
106
  // var _app = require("./App");
107
- // var _appDefault = atlaspackHelpers.interopDefault(_app);
107
+ // var _appDefault = parcelHelpers.interopDefault(_app);
108
108
  // ```
109
109
  //
110
110
  // In this case we want to also put `_appDefault` into the `moduleVariableMap` with the initializer node,
@@ -115,7 +115,7 @@ class RequireInliningVisitor extends _Visitor().Visitor {
115
115
  // var _appDefault = null;
116
116
  // ```
117
117
  //
118
- // .. and where `_appDefault` is used we replace that with `atlaspackHelpers.interopDefault(require('./App'))`
118
+ // .. and where `_appDefault` is used we replace that with `parcelHelpers.interopDefault(require('./App'))`
119
119
  const variable = decl.id.value;
120
120
  const baseId = variable.substring(0, decl.id.value.length - 'Default'.length);
121
121
  if (!this.moduleVariables.has(baseId)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/optimizer-inline-requires",
3
- "version": "2.12.1-dev.3367+07fefed65",
3
+ "version": "2.12.1-dev.3398+81c73b3cd",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -13,14 +13,14 @@
13
13
  "source": "src/InlineRequires.js",
14
14
  "engines": {
15
15
  "node": ">= 14.0.0",
16
- "atlaspack": "^2.12.1-dev.3367+07fefed65"
16
+ "parcel": "^2.12.1-dev.3398+81c73b3cd"
17
17
  },
18
18
  "dependencies": {
19
- "@atlaspack/plugin": "2.12.1-dev.3367+07fefed65",
20
- "@atlaspack/types": "2.12.1-dev.3367+07fefed65",
19
+ "@atlaspack/plugin": "2.12.1-dev.3398+81c73b3cd",
20
+ "@atlaspack/types": "2.12.1-dev.3398+81c73b3cd",
21
21
  "@parcel/source-map": "^2.1.1",
22
22
  "@swc/core": "^1.3.36",
23
23
  "nullthrows": "^1.1.1"
24
24
  },
25
- "gitHead": "07fefed65a9a4d7bd0bdc9c45b39704ee4ca70dd"
25
+ "gitHead": "81c73b3cdf93adf8b0013be9fed5422579bd5910"
26
26
  }
@@ -41,7 +41,7 @@ export class RequireInliningVisitor extends Visitor {
41
41
  visitFunctionExpression(n: FunctionExpression): FunctionExpression {
42
42
  // This visitor tries to find module definition functions, these are of the form:
43
43
  //
44
- // atlaspackRequire.register("moduleId", function (require, module, exports) { ... });
44
+ // parcelRequire.register("moduleId", function (require, module, exports) { ... });
45
45
  //
46
46
  // We do this to set the vistior variable `inModuleDefinition` for subsequent visits,
47
47
  // and also reset the module variable tracking data structures.
@@ -87,8 +87,8 @@ export class RequireInliningVisitor extends Visitor {
87
87
  if (
88
88
  ((init.callee.type === 'Identifier' &&
89
89
  init.callee.value === 'require') ||
90
- init.callee.value === 'atlaspackRequire') &&
91
- decl.id.value !== 'atlaspackHelpers' && // ignore var atlaspackHelpers = require("@atlaspack/transformer-js/src/esmodule-helpers.js");
90
+ init.callee.value === 'parcelRequire') &&
91
+ decl.id.value !== 'parcelHelpers' && // ignore var parcelHelpers = require("@atlaspack/transformer-js/src/esmodule-helpers.js");
92
92
  init.arguments[0].expression.type === 'StringLiteral' &&
93
93
  typeof decl.id.value === 'string' &&
94
94
  decl.id.value.startsWith('$')
@@ -132,7 +132,7 @@ export class RequireInliningVisitor extends Visitor {
132
132
  // Handle modules with default values, these look like this in the source:
133
133
  // ```
134
134
  // var _app = require("./App");
135
- // var _appDefault = atlaspackHelpers.interopDefault(_app);
135
+ // var _appDefault = parcelHelpers.interopDefault(_app);
136
136
  // ```
137
137
  //
138
138
  // In this case we want to also put `_appDefault` into the `moduleVariableMap` with the initializer node,
@@ -143,7 +143,7 @@ export class RequireInliningVisitor extends Visitor {
143
143
  // var _appDefault = null;
144
144
  // ```
145
145
  //
146
- // .. and where `_appDefault` is used we replace that with `atlaspackHelpers.interopDefault(require('./App'))`
146
+ // .. and where `_appDefault` is used we replace that with `parcelHelpers.interopDefault(require('./App'))`
147
147
  const variable = decl.id.value;
148
148
  const baseId = variable.substring(
149
149
  0,
@@ -54,13 +54,13 @@ describe('InliningVisitor', () => {
54
54
  it('performs module default inlining', async () => {
55
55
  const src = getModule(
56
56
  `var $abc123 = require('abc123');
57
- var $abc123Default = atlaspackHelpers.interopDefault($abc123);
57
+ var $abc123Default = parcelHelpers.interopDefault($abc123);
58
58
  console.log($abc123Default.foo());`,
59
59
  );
60
60
  const expected = getModule(
61
61
  `var $abc123;
62
62
  var $abc123Default;
63
- console.log((0, atlaspackHelpers.interopDefault(require('abc123'))).foo());`,
63
+ console.log((0, parcelHelpers.interopDefault(require('abc123'))).foo());`,
64
64
  );
65
65
  const result = await testRequireInliningVisitor(src, []);
66
66
  assertEqualCode(result, expected);