From 5a13d73bca350a639323ed680721ab8e195a82b5 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 18 Oct 2023 17:01:58 +0200 Subject: [PATCH] Change to use `exports` --- packages/esbuild/lib/index.js | 6 +++--- packages/esbuild/package.json | 3 +-- packages/loader/lib/index.js | 2 +- packages/loader/package.json | 3 +-- ...condition.browser.js => condition.default.js} | 0 .../mdx/lib/{condition.js => condition.node.js} | 0 packages/mdx/lib/core.js | 2 +- packages/mdx/package.json | 16 ++++++++++------ packages/node-loader/lib/index.js | 6 +++--- packages/node-loader/package.json | 3 +-- packages/preact/package.json | 3 +-- packages/preact/test/index.jsx | 2 +- packages/react/package.json | 3 +-- packages/react/test/index.jsx | 2 +- packages/register/lib/index.cjs | 14 ++++++-------- packages/register/package.json | 3 +-- packages/remark-mdx/package.json | 3 +-- packages/rollup/lib/index.js | 2 +- packages/rollup/package.json | 3 +-- packages/vue/package.json | 3 +-- 20 files changed, 36 insertions(+), 43 deletions(-) rename packages/mdx/lib/{condition.browser.js => condition.default.js} (100%) rename packages/mdx/lib/{condition.js => condition.node.js} (100%) diff --git a/packages/esbuild/lib/index.js b/packages/esbuild/lib/index.js index d8e48e2c6..cdc3dc8d5 100644 --- a/packages/esbuild/lib/index.js +++ b/packages/esbuild/lib/index.js @@ -1,5 +1,5 @@ /** - * @typedef {import('@mdx-js/mdx/lib/core.js').ProcessorOptions} ProcessorOptions + * @typedef {import('@mdx-js/mdx').ProcessorOptions} ProcessorOptions * @typedef {import('esbuild').Message} Message * @typedef {import('esbuild').OnLoadArgs} OnLoadArgs * @typedef {import('esbuild').OnLoadResult} OnLoadResult @@ -46,8 +46,8 @@ import assert from 'node:assert' import fs from 'node:fs/promises' import path from 'node:path' import process from 'node:process' -import {createFormatAwareProcessors} from '@mdx-js/mdx/lib/util/create-format-aware-processors.js' -import {extnamesToRegex} from '@mdx-js/mdx/lib/util/extnames-to-regex.js' +import {createFormatAwareProcessors} from '@mdx-js/mdx/internal-create-format-aware-processors' +import {extnamesToRegex} from '@mdx-js/mdx/internal-extnames-to-regex' import {fetch} from 'undici' import {VFile} from 'vfile' diff --git a/packages/esbuild/package.json b/packages/esbuild/package.json index 10206d502..a9c0cec42 100644 --- a/packages/esbuild/package.json +++ b/packages/esbuild/package.json @@ -30,8 +30,7 @@ ], "type": "module", "sideEffects": false, - "main": "index.js", - "types": "index.d.ts", + "exports": "./index.js", "files": [ "lib/", "index.d.ts", diff --git a/packages/loader/lib/index.js b/packages/loader/lib/index.js index b653732a7..eaff38a91 100644 --- a/packages/loader/lib/index.js +++ b/packages/loader/lib/index.js @@ -24,7 +24,7 @@ import {Buffer} from 'node:buffer' import {createHash} from 'node:crypto' import path from 'node:path' -import {createFormatAwareProcessors} from '@mdx-js/mdx/lib/util/create-format-aware-processors.js' +import {createFormatAwareProcessors} from '@mdx-js/mdx/internal-create-format-aware-processors' import {SourceMapGenerator} from 'source-map' // Note: the cache is heavily inspired by: diff --git a/packages/loader/package.json b/packages/loader/package.json index 5040298e5..f81445ce4 100644 --- a/packages/loader/package.json +++ b/packages/loader/package.json @@ -35,8 +35,7 @@ ], "type": "module", "sideEffects": false, - "main": "index.cjs", - "types": "index.d.ts", + "exports": "./index.cjs", "files": [ "lib/", "index.cjs", diff --git a/packages/mdx/lib/condition.browser.js b/packages/mdx/lib/condition.default.js similarity index 100% rename from packages/mdx/lib/condition.browser.js rename to packages/mdx/lib/condition.default.js diff --git a/packages/mdx/lib/condition.js b/packages/mdx/lib/condition.node.js similarity index 100% rename from packages/mdx/lib/condition.js rename to packages/mdx/lib/condition.node.js diff --git a/packages/mdx/lib/core.js b/packages/mdx/lib/core.js index eea9d97f8..f5d0ac0c8 100644 --- a/packages/mdx/lib/core.js +++ b/packages/mdx/lib/core.js @@ -51,8 +51,8 @@ import {recmaStringify} from './plugin/recma-stringify.js' import {rehypeRecma} from './plugin/rehype-recma.js' import {rehypeRemoveRaw} from './plugin/rehype-remove-raw.js' import {remarkMarkAndUnravel} from './plugin/remark-mark-and-unravel.js' -import {development as defaultDevelopment} from './condition.js' import {nodeTypes} from './node-types.js' +import {development as defaultDevelopment} from '#condition' const removedOptions = [ 'compilers', diff --git a/packages/mdx/package.json b/packages/mdx/package.json index 676ec5c3a..00cc3c52a 100644 --- a/packages/mdx/package.json +++ b/packages/mdx/package.json @@ -31,13 +31,17 @@ ], "type": "module", "sideEffects": false, - "main": "index.js", - "types": "index.d.ts", - "browser": { - "./lib/condition.js": "./lib/condition.browser.js" + "exports": { + ".": "./index.js", + "./internal-create-format-aware-processors": "./lib/util/create-format-aware-processors.js", + "./internal-extnames-to-regex": "./lib/util/extnames-to-regex.js", + "./internal-resolve-evaluate-options": "./lib/util/resolve-evaluate-options.js" }, - "react-native": { - "./lib/condition.js": "./lib/condition.browser.js" + "imports": { + "#condition": { + "node": "./lib/condition.node.js", + "default": "./lib/condition.default.js" + } }, "files": [ "lib/", diff --git a/packages/node-loader/lib/index.js b/packages/node-loader/lib/index.js index 860f57c18..71bd240d4 100644 --- a/packages/node-loader/lib/index.js +++ b/packages/node-loader/lib/index.js @@ -1,10 +1,10 @@ /** - * @typedef {import('@mdx-js/mdx/lib/compile.js').CompileOptions} Options + * @typedef {import('@mdx-js/mdx').CompileOptions} Options */ import fs from 'node:fs/promises' -import {createFormatAwareProcessors} from '@mdx-js/mdx/lib/util/create-format-aware-processors.js' -import {extnamesToRegex} from '@mdx-js/mdx/lib/util/extnames-to-regex.js' +import {createFormatAwareProcessors} from '@mdx-js/mdx/internal-create-format-aware-processors' +import {extnamesToRegex} from '@mdx-js/mdx/internal-extnames-to-regex' import {VFile} from 'vfile' /** diff --git a/packages/node-loader/package.json b/packages/node-loader/package.json index 5c41d8d8d..771b5e9e8 100644 --- a/packages/node-loader/package.json +++ b/packages/node-loader/package.json @@ -29,8 +29,7 @@ ], "type": "module", "sideEffects": false, - "main": "index.js", - "types": "index.d.ts", + "exports": "./index.js", "files": [ "lib/", "index.d.ts", diff --git a/packages/preact/package.json b/packages/preact/package.json index 708594e4e..fe1916013 100644 --- a/packages/preact/package.json +++ b/packages/preact/package.json @@ -33,8 +33,7 @@ ], "type": "module", "sideEffects": false, - "main": "index.js", - "types": "index.d.ts", + "exports": "./index.js", "files": [ "lib/", "index.d.ts", diff --git a/packages/preact/test/index.jsx b/packages/preact/test/index.jsx index c2410f0e2..15633b1ea 100644 --- a/packages/preact/test/index.jsx +++ b/packages/preact/test/index.jsx @@ -1,7 +1,7 @@ /* @jsxRuntime automatic @jsxImportSource preact */ /** - * @typedef {import('@mdx-js/mdx/lib/util/resolve-evaluate-options.js').RuntimeProduction} RuntimeProduction + * @typedef {import('@mdx-js/mdx/internal-resolve-evaluate-options').RuntimeProduction} RuntimeProduction */ import assert from 'node:assert/strict' diff --git a/packages/react/package.json b/packages/react/package.json index e6cfe901f..ed54c7eab 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -32,8 +32,7 @@ ], "type": "module", "sideEffects": false, - "main": "index.js", - "types": "index.d.ts", + "exports": "./index.js", "files": [ "lib/", "index.d.ts", diff --git a/packages/react/test/index.jsx b/packages/react/test/index.jsx index cff290c9a..5ca522c7c 100644 --- a/packages/react/test/index.jsx +++ b/packages/react/test/index.jsx @@ -1,5 +1,5 @@ /** - * @typedef {import('@mdx-js/mdx/lib/util/resolve-evaluate-options.js').RuntimeProduction} RuntimeProduction + * @typedef {import('@mdx-js/mdx/internal-resolve-evaluate-options').RuntimeProduction} RuntimeProduction */ import assert from 'node:assert/strict' diff --git a/packages/register/lib/index.cjs b/packages/register/lib/index.cjs index e62b5b541..b1e8c8dc3 100644 --- a/packages/register/lib/index.cjs +++ b/packages/register/lib/index.cjs @@ -19,11 +19,11 @@ // @ts-expect-error: type imports from CJS do work. /** @typedef {import('@mdx-js/mdx').EvaluateOptions} EvaluateOptions */ // @ts-expect-error: type imports from CJS do work. -/** @typedef {import('@mdx-js/mdx/lib/run.js')} RunMod */ +/** @typedef {import('@mdx-js/mdx')} MdxMod */ // @ts-expect-error: type imports from CJS do work. -/** @typedef {import('@mdx-js/mdx/lib/util/create-format-aware-processors.js')} CreateProcessorMod */ +/** @typedef {import('@mdx-js/mdx/internal-create-format-aware-processors')} CreateProcessorMod */ // @ts-expect-error: type imports from CJS do work. -/** @typedef {import('@mdx-js/mdx/lib/util/resolve-evaluate-options.js')} ResolveEvaluateMod */ +/** @typedef {import('@mdx-js/mdx/internal-resolve-evaluate-options')} ResolveEvaluateMod */ 'use strict' @@ -31,14 +31,12 @@ const fs = require('node:fs') const deasync = require('deasync') const {createFormatAwareProcessors} = /** @type {CreateProcessorMod} */ ( - deasync(load)('@mdx-js/mdx/lib/util/create-format-aware-processors.js') + deasync(load)('@mdx-js/mdx/internal-create-format-aware-processors') ) const {resolveEvaluateOptions} = /** @type {ResolveEvaluateMod} */ ( - deasync(load)('@mdx-js/mdx/lib/util/resolve-evaluate-options.js') -) -const {runSync} = /** @type {RunMod} */ ( - deasync(load)('@mdx-js/mdx/lib/run.js') + deasync(load)('@mdx-js/mdx/internal-resolve-evaluate-options') ) +const {runSync} = /** @type {MdxMod} */ (deasync(load)('@mdx-js/mdx')) module.exports = register diff --git a/packages/register/package.json b/packages/register/package.json index c79d943f9..b97c4ca60 100644 --- a/packages/register/package.json +++ b/packages/register/package.json @@ -29,8 +29,7 @@ ], "type": "module", "sideEffects": true, - "main": "index.cjs", - "types": "index.d.ts", + "exports": "./index.cjs", "files": [ "lib/", "index.d.ts", diff --git a/packages/remark-mdx/package.json b/packages/remark-mdx/package.json index acd3ef4ce..227e25c51 100644 --- a/packages/remark-mdx/package.json +++ b/packages/remark-mdx/package.json @@ -33,8 +33,7 @@ ], "type": "module", "sideEffects": false, - "main": "index.js", - "types": "index.d.ts", + "exports": "./index.js", "files": [ "lib/", "index.d.ts", diff --git a/packages/rollup/lib/index.js b/packages/rollup/lib/index.js index 5cbb007fd..17f8de9b1 100644 --- a/packages/rollup/lib/index.js +++ b/packages/rollup/lib/index.js @@ -19,7 +19,7 @@ * Configuration. */ -import {createFormatAwareProcessors} from '@mdx-js/mdx/lib/util/create-format-aware-processors.js' +import {createFormatAwareProcessors} from '@mdx-js/mdx/internal-create-format-aware-processors' import {createFilter} from '@rollup/pluginutils' import {SourceMapGenerator} from 'source-map' import {VFile} from 'vfile' diff --git a/packages/rollup/package.json b/packages/rollup/package.json index 44b12f45f..9bee43ffb 100644 --- a/packages/rollup/package.json +++ b/packages/rollup/package.json @@ -30,8 +30,7 @@ ], "type": "module", "sideEffects": false, - "main": "index.js", - "types": "index.d.ts", + "exports": "./index.js", "files": [ "lib/", "index.d.ts", diff --git a/packages/vue/package.json b/packages/vue/package.json index 3b0c45b3c..1dde64494 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -28,8 +28,7 @@ ], "type": "module", "sideEffects": false, - "main": "index.js", - "types": "index.d.ts", + "exports": "./index.js", "files": [ "lib/", "index.d.ts",