From e5b2dfdc73ec459e90fdf3cdef520a0ae74828fa Mon Sep 17 00:00:00 2001 From: Alex Khizhnyi Date: Thu, 10 Oct 2024 18:32:27 +0300 Subject: [PATCH] Fix module import and build on win system (#35) --------- Co-authored-by: Alex Khizhnyi --- package.json | 1 + scripts/bundle.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index cd15681..336d1a9 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ }, "type": "module", "main": "./cjs/index.cjs", + "module": "./lib/index.js", "exports": { ".": { "import": "./lib/index.js", diff --git a/scripts/bundle.js b/scripts/bundle.js index 3a7da1b..de632c9 100644 --- a/scripts/bundle.js +++ b/scripts/bundle.js @@ -7,10 +7,10 @@ const { version } = createRequire(import.meta.url)('../package.json'); async function build() { const genModules = { - [path.resolve('lib/version.js')]: `export const version = "${version}";`, - [path.resolve('lib/version.cjs')]: `module.exports = "${version}";` + 'version.js': `export const version = "${version}";`, + 'version.cjs': `module.exports = "${version}";` }; - const genModulesFilter = new RegExp('(' + Object.keys(genModules).join('|').replace(/\./g, '\\.') + ')$'); + const genModulesFilter = new RegExp('lib[\\\\/](' + Object.keys(genModules).join('|').replace(/\./g, '\\.') + ')$'); const plugins = [{ name: 'replace', setup({ onLoad }) {