@astrojs/mdx 2.0.3 → 2.0.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.
package/dist/index.js CHANGED
@@ -89,7 +89,7 @@ function mdx(partialMdxOptions = {}) {
89
89
  try {
90
90
  const compiled = await processor.process(vfile);
91
91
  return {
92
- code: escapeViteEnvReferences(String(compiled.value)),
92
+ code: String(compiled.value),
93
93
  map: compiled.map
94
94
  };
95
95
  } catch (e) {
@@ -157,7 +157,7 @@ if (import.meta.hot) {
157
157
  import.meta.hot.decline();
158
158
  }`;
159
159
  }
160
- return { code: escapeViteEnvReferences(code), map: null };
160
+ return { code, map: null };
161
161
  }
162
162
  }
163
163
  ]
@@ -198,9 +198,6 @@ function applyDefaultOptions({
198
198
  optimize: options.optimize ?? defaults.optimize
199
199
  };
200
200
  }
201
- function escapeViteEnvReferences(code) {
202
- return code.replace(/import\.meta\.env/g, "import\\u002Emeta.env");
203
- }
204
201
  export {
205
202
  mdx as default
206
203
  };
@@ -6,7 +6,7 @@ function recmaInjectImportMetaEnv({
6
6
  estreeVisit(tree, (node) => {
7
7
  if (node.type === "MemberExpression") {
8
8
  const envVarName = getImportMetaEnvVariableName(node);
9
- if (typeof envVarName === "string") {
9
+ if (typeof envVarName === "string" && importMetaEnv[envVarName] != null) {
10
10
  for (const key in node) {
11
11
  delete node[key];
12
12
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@astrojs/mdx",
3
3
  "description": "Add support for MDX pages in your Astro site",
4
- "version": "2.0.3",
4
+ "version": "2.0.4",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -67,7 +67,7 @@
67
67
  "remark-toc": "^9.0.0",
68
68
  "unified": "^11.0.4",
69
69
  "vite": "^5.0.10",
70
- "astro": "4.0.8",
70
+ "astro": "4.1.2",
71
71
  "astro-scripts": "0.0.14"
72
72
  },
73
73
  "engines": {