@marko/translator-default 5.25.8 → 5.25.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,7 +1,7 @@
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.25.9",
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": {
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "devDependencies": {
15
15
  "@marko/compiler": "^5.27.8",
16
- "marko": "^5.25.12"
16
+ "marko": "^5.25.17"
17
17
  },
18
18
  "files": [
19
19
  "dist",