@marko/translator-default 5.25.8 → 5.26.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,18 @@
1
1
  "use strict";var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");exports.__esModule = true;exports.default = void 0;var _compiler = require("@marko/compiler");
2
- var _withPreviousLocation = _interopRequireDefault(require("../../util/with-previous-location"));var _default =
2
+ var _withPreviousLocation = _interopRequireDefault(require("../../util/with-previous-location"));
3
+ var _babelUtils = require("@marko/babel-utils");var _default =
3
4
 
4
5
  {
5
6
  ReferencedIdentifier(path) {
6
7
  if (path.node.name === "data" && !path.scope.hasBinding("data")) {
7
- path.replaceWith((0, _withPreviousLocation.default)(_compiler.types.identifier("input"), path.node));
8
+ (0, _babelUtils.diagnosticDeprecate)(path, {
9
+ label: "The 'data' variable is deprecated. Use 'input' instead.",
10
+ fix() {
11
+ path.replaceWith(
12
+ (0, _withPreviousLocation.default)(_compiler.types.identifier("input"), path.node));
13
+
14
+ }
15
+ });
8
16
  }
9
17
  }
10
18
  };exports.default = _default;
@@ -12,12 +12,11 @@ function getComponentFiles({ hub: { file } }) {
12
12
 
13
13
  const { filename } = file.opts;
14
14
  const fs = file.markoOpts.fileSystem;
15
- const ext = _path.default.extname(filename);
16
15
  const dirname = _path.default.dirname(filename);
17
16
  const dirFiles = fs.readdirSync(dirname).sort();
18
- const nameNoExt = _path.default.basename(filename, ext);
19
- const isEntry = "index" === nameNoExt;
20
- const fileMatch = `(${(0, _escapeStringRegexp.default)(nameNoExt)}\\.${isEntry ? "|" : ""})`;
17
+ const base = getBase(filename);
18
+ const isEntry = "index" === base;
19
+ const fileMatch = `(${(0, _escapeStringRegexp.default)(base)}\\.${isEntry ? "|" : ""})`;
21
20
  const styleMatch = new RegExp(`^${fileMatch}style\\.\\w+$`);
22
21
  const componentMatch = new RegExp(`^${fileMatch}component\\.\\w+$`);
23
22
  const splitComponentMatch = new RegExp(
@@ -49,4 +48,38 @@ function getComponentFiles({ hub: { file } }) {
49
48
  componentFile,
50
49
  componentBrowserFile
51
50
  };
51
+ }
52
+
53
+ /**
54
+ * Given a filename, gets the base name, strips off the file extension
55
+ * and removes any arc flags (https://github.com/eBay/arc).
56
+ *
57
+ * @example
58
+ * getBase("/dir/foo.marko") // => "foo"
59
+ * getBase("/dir/foo.bar.marko") // => "foo.bar"
60
+ * getBase("/dir/foo[bar].marko") // => "foo"
61
+ * getBase("/dir/foo[bar].baz.marko") // => "foo.baz"
62
+ */
63
+ function getBase(filename) {
64
+ const start = filename.lastIndexOf(_path.default.sep) + 1;
65
+ const leftDot = filename.indexOf(".", start);
66
+
67
+ if (leftDot === -1) {
68
+ return filename.slice(start);
69
+ }
70
+
71
+ const rightDot = filename.lastIndexOf(".");
72
+ const closeBracket = leftDot - 1;
73
+ if (filename[closeBracket] === "]") {
74
+ const openBracket = filename.lastIndexOf("[", closeBracket);
75
+ if (openBracket > start) {
76
+ // If we match a "]" before the extension and find a "[" before that,
77
+ // then we have an arc flag. Strip it off.
78
+ return (
79
+ filename.slice(start, openBracket) + filename.slice(leftDot, rightDot));
80
+
81
+ }
82
+ }
83
+
84
+ return filename.slice(start, rightDot);
52
85
  }
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@marko/translator-default",
3
3
  "description": "Translates Marko templates to the default Marko runtime.",
4
- "version": "5.25.8",
4
+ "version": "5.26.0",
5
5
  "author": "Dylan Piercey <dpiercey@ebay.com>",
6
6
  "bugs": "https://github.com/marko-js/marko/issues/new?template=Bug_report.md",
7
7
  "dependencies": {
8
8
  "@babel/runtime": "^7.16.0",
9
- "@marko/babel-utils": "^5.21.4",
9
+ "@marko/babel-utils": "^5.22.0",
10
10
  "escape-string-regexp": "^4.0.0",
11
11
  "magic-string": "^0.27.0",
12
12
  "self-closing-tags": "^1.0.1"
13
13
  },
14
14
  "devDependencies": {
15
- "@marko/compiler": "^5.27.8",
16
- "marko": "^5.25.12"
15
+ "@marko/compiler": "^5.28.0",
16
+ "marko": "^5.26.0"
17
17
  },
18
18
  "files": [
19
19
  "dist",