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' ]) })