@astrojs/mdx 0.18.3 → 0.18.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.
@@ -1,5 +1,5 @@
1
- @astrojs/mdx:build: cache hit, replaying output 603ca93f0d424089
1
+ @astrojs/mdx:build: cache hit, replaying output dc77e5588cbd224c
2
2
  @astrojs/mdx:build: 
3
- @astrojs/mdx:build: > @astrojs/mdx@0.18.3 build /home/runner/work/astro/astro/packages/integrations/mdx
3
+ @astrojs/mdx:build: > @astrojs/mdx@0.18.4 build /home/runner/work/astro/astro/packages/integrations/mdx
4
4
  @astrojs/mdx:build: > astro-scripts build "src/**/*.ts" && tsc
5
5
  @astrojs/mdx:build: 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @astrojs/mdx
2
2
 
3
+ ## 0.18.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#6817](https://github.com/withastro/astro/pull/6817) [`f882bc163`](https://github.com/withastro/astro/commit/f882bc1636d5ce1c3b8faae47df36b4dc758045a) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Fix sourcemap warnings when using Content Collections and MDX with the `vite.build.sourcemap` option
8
+
3
9
  ## 0.18.3
4
10
 
5
11
  ### Patch Changes
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ import mdxPlugin from "@mdx-js/rollup";
5
5
  import { parse as parseESM } from "es-module-lexer";
6
6
  import fs from "node:fs/promises";
7
7
  import { fileURLToPath } from "node:url";
8
+ import { SourceMapGenerator } from "source-map";
8
9
  import { VFile } from "vfile";
9
10
  import { getRehypePlugins, getRemarkPlugins, recmaInjectImportMetaEnvPlugin } from "./plugins.js";
10
11
  import { getFileInfo, ignoreStringPlugins, parseFrontmatter } from "./utils.js";
@@ -64,6 +65,7 @@ function mdx(partialMdxOptions = {}) {
64
65
  // Override transform to alter code before MDX compilation
65
66
  // ex. inject layouts
66
67
  async transform(_, id) {
68
+ var _a;
67
69
  if (!id.endsWith("mdx"))
68
70
  return;
69
71
  const { fileId } = getFileInfo(id, config);
@@ -80,7 +82,8 @@ function mdx(partialMdxOptions = {}) {
80
82
  recmaPlugins: [
81
83
  ...mdxPluginOpts.recmaPlugins ?? [],
82
84
  () => recmaInjectImportMetaEnvPlugin({ importMetaEnv })
83
- ]
85
+ ],
86
+ SourceMapGenerator: ((_a = config.vite.build) == null ? void 0 : _a.sourcemap) ? SourceMapGenerator : void 0
84
87
  });
85
88
  return {
86
89
  code: escapeViteEnvReferences(String(compiled.value)),
@@ -130,7 +133,7 @@ if (import.meta.hot) {
130
133
  import.meta.hot.decline();
131
134
  }`;
132
135
  }
133
- return escapeViteEnvReferences(code);
136
+ return { code: escapeViteEnvReferences(code), map: null };
134
137
  }
135
138
  }
136
139
  ]
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": "0.18.3",
4
+ "version": "0.18.4",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -38,6 +38,7 @@
38
38
  "remark-gfm": "^3.0.1",
39
39
  "remark-smartypants": "^2.0.0",
40
40
  "shiki": "^0.11.1",
41
+ "source-map": "^0.7.4",
41
42
  "unist-util-visit": "^4.1.0",
42
43
  "vfile": "^5.3.2"
43
44
  },
@@ -48,7 +49,7 @@
48
49
  "@types/mdast": "^3.0.10",
49
50
  "@types/mocha": "^9.1.1",
50
51
  "@types/yargs-parser": "^21.0.0",
51
- "astro": "2.2.1",
52
+ "astro": "2.2.3",
52
53
  "astro-scripts": "0.0.14",
53
54
  "chai": "^4.3.6",
54
55
  "cheerio": "^1.0.0-rc.11",
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ import { parse as parseESM } from 'es-module-lexer';
8
8
  import fs from 'node:fs/promises';
9
9
  import { fileURLToPath } from 'node:url';
10
10
  import type { Options as RemarkRehypeOptions } from 'remark-rehype';
11
+ import { SourceMapGenerator } from 'source-map';
11
12
  import { VFile } from 'vfile';
12
13
  import type { Plugin as VitePlugin } from 'vite';
13
14
  import { getRehypePlugins, getRemarkPlugins, recmaInjectImportMetaEnvPlugin } from './plugins.js';
@@ -113,6 +114,9 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
113
114
  ...(mdxPluginOpts.recmaPlugins ?? []),
114
115
  () => recmaInjectImportMetaEnvPlugin({ importMetaEnv }),
115
116
  ],
117
+ SourceMapGenerator: config.vite.build?.sourcemap
118
+ ? SourceMapGenerator
119
+ : undefined,
116
120
  });
117
121
 
118
122
  return {
@@ -168,7 +172,7 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
168
172
  import.meta.hot.decline();
169
173
  }`;
170
174
  }
171
- return escapeViteEnvReferences(code);
175
+ return { code: escapeViteEnvReferences(code), map: null };
172
176
  },
173
177
  },
174
178
  ] as VitePlugin[],