nuxt-monaco-editor 1.3.0 → 1.3.1-0

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/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.3.1-0](https://github.com/e-chan1007/nuxt-monaco-editor/compare/v1.3.0...v1.3.1-0) (2024-10-19)
6
+
7
+
8
+ ### Features
9
+
10
+ * add `removeSourceMaps` option ([9c94fbb](https://github.com/e-chan1007/nuxt-monaco-editor/commit/9c94fbbf8d33ced7c89e2d3e739a11bc4a991d5c))
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * load `nls.js` insted of `nls.mjs` ([4b9d0a7](https://github.com/e-chan1007/nuxt-monaco-editor/commit/4b9d0a7f213f85c7fba1afbb6dbddeaf6a7fa9a4))
16
+
5
17
  ## [1.3.0](https://github.com/e-chan1007/nuxt-monaco-editor/compare/v1.2.9...v1.3.0) (2024-10-19)
6
18
 
7
19
 
package/dist/module.d.mts CHANGED
@@ -3,6 +3,7 @@ import * as _nuxt_schema from '@nuxt/schema';
3
3
  type MonacoEditorLocale = 'cs' | 'de' | 'es' | 'fr' | 'it' | 'ja' | 'ko' | 'pl' | 'pt-br' | 'qps-ploc' | 'ru' | 'tr' | 'zh-hans' | 'zh-hant' | 'en';
4
4
  interface ModuleOptions {
5
5
  locale?: MonacoEditorLocale;
6
+ removeSourceMaps?: boolean;
6
7
  componentName?: {
7
8
  codeEditor?: string;
8
9
  diffEditor?: string;
package/dist/module.d.ts CHANGED
@@ -3,6 +3,7 @@ import * as _nuxt_schema from '@nuxt/schema';
3
3
  type MonacoEditorLocale = 'cs' | 'de' | 'es' | 'fr' | 'it' | 'ja' | 'ko' | 'pl' | 'pt-br' | 'qps-ploc' | 'ru' | 'tr' | 'zh-hans' | 'zh-hant' | 'en';
4
4
  interface ModuleOptions {
5
5
  locale?: MonacoEditorLocale;
6
+ removeSourceMaps?: boolean;
6
7
  componentName?: {
7
8
  codeEditor?: string;
8
9
  diffEditor?: string;
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.1.0"
6
6
  },
7
- "version": "1.3.0",
7
+ "version": "1.3.1-0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "0.8.4",
10
10
  "unbuild": "2.0.0"
package/dist/module.mjs CHANGED
@@ -16,7 +16,7 @@ const require = __cjs_mod__.createRequire(import.meta.url);
16
16
  const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
17
17
  const { resolve } = createResolver(runtimeDir);
18
18
  const rewrittenMonacoFiles = /* @__PURE__ */ new Map();
19
- const nlsPath = resolve("nls.mjs");
19
+ const nlsPath = resolve("nls.js");
20
20
  const { resolve: resolveModule } = createRequire(import.meta.url);
21
21
  const plugin = (options, nuxtOptions) => ({
22
22
  name: "vite-plugin-nuxt-monaco-editor",
@@ -36,13 +36,16 @@ const plugin = (options, nuxtOptions) => ({
36
36
  return { code: rewrittenMonacoFiles.get(id) };
37
37
  }
38
38
  if (/\/(vscode-)?nls\.m?js/.test(id)) {
39
- const code = (await fs.readFile(resolve("nls.mjs"), "utf-8")).replace("__LOCALE_DATA_PATH__", `nuxt-monaco-editor/dist/i18n/${options.locale}.json`).replace("__LOCALE__", options.locale);
39
+ const code = (await fs.readFile(nlsPath, "utf-8")).replace("__LOCALE_DATA_PATH__", `nuxt-monaco-editor/dist/i18n/${options.locale}.json`).replace("__LOCALE__", options.locale);
40
40
  rewrittenMonacoFiles.set(id, code);
41
41
  return { code };
42
42
  }
43
43
  if (vsPath && id.endsWith(".js")) {
44
44
  const path = vsPath.replace(/\.js$/, "");
45
45
  let code = (await fs.readFile(id, "utf-8")).replace(/import \* as nls from '.+nls\.js(\?v=.+)?';/g, `import * as nls from '${nlsPath}';`).replace(/(?<!function )localize\(/g, `localize('${path}', `);
46
+ if (options.removeSourceMaps) {
47
+ code = code.replace(/\/\/# sourceMappingURL=.+\.js\.map/g, "");
48
+ }
46
49
  if (path === "vs/base/common/platform") {
47
50
  code = code.replace("let _isWeb = false;", "let _isWeb = true;");
48
51
  }
@@ -51,21 +54,29 @@ const plugin = (options, nuxtOptions) => ({
51
54
  }
52
55
  return;
53
56
  }
54
- if (vsPath === "vs/base/common/platform.js") {
57
+ if (vsPath && id.endsWith(".js")) {
55
58
  let code = await fs.readFile(id, "utf-8");
56
- code = code.replace("let _isWeb = false;", "let _isWeb = true;");
59
+ if (options.removeSourceMaps) {
60
+ code = code.replace(/\/\/# sourceMappingURL=.+\.js\.map/g, "");
61
+ }
62
+ if (vsPath === "vs/base/common/platform.js") {
63
+ code = code.replace("let _isWeb = false;", "let _isWeb = true;");
64
+ }
57
65
  rewrittenMonacoFiles.set(id, code);
58
66
  return { code };
59
67
  }
60
68
  }
61
69
  });
62
70
 
63
- const DEFAULTS = {
64
- locale: "en",
65
- componentName: {
66
- codeEditor: "MonacoEditor",
67
- diffEditor: "MonacoDiffEditor"
68
- }
71
+ const getDefaults = (nuxt) => {
72
+ return {
73
+ locale: "en",
74
+ removeSourceMaps: !nuxt.options.dev,
75
+ componentName: {
76
+ codeEditor: "MonacoEditor",
77
+ diffEditor: "MonacoDiffEditor"
78
+ }
79
+ };
69
80
  };
70
81
  const module = defineNuxtModule({
71
82
  meta: {
@@ -73,7 +84,7 @@ const module = defineNuxtModule({
73
84
  configKey: "monacoEditor",
74
85
  compatibility: { nuxt: ">=3.1.0" }
75
86
  },
76
- defaults: DEFAULTS,
87
+ defaults: getDefaults,
77
88
  setup(options, nuxt) {
78
89
  const isDev = nuxt.options.dev;
79
90
  const runtimeDir = fileURLToPath(new URL("./runtime", import.meta.url));
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "type": "git",
12
12
  "url": "https://github.com/e-chan1007/nuxt-monaco-editor.git"
13
13
  },
14
- "version": "1.3.0",
14
+ "version": "1.3.1-0",
15
15
  "type": "module",
16
16
  "license": "MIT",
17
17
  "exports": {
File without changes