Socket
Socket
Sign inDemoInstall

micromark-extension-mdxjs-esm

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

micromark-extension-mdxjs-esm - npm Package Compare versions

Comparing version 1.0.5 to 2.0.0

6

dev/lib/syntax.d.ts

@@ -27,10 +27,10 @@ /**

* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
* sourceType: 'module'}`).
* all fields except `locations` can be set
* sourceType: 'module'}`); all fields except `locations` can be set.
*/
acornOptions?: AcornOptions | null | undefined
/**
* Whether to add `estree` fields to tokens with results from acorn.
* Whether to add `estree` fields to tokens with results from acorn
* (default: `false`).
*/
addResult?: boolean | null | undefined
}

@@ -17,14 +17,13 @@ /**

* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
* sourceType: 'module'}`).
* all fields except `locations` can be set
* sourceType: 'module'}`); all fields except `locations` can be set.
* @property {boolean | null | undefined} [addResult=false]
* Whether to add `estree` fields to tokens with results from acorn.
* Whether to add `estree` fields to tokens with results from acorn
* (default: `false`).
*/
import {ok as assert} from 'uvu/assert'
import {ok as assert} from 'devlop'
import {blankLine} from 'micromark-core-commonmark'
import {asciiAlpha, markdownLineEnding} from 'micromark-util-character'
import {eventsToAcorn} from 'micromark-util-events-to-acorn'
import {codes} from 'micromark-util-symbol/codes.js'
import {types} from 'micromark-util-symbol/types.js'
import {codes, types} from 'micromark-util-symbol'
import {positionFromEstree} from 'unist-util-position-from-estree'

@@ -35,2 +34,4 @@ import {VFileMessage} from 'vfile-message'

const trouble = 'https://github.com/micromark/micromark-extension-mdxjs-esm'
const allowedAcornTypes = new Set([

@@ -78,3 +79,2 @@ 'ExportAllDeclaration',

const self = this
/** @type {Array<string>} */
const definedModuleSpecifiers =

@@ -222,2 +222,3 @@ self.parser.definedModuleSpecifiers ||

acornOptions,
tokenTypes: ['mdxjsEsmData'],
prefix:

@@ -236,11 +237,17 @@ definedModuleSpecifiers.length > 0

throw new VFileMessage(
'Could not parse import/exports with acorn: ' + String(result.error),
const error = new VFileMessage(
'Could not parse import/exports with acorn',
{
line: result.error.loc.line,
column: result.error.loc.column + 1,
offset: result.error.pos
},
'micromark-extension-mdxjs-esm:acorn'
cause: result.error,
place: {
line: result.error.loc.line,
column: result.error.loc.column + 1,
offset: result.error.pos
},
ruleId: 'acorn',
source: 'micromark-extension-mdxjs-esm'
}
)
error.url = trouble + '#could-not-parse-importexports-with-acorn'
throw error
}

@@ -263,9 +270,16 @@

if (!allowedAcornTypes.has(node.type)) {
throw new VFileMessage(
const error = new VFileMessage(
'Unexpected `' +
node.type +
'` in code: only import/exports are supported',
positionFromEstree(node),
'micromark-extension-mdxjs-esm:non-esm'
{
place: positionFromEstree(node),
ruleId: 'non-esm',
source: 'micromark-extension-mdxjs-esm'
}
)
error.url =
trouble +
'#unexpected-type-in-code-only-importexports-are-supported'
throw error
}

@@ -272,0 +286,0 @@

@@ -27,10 +27,10 @@ /**

* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
* sourceType: 'module'}`).
* all fields except `locations` can be set
* sourceType: 'module'}`); all fields except `locations` can be set.
*/
acornOptions?: AcornOptions | null | undefined
/**
* Whether to add `estree` fields to tokens with results from acorn.
* Whether to add `estree` fields to tokens with results from acorn
* (default: `false`).
*/
addResult?: boolean | null | undefined
}

@@ -17,6 +17,6 @@ /**

* Configuration for acorn (default: `{ecmaVersion: 2020, locations: true,
* sourceType: 'module'}`).
* all fields except `locations` can be set
* sourceType: 'module'}`); all fields except `locations` can be set.
* @property {boolean | null | undefined} [addResult=false]
* Whether to add `estree` fields to tokens with results from acorn.
* Whether to add `estree` fields to tokens with results from acorn
* (default: `false`).
*/

@@ -33,2 +33,3 @@

}
const trouble = 'https://github.com/micromark/micromark-extension-mdxjs-esm'
const allowedAcornTypes = new Set([

@@ -79,3 +80,2 @@ 'ExportAllDeclaration',

const self = this
/** @type {Array<string>} */
const definedModuleSpecifiers =

@@ -207,2 +207,3 @@ self.parser.definedModuleSpecifiers ||

acornOptions,
tokenTypes: ['mdxjsEsmData'],
prefix:

@@ -219,11 +220,17 @@ definedModuleSpecifiers.length > 0

}
throw new VFileMessage(
'Could not parse import/exports with acorn: ' + String(result.error),
const error = new VFileMessage(
'Could not parse import/exports with acorn',
{
line: result.error.loc.line,
column: result.error.loc.column + 1,
offset: result.error.pos
},
'micromark-extension-mdxjs-esm:acorn'
cause: result.error,
place: {
line: result.error.loc.line,
column: result.error.loc.column + 1,
offset: result.error.pos
},
ruleId: 'acorn',
source: 'micromark-extension-mdxjs-esm'
}
)
error.url = trouble + '#could-not-parse-importexports-with-acorn'
throw error
}

@@ -238,9 +245,16 @@ // Remove the `VariableDeclaration`.

if (!allowedAcornTypes.has(node.type)) {
throw new VFileMessage(
const error = new VFileMessage(
'Unexpected `' +
node.type +
'` in code: only import/exports are supported',
positionFromEstree(node),
'micromark-extension-mdxjs-esm:non-esm'
{
place: positionFromEstree(node),
ruleId: 'non-esm',
source: 'micromark-extension-mdxjs-esm'
}
)
error.url =
trouble +
'#unexpected-type-in-code-only-importexports-are-supported'
throw error
}

@@ -247,0 +261,0 @@

{
"name": "micromark-extension-mdxjs-esm",
"version": "1.0.5",
"version": "2.0.0",
"description": "micromark extension to support MDX JS import/exports",

@@ -32,4 +32,6 @@ "license": "MIT",

"type": "module",
"main": "index.js",
"types": "index.d.ts",
"exports": {
"development": "./dev/index.js",
"default": "./index.js"
},
"files": [

@@ -41,16 +43,12 @@ "dev/",

],
"exports": {
"development": "./dev/index.js",
"default": "./index.js"
},
"dependencies": {
"@types/estree": "^1.0.0",
"micromark-core-commonmark": "^1.0.0",
"micromark-util-character": "^1.0.0",
"micromark-util-events-to-acorn": "^1.0.0",
"micromark-util-symbol": "^1.0.0",
"micromark-util-types": "^1.0.0",
"devlop": "^1.0.0",
"micromark-core-commonmark": "^2.0.0",
"micromark-util-character": "^2.0.0",
"micromark-util-events-to-acorn": "^2.0.0",
"micromark-util-symbol": "^2.0.0",
"micromark-util-types": "^2.0.0",
"unist-util-position-from-estree": "^1.1.0",
"uvu": "^0.5.0",
"vfile-message": "^3.0.0"
"vfile-message": "^4.0.0"
},

@@ -62,5 +60,5 @@ "devDependencies": {

"acorn-jsx": "^5.0.0",
"c8": "^7.0.0",
"micromark": "^3.0.0",
"micromark-build": "^1.0.0",
"c8": "^8.0.0",
"micromark": "^4.0.0",
"micromark-build": "^2.0.0",
"prettier": "^2.0.0",

@@ -84,19 +82,12 @@ "remark-cli": "^11.0.0",

"prettier": {
"tabWidth": 2,
"useTabs": false,
"singleQuote": true,
"bracketSpacing": false,
"semi": false,
"trailingComma": "none"
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "none",
"useTabs": false
},
"xo": {
"prettier": true,
"rules": {
"n/file-extension-in-import": "off",
"unicorn/no-this-assignment": "off"
}
},
"remarkConfig": {
"plugins": [
"preset-wooorm"
"remark-preset-wooorm"
]

@@ -107,5 +98,20 @@ },

"detail": true,
"strict": true,
"ignoreCatch": true
"ignoreCatch": true,
"strict": true
},
"xo": {
"prettier": true,
"rules": {
"n/file-extension-in-import": "off",
"unicorn/no-this-assignment": "off"
},
"overrides": [
{
"files": "test/**/*.js",
"rules": {
"no-await-in-loop": "off"
}
}
]
}
}

@@ -25,3 +25,3 @@ # micromark-extension-mdxjs-esm

* [Errors](#errors)
* [Could not parse import/exports with acorn: $error](#could-not-parse-importexports-with-acorn-error)
* [Could not parse import/exports with acorn](#could-not-parse-importexports-with-acorn)
* [Unexpected `$type` in code: only import/exports are supported](#unexpected-type-in-code-only-importexports-are-supported)

@@ -73,3 +73,3 @@ * [Tokens](#tokens)

```js
import {mdxjsEsm} from 'https://esm.sh/micromark-extension-mdxjs-esm@1'
import {mdxjsEsm} from 'https://esm.sh/micromark-extension-mdxjs-esm@2'
```

@@ -81,3 +81,3 @@

<script type="module">
import {mdxjsEsm} from 'https://esm.sh/micromark-extension-mdxjs-esm@1?bundle'
import {mdxjsEsm} from 'https://esm.sh/micromark-extension-mdxjs-esm@2?bundle'
</script>

@@ -169,3 +169,3 @@ ```

```js
```mdx
import a from 'b'

@@ -206,3 +206,5 @@ import * as a from 'b'

}
```
```mdx-invalid
{/* A blank line must be used after import/exports: this is incorrect! */}

@@ -229,3 +231,3 @@

### Could not parse import/exports with acorn: $error
### Could not parse import/exports with acorn

@@ -236,3 +238,3 @@ This error occurs if acorn crashes (source: `micromark-extension-mdxjs-esm`,

```js
```mdx-invalid
import 1/1

@@ -247,3 +249,3 @@ ```

```js
```mdx-invalid
export var a = 1

@@ -272,9 +274,12 @@ var b

Projects maintained by the unified collective are compatible with all maintained
Projects maintained by the unified collective are compatible with maintained
versions of Node.js.
As of now, that is Node.js 16+.
Our projects sometimes work with older versions, but this is not guaranteed.
These extensions work with `micromark` version 3+.
When we cut a new major release, we drop support for unmaintained versions of
Node.
This means we try to keep the current release line,
`micromark-extension-mdxjs-esm@^2`, compatible with Node.js 16.
This package works with `micromark` version `3` and later.
## Security

@@ -321,5 +326,5 @@

[size-badge]: https://img.shields.io/bundlephobia/minzip/micromark-extension-mdxjs-esm.svg
[size-badge]: https://img.shields.io/badge/dynamic/json?label=minzipped%20size&query=$.size.compressedSize&url=https://deno.bundlejs.com/?q=micromark-extension-mdxjs-esm
[size]: https://bundlephobia.com/result?p=micromark-extension-mdxjs-esm
[size]: https://bundlejs.com/?q=micromark-extension-mdxjs-esm

@@ -344,7 +349,7 @@ [sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg

[contributing]: https://github.com/micromark/.github/blob/HEAD/contributing.md
[contributing]: https://github.com/micromark/.github/blob/main/contributing.md
[support]: https://github.com/micromark/.github/blob/HEAD/support.md
[support]: https://github.com/micromark/.github/blob/main/support.md
[coc]: https://github.com/micromark/.github/blob/HEAD/code-of-conduct.md
[coc]: https://github.com/micromark/.github/blob/main/code-of-conduct.md

@@ -351,0 +356,0 @@ [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc