@marko/translator-default 5.30.0 → 5.31.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,37 @@
1
1
  "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = void 0;var _compiler = require("@marko/compiler");
2
2
  var _withPreviousLocation = _interopRequireDefault(require("../../util/with-previous-location"));
3
- var _babelUtils = require("@marko/babel-utils");var _default =
3
+ var _babelUtils = require("@marko/babel-utils");
4
+ const kHadAssignment = Symbol();var _default =
4
5
 
5
6
  {
6
- ReferencedIdentifier(path) {
7
- if (path.node.name === "data" && !path.scope.hasBinding("data")) {
7
+ AssignmentExpression(path, state) {
8
+ if (
9
+ !state[kHadAssignment] &&
10
+ path.node.left.type === "Identifier" &&
11
+ path.node.left.name === "data")
12
+ {
13
+ state[kHadAssignment] = true;
14
+
15
+ let root = path.parentPath;
16
+ while (root.parentPath.type !== "Program") {
17
+ root = root.parentPath;
18
+ }
19
+
20
+ root.insertBefore(
21
+ _compiler.types.markoScriptlet([
22
+ _compiler.types.variableDeclaration("var", [
23
+ _compiler.types.variableDeclarator(_compiler.types.identifier("data"))])]));
24
+
25
+
26
+
27
+ }
28
+ },
29
+ ReferencedIdentifier(path, state) {
30
+ if (
31
+ !state[kHadAssignment] &&
32
+ path.node.name === "data" &&
33
+ !path.scope.hasBinding("data"))
34
+ {
8
35
  (0, _babelUtils.diagnosticDeprecate)(path, {
9
36
  label: "The 'data' variable is deprecated. Use 'input' instead.",
10
37
  fix() {
@@ -9,7 +9,7 @@ var _babelUtils = require("@marko/babel-utils");var _default =
9
9
 
10
10
 
11
11
  (entryFile, isHydrate) => {
12
- const { resolveVirtualDependency, hydrateIncludeImports } =
12
+ const { resolveVirtualDependency, hydrateIncludeImports, hydrateInit } =
13
13
  entryFile.markoOpts;
14
14
  const hydratedFiles = new Set();
15
15
  const program = entryFile.path;
@@ -39,19 +39,26 @@ var _babelUtils = require("@marko/babel-utils");var _default =
39
39
  _compiler.types.importSpecifier(_compiler.types.identifier("register"), _compiler.types.identifier("register")));
40
40
 
41
41
  }
42
- markoComponentsImport.specifiers.push(_compiler.types.importSpecifier(initId, initId));
42
+
43
+ if (hydrateInit) {
44
+ markoComponentsImport.specifiers.push(_compiler.types.importSpecifier(initId, initId));
45
+ }
46
+
43
47
  program.unshiftContainer("body", markoComponentsImport);
44
- program.pushContainer(
45
- "body",
46
- _compiler.types.expressionStatement(
47
- _compiler.types.callExpression(
48
- initId,
49
- entryFile.markoOpts.runtimeId ?
50
- [_compiler.types.stringLiteral(entryFile.markoOpts.runtimeId)] :
51
- [])));
48
+
49
+ if (hydrateInit) {
50
+ program.pushContainer(
51
+ "body",
52
+ _compiler.types.expressionStatement(
53
+ _compiler.types.callExpression(
54
+ initId,
55
+ entryFile.markoOpts.runtimeId ?
56
+ [_compiler.types.stringLiteral(entryFile.markoOpts.runtimeId)] :
57
+ [])));
52
58
 
53
59
 
54
60
 
61
+ }
55
62
  }
56
63
 
57
64
  function addHydrateDeps(file) {
@@ -159,6 +166,10 @@ var _babelUtils = require("@marko/babel-utils");var _default =
159
166
  code,
160
167
  virtualPath
161
168
  });
169
+
170
+ if (!dep) {
171
+ continue;
172
+ }
162
173
  } else if (dep.startsWith("package:")) {
163
174
  continue;
164
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/translator-default",
3
- "version": "5.30.0",
3
+ "version": "5.31.0",
4
4
  "description": "Translates Marko templates to the default Marko runtime.",
5
5
  "keywords": [
6
6
  "babel",
@@ -29,14 +29,14 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@babel/runtime": "^7.16.0",
32
- "@marko/babel-utils": "^6.3.0",
32
+ "@marko/babel-utils": "^6.3.1",
33
33
  "escape-string-regexp": "^4.0.0",
34
34
  "magic-string": "^0.27.0",
35
35
  "self-closing-tags": "^1.0.1"
36
36
  },
37
37
  "devDependencies": {
38
- "@marko/compiler": "^5.32.0",
39
- "marko": "^5.30.0"
38
+ "@marko/compiler": "^5.33.0",
39
+ "marko": "^5.31.0"
40
40
  },
41
41
  "peerDependencies": {
42
42
  "@marko/compiler": "^5.16.1",