Skip to content

Commit

Permalink
Update MDX integration to es-module-lexer@1.1.1 (#6296)
Browse files Browse the repository at this point in the history
* Update MDX integration to es-module-lexer@1.1.1

* Added missing pnpm-lock.yaml file

* Create lucky-flowers-wonder.md

---------

Co-authored-by: Nate Moore <natemoo-re@users.noreply.github.com>
  • Loading branch information
RaphaelBossek and natemoo-re authored Feb 23, 2023
1 parent f91a7f3 commit 075b87e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/lucky-flowers-wonder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/mdx": patch
---

Update to `es-module-lexer@1.1.1`
4 changes: 4 additions & 0 deletions packages/integrations/mdx/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# @astrojs/mdx

## 0.17.1

- Updated to es-module-lexer@1.1.1

## 0.17.0

### Minor Changes
Expand Down
4 changes: 2 additions & 2 deletions packages/integrations/mdx/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@astrojs/mdx",
"description": "Use MDX within Astro",
"version": "0.17.0",
"version": "0.17.1",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
Expand Down Expand Up @@ -35,7 +35,7 @@
"@mdx-js/mdx": "^2.3.0",
"@mdx-js/rollup": "^2.3.0",
"acorn": "^8.8.0",
"es-module-lexer": "^0.10.5",
"es-module-lexer": "^1.1.1",
"estree-util-visit": "^1.2.0",
"github-slugger": "^1.4.0",
"gray-matter": "^4.0.3",
Expand Down
6 changes: 3 additions & 3 deletions packages/integrations/mdx/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,13 @@ export default function mdx(partialMdxOptions: Partial<MdxOptions> = {}): AstroI
}

const { fileUrl, fileId } = getFileInfo(id, config);
if (!moduleExports.includes('url')) {
if (!moduleExports.find(({n}) => n === 'url')) {
code += `\nexport const url = ${JSON.stringify(fileUrl)};`;
}
if (!moduleExports.includes('file')) {
if (!moduleExports.find(({n}) => n === 'file')) {
code += `\nexport const file = ${JSON.stringify(fileId)};`;
}
if (!moduleExports.includes('Content')) {
if (!moduleExports.find(({n}) => n === 'Content')) {
// Make `Content` the default export so we can wrap `MDXContent` and pass in `Fragment`
code = code.replace('export default MDXContent;', '');
code += `\nexport const Content = (props = {}) => MDXContent({
Expand Down
8 changes: 2 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 075b87e

Please sign in to comment.