@marko/compiler 5.39.58 → 5.39.59

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/dist/index.js CHANGED
@@ -19,6 +19,11 @@ var _shouldOptimize = _interopRequireDefault(require("./util/should-optimize"));
19
19
  var _tryLoadTranslator = _interopRequireDefault(require("./util/try-load-translator"));function _interopRequireWildcard(e, t) {if ("function" == typeof WeakMap) var r = new WeakMap(),n = new WeakMap();return (_interopRequireWildcard = function (e, t) {if (!t && e && e.__esModule) return e;var o,i,f = { __proto__: null, default: e };if (null === e || "object" != typeof e && "function" != typeof e) return f;if (o = t ? n : r) {if (o.has(e)) return o.get(e);o.set(e, f);}for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]);return f;})(e, t);}function _interopRequireDefault(e) {return e && e.__esModule ? e : { default: e };}
20
20
 
21
21
 
22
+ const hasBabel = !!(
23
+ _modules.default.pkg && (
24
+ _modules.default.pkg.dependencies?.["@babel/core"] ||
25
+ _modules.default.pkg.devDependencies?.["@babel/core"]));
26
+
22
27
  let globalConfig = exports.globalConfig = { ..._config.default };
23
28
  function configure(newConfig) {
24
29
  exports.globalConfig = globalConfig = { ..._config.default, ...newConfig };
@@ -76,20 +81,29 @@ function loadMarkoConfig(config) {
76
81
 
77
82
  async function loadBabelConfig(filename, config) {
78
83
  const baseBabelConfig = getBaseBabelConfig(filename, config);
79
- return isTranslatedOutput(config.output) ?
84
+ return shouldResolveBabelConfig(config) ?
80
85
  (await (0, _babel.loadPartialConfigAsync)(baseBabelConfig)).options :
81
86
  baseBabelConfig;
82
87
  }
83
88
 
84
89
  function loadBabelConfigSync(filename, config) {
85
90
  const baseBabelConfig = getBaseBabelConfig(filename, config);
86
- return isTranslatedOutput(config.output) ?
91
+ return shouldResolveBabelConfig(config) ?
87
92
  (0, _babel.loadPartialConfig)(baseBabelConfig).options :
88
93
  baseBabelConfig;
89
94
  }
90
95
 
96
+ function shouldResolveBabelConfig(config) {
97
+ return !!(
98
+ config.babelrc ||
99
+ config.configFile ||
100
+ config.browserslistConfigFile);
101
+
102
+ }
103
+
91
104
  function getBaseBabelConfig(filename, { babelConfig, ...markoConfig }) {
92
105
  const isTranslated = isTranslatedOutput(markoConfig.output);
106
+ const loadConfig = isTranslated && hasBabel;
93
107
  const requiredPlugins = [[_babelPlugin.default, markoConfig]];
94
108
  const baseBabelConfig = {
95
109
  filenameRelative: filename ?
@@ -97,8 +111,9 @@ function getBaseBabelConfig(filename, { babelConfig, ...markoConfig }) {
97
111
  undefined,
98
112
  sourceRoot: filename ? _path.default.dirname(filename) : undefined,
99
113
  sourceFileName: filename ? _path.default.basename(filename) : undefined,
100
- configFile: isTranslated,
101
- babelrc: isTranslated,
114
+ babelrc: loadConfig,
115
+ configFile: loadConfig,
116
+ browserslistConfigFile: loadConfig,
102
117
  ...babelConfig,
103
118
  filename,
104
119
  sourceType: "module",
@@ -8,9 +8,9 @@ exports.readFileSync = function (path) {
8
8
  try {
9
9
  var taglibProps = JSON.parse(stripJsonComments(json));
10
10
  return taglibProps;
11
- } catch (e) {
12
- throw new Error(
13
- 'Unable to parse JSON file at path "' + path + '". Error: ' + e
14
- );
11
+ } catch (cause) {
12
+ throw new Error('Unable to parse JSON file at path "' + path + '".', {
13
+ cause
14
+ });
15
15
  }
16
16
  };
@@ -337,6 +337,7 @@ class TagLoader {
337
337
  taglibConfig.fs.statSync(path);
338
338
  tag.template = path;
339
339
  } catch (_) {
340
+ // eslint-disable-next-line preserve-caught-error
340
341
  throw new Error('Template at path "' + path + '" does not exist.');
341
342
  }
342
343
  }
@@ -91,16 +91,15 @@ class TaglibLoader {
91
91
 
92
92
  _handleTag(tagName, value, dependencyChain) {
93
93
  var tagProps;
94
- var tagFilePath = this.filePath;
95
-
96
94
  var tag;
97
95
 
98
96
  if (typeof value === "string") {
99
- tagFilePath = nodePath.resolve(this.dirname, value);
97
+ var tagFilePath = nodePath.resolve(this.dirname, value);
100
98
 
101
99
  try {
102
100
  taglibFS.fs.statSync(tagFilePath);
103
101
  } catch (_) {
102
+ // eslint-disable-next-line preserve-caught-error
104
103
  throw new Error(
105
104
  'Tag at path "' +
106
105
  tagFilePath +
@@ -141,7 +141,7 @@ dependencyChain)
141
141
  }
142
142
 
143
143
  let tagName;
144
- let tagDef = null;
144
+ let tagDef;
145
145
  let tagDirname;
146
146
  let tagJsonPath;
147
147
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/compiler",
3
- "version": "5.39.58",
3
+ "version": "5.39.59",
4
4
  "description": "Marko template to JS compiler.",
5
5
  "keywords": [
6
6
  "babel",
@@ -82,7 +82,7 @@
82
82
  "source-map-support": "^0.5.21"
83
83
  },
84
84
  "devDependencies": {
85
- "marko": "^5.38.27"
85
+ "marko": "^5.38.28"
86
86
  },
87
87
  "engines": {
88
88
  "node": "18 || 20 || >=22"