@marko/compiler 5.33.2 → 5.33.4

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.
Files changed (2) hide show
  1. package/dist/index.js +17 -5
  2. package/package.json +2 -2
package/dist/index.js CHANGED
@@ -23,7 +23,7 @@ function configure(newConfig) {
23
23
 
24
24
  async function compile(src, filename, config) {
25
25
  const markoConfig = loadMarkoConfig(config);
26
- const babelConfig = loadBabelConfig(filename, markoConfig);
26
+ const babelConfig = await loadBabelConfig(filename, markoConfig);
27
27
  const babelResult = await babel.transformAsync(src, babelConfig);
28
28
  scheduleDefaultClear(markoConfig);
29
29
  return buildResult(src, filename, markoConfig.errorRecovery, babelResult);
@@ -31,7 +31,7 @@ async function compile(src, filename, config) {
31
31
 
32
32
  function compileSync(src, filename, config) {
33
33
  const markoConfig = loadMarkoConfig(config);
34
- const babelConfig = loadBabelConfig(filename, markoConfig);
34
+ const babelConfig = loadBabelConfigSync(filename, markoConfig);
35
35
  const babelResult = babel.transformSync(src, babelConfig);
36
36
  scheduleDefaultClear(markoConfig);
37
37
  return buildResult(src, filename, markoConfig.errorRecovery, babelResult);
@@ -73,7 +73,21 @@ function loadMarkoConfig(config) {
73
73
  return markoConfig;
74
74
  }
75
75
 
76
- function loadBabelConfig(filename, { babelConfig, ...markoConfig }) {
76
+ async function loadBabelConfig(filename, config) {
77
+ const baseBabelConfig = getBaseBabelConfig(filename, config);
78
+ return isTranslatedOutput(config.output) ?
79
+ (await babel.loadPartialConfigAsync(baseBabelConfig)).options :
80
+ baseBabelConfig;
81
+ }
82
+
83
+ function loadBabelConfigSync(filename, config) {
84
+ const baseBabelConfig = getBaseBabelConfig(filename, config);
85
+ return isTranslatedOutput(config.output) ?
86
+ babel.loadPartialConfigSync(baseBabelConfig).options :
87
+ baseBabelConfig;
88
+ }
89
+
90
+ function getBaseBabelConfig(filename, { babelConfig, ...markoConfig }) {
77
91
  const isTranslated = isTranslatedOutput(markoConfig.output);
78
92
  const requiredPlugins = [
79
93
  [_babelPlugin.default, markoConfig],
@@ -111,8 +125,6 @@ function loadBabelConfig(filename, { babelConfig, ...markoConfig }) {
111
125
  if (markoConfig.modules === "cjs") {
112
126
  baseBabelConfig.plugins.push([_pluginTransformModulesCommonjs.default, { loose: true }]);
113
127
  }
114
-
115
- return babel.loadPartialConfig(baseBabelConfig).options;
116
128
  }
117
129
 
118
130
  return baseBabelConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marko/compiler",
3
- "version": "5.33.2",
3
+ "version": "5.33.4",
4
4
  "description": "Marko template to JS compiler.",
5
5
  "keywords": [
6
6
  "babel",
@@ -61,7 +61,7 @@
61
61
  "strip-json-comments": "^3.1.1"
62
62
  },
63
63
  "devDependencies": {
64
- "@marko/translator-default": "^5.31.3"
64
+ "@marko/translator-default": "^5.31.4"
65
65
  },
66
66
  "publishConfig": {
67
67
  "access": "public"