From 404a8a1c48f3b6cd244b468b882ee3f2b46112ce Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sat, 23 Sep 2023 14:47:34 +0200 Subject: [PATCH] Change to use `exports` --- ...license.browser.js => find-license.default.js} | 0 lib/{find-license.js => find-license.node.js} | 0 ...browser.js => find-nearest-package.default.js} | 0 ...st-package.js => find-nearest-package.node.js} | 0 lib/index.js | 4 ++-- package.json | 15 ++++++++++----- test/index.js | 6 +++--- 7 files changed, 15 insertions(+), 10 deletions(-) rename lib/{find-license.browser.js => find-license.default.js} (100%) rename lib/{find-license.js => find-license.node.js} (100%) rename lib/{find-nearest-package.browser.js => find-nearest-package.default.js} (100%) rename lib/{find-nearest-package.js => find-nearest-package.node.js} (100%) diff --git a/lib/find-license.browser.js b/lib/find-license.default.js similarity index 100% rename from lib/find-license.browser.js rename to lib/find-license.default.js diff --git a/lib/find-license.js b/lib/find-license.node.js similarity index 100% rename from lib/find-license.js rename to lib/find-license.node.js diff --git a/lib/find-nearest-package.browser.js b/lib/find-nearest-package.default.js similarity index 100% rename from lib/find-nearest-package.browser.js rename to lib/find-nearest-package.default.js diff --git a/lib/find-nearest-package.js b/lib/find-nearest-package.node.js similarity index 100% rename from lib/find-nearest-package.js rename to lib/find-nearest-package.node.js diff --git a/lib/index.js b/lib/index.js index d08f1cf..13fe0c0 100644 --- a/lib/index.js +++ b/lib/index.js @@ -38,8 +38,8 @@ import {headingRange} from 'mdast-util-heading-range' import spdx from 'spdx-license-list' -import {findNearestPackage} from './find-nearest-package.js' -import {findLicense} from './find-license.js' +import {findLicense} from '#find-license' +import {findNearestPackage} from '#find-nearest-package' const http = 'http://' const https = 'https://' diff --git a/package.json b/package.json index fa17d82..a2aff6b 100644 --- a/package.json +++ b/package.json @@ -30,11 +30,16 @@ ], "sideEffects": false, "type": "module", - "main": "index.js", - "types": "index.d.ts", - "browser": { - "./lib/find-license.js": "./lib/find-license.browser.js", - "./lib/find-nearest-package.js": "./lib/find-nearest-package.browser.js" + "exports": "./index.js", + "imports": { + "#find-license": { + "node": "./lib/find-license.node.js", + "default": "./lib/find-license.default.js" + }, + "#find-nearest-package": { + "node": "./lib/find-nearest-package.node.js", + "default": "./lib/find-nearest-package.default.js" + } }, "files": [ "lib/", diff --git a/test/index.js b/test/index.js index 43782c0..0a4018a 100644 --- a/test/index.js +++ b/test/index.js @@ -1,5 +1,5 @@ /** - * @typedef {import('../index.js').Options} Options + * @typedef {import('remark-license').Options} Options */ import assert from 'node:assert/strict' @@ -8,12 +8,12 @@ import process from 'node:process' import test from 'node:test' import {fileURLToPath} from 'node:url' import {remark} from 'remark' +import license from 'remark-license' import semver from 'semver' -import license from '../index.js' test('remark-license', async function (t) { await t.test('should expose the public api', async function () { - assert.deepEqual(Object.keys(await import('../index.js')).sort(), [ + assert.deepEqual(Object.keys(await import('remark-license')).sort(), [ 'default' ]) })