@marko/language-tools 2.1.2 → 2.1.3

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
@@ -3075,31 +3075,43 @@ function getMeta(dir) {
3075
3075
  }
3076
3076
  return defaultMeta;
3077
3077
  }
3078
+ if (defaultMeta) {
3079
+ try {
3080
+ return loadMeta(dir);
3081
+ } catch {
3082
+ metaByDir.set(dir, defaultMeta);
3083
+ return defaultMeta;
3084
+ }
3085
+ }
3086
+ return loadMeta(dir);
3087
+ }
3088
+ function loadMeta(dir) {
3078
3089
  let cached = metaByDir.get(dir);
3079
3090
  if (!cached) {
3091
+ let require2 = (0, import_module.createRequire)(dir);
3092
+ let configPath;
3080
3093
  try {
3081
- const require2 = (0, import_module.createRequire)(dir);
3082
- const configPath = require2.resolve("@marko/compiler/config");
3083
- cached = metaByCompiler.get(configPath);
3084
- if (!cached) {
3085
- const compiler = require2(import_path2.default.join(
3086
- configPath,
3087
- ".."
3088
- ));
3089
- const config = interopDefault(require2(configPath));
3090
- cached = {
3091
- compiler,
3092
- config: {
3093
- ...config,
3094
- cache: /* @__PURE__ */ new Map(),
3095
- translator: require2(config.translator)
3096
- }
3097
- };
3098
- compiler.configure(cached.config);
3099
- metaByCompiler.set(configPath, cached);
3100
- }
3101
- } catch (err) {
3102
- cached = getMeta();
3094
+ configPath = require2.resolve("@marko/compiler/config");
3095
+ } catch {
3096
+ require2 = (0, import_module.createRequire)(
3097
+ import_path2.default.dirname(require2.resolve("marko/package.json"))
3098
+ );
3099
+ configPath = require2.resolve("@marko/compiler/config");
3100
+ }
3101
+ cached = metaByCompiler.get(configPath);
3102
+ if (!cached) {
3103
+ const compiler = require2(import_path2.default.dirname(configPath));
3104
+ const config = interopDefault(require2(configPath));
3105
+ cached = {
3106
+ compiler,
3107
+ config: {
3108
+ ...config,
3109
+ cache: /* @__PURE__ */ new Map(),
3110
+ translator: require2(config.translator)
3111
+ }
3112
+ };
3113
+ compiler.configure(cached.config);
3114
+ metaByCompiler.set(configPath, cached);
3103
3115
  }
3104
3116
  metaByDir.set(dir, cached);
3105
3117
  }
package/dist/index.mjs CHANGED
@@ -3043,31 +3043,43 @@ function getMeta(dir) {
3043
3043
  }
3044
3044
  return defaultMeta;
3045
3045
  }
3046
+ if (defaultMeta) {
3047
+ try {
3048
+ return loadMeta(dir);
3049
+ } catch {
3050
+ metaByDir.set(dir, defaultMeta);
3051
+ return defaultMeta;
3052
+ }
3053
+ }
3054
+ return loadMeta(dir);
3055
+ }
3056
+ function loadMeta(dir) {
3046
3057
  let cached = metaByDir.get(dir);
3047
3058
  if (!cached) {
3059
+ let require2 = createRequire(dir);
3060
+ let configPath;
3048
3061
  try {
3049
- const require2 = createRequire(dir);
3050
- const configPath = require2.resolve("@marko/compiler/config");
3051
- cached = metaByCompiler.get(configPath);
3052
- if (!cached) {
3053
- const compiler = require2(path2.join(
3054
- configPath,
3055
- ".."
3056
- ));
3057
- const config = interopDefault(require2(configPath));
3058
- cached = {
3059
- compiler,
3060
- config: {
3061
- ...config,
3062
- cache: /* @__PURE__ */ new Map(),
3063
- translator: require2(config.translator)
3064
- }
3065
- };
3066
- compiler.configure(cached.config);
3067
- metaByCompiler.set(configPath, cached);
3068
- }
3069
- } catch (err) {
3070
- cached = getMeta();
3062
+ configPath = require2.resolve("@marko/compiler/config");
3063
+ } catch {
3064
+ require2 = createRequire(
3065
+ path2.dirname(require2.resolve("marko/package.json"))
3066
+ );
3067
+ configPath = require2.resolve("@marko/compiler/config");
3068
+ }
3069
+ cached = metaByCompiler.get(configPath);
3070
+ if (!cached) {
3071
+ const compiler = require2(path2.dirname(configPath));
3072
+ const config = interopDefault(require2(configPath));
3073
+ cached = {
3074
+ compiler,
3075
+ config: {
3076
+ ...config,
3077
+ cache: /* @__PURE__ */ new Map(),
3078
+ translator: require2(config.translator)
3079
+ }
3080
+ };
3081
+ compiler.configure(cached.config);
3082
+ metaByCompiler.set(configPath, cached);
3071
3083
  }
3072
3084
  metaByDir.set(dir, cached);
3073
3085
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@marko/language-tools",
3
3
  "description": "Marko Language Tools",
4
- "version": "2.1.2",
4
+ "version": "2.1.3",
5
5
  "bugs": "https://github.com/marko-js/language-server/issues/new?template=Bug_report.md",
6
6
  "peerDependencies": {
7
7
  "@marko/compiler": "^5.28.4"