From 192a2e0b8c599523731bf0e549bf33999d947ef0 Mon Sep 17 00:00:00 2001 From: Silviu Alexandru Avram Date: Mon, 9 Feb 2026 09:29:23 +0200 Subject: [PATCH] feat: support cjs and esm extensions --- .size-snapshot.json | 31 ----------------------------- other/misc-tests/__tests__/build.js | 10 +++++----- other/misc-tests/jest.config.js | 7 +++++-- package.json | 16 +++++++-------- 4 files changed, 18 insertions(+), 46 deletions(-) delete mode 100644 .size-snapshot.json diff --git a/.size-snapshot.json b/.size-snapshot.json deleted file mode 100644 index 08893610..00000000 --- a/.size-snapshot.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "downshift.cjs.js": { - "bundled": 149451, - "minified": 68556, - "gzipped": 14398 - }, - "downshift.umd.min.js": { - "bundled": 156339, - "minified": 52343, - "gzipped": 14138 - }, - "downshift.umd.js": { - "bundled": 202102, - "minified": 70464, - "gzipped": 18354 - }, - "downshift.esm.js": { - "bundled": 144747, - "minified": 64534, - "gzipped": 14156, - "treeshaked": { - "rollup": { - "code": 2275, - "import_statements": 318 - }, - "webpack": { - "code": 4626 - } - } - } -} diff --git a/other/misc-tests/__tests__/build.js b/other/misc-tests/__tests__/build.js index c56a56c3..20f633e3 100644 --- a/other/misc-tests/__tests__/build.js +++ b/other/misc-tests/__tests__/build.js @@ -15,7 +15,7 @@ import esImport, { useCombobox as useComboboxEsImport, useSelect as useSelectEsImport, useMultipleSelection as useMultipleSelectionEsImport, -} from '../../../dist/downshift.esm' +} from '../../../dist/downshift.esm.mjs' import cjsImport, { useCombobox as useComboboxCjsImport, @@ -33,21 +33,21 @@ import rnImport, { useCombobox as useComboboxRnImport, useSelect as useSelectRnImport, useMultipleSelection as useMultipleSelectionRnImport, -} from '../../../dist/downshift.native.cjs' +} from '../../../dist/downshift.native.cjs.cjs' import rnWebImport, { useCombobox as useComboboxRnWebImport, useSelect as useSelectRnWebImport, useMultipleSelection as useMultipleSelectionRnWebImport, -} from '../../../dist/downshift.nativeweb.cjs' +} from '../../../dist/downshift.nativeweb.cjs.cjs' // intentionally left out because you shouldn't ever // try to require the ES file in CommonJS // const esRequire = require('../../../dist/downshift.es') const cjsRequire = require('../../../') // picks up the main from package.json const umdRequire = require('../../../dist/downshift.umd') -const rnCjsRequire = require('../../../dist/downshift.native.cjs') -const rnWebCjsRequire = require('../../../dist/downshift.native.cjs') +const rnCjsRequire = require('../../../dist/downshift.native.cjs.cjs') +const rnWebCjsRequire = require('../../../dist/downshift.nativeweb.cjs.cjs') test('downshift component is imported', () => { assert( diff --git a/other/misc-tests/jest.config.js b/other/misc-tests/jest.config.js index b86d5dfc..0df4a948 100644 --- a/other/misc-tests/jest.config.js +++ b/other/misc-tests/jest.config.js @@ -4,9 +4,12 @@ const babelHelpersList = require('@babel/helpers').list module.exports = Object.assign(jestConfig, { roots: ['.'], testEnvironment: 'jsdom', - testEnvironmentOptions: { - customExportConditions: ['require', 'node'], + transform: { + '^.+\\.(js|jsx|mjs)$': ['babel-jest', { rootMode: 'upward' }], }, + transformIgnorePatterns: [ + 'node_modules/(?!(dedent|@testing-library/preact)/)', + ], moduleNameMapper: babelHelpersList.reduce( (aliasMap, helper) => { aliasMap[`@babel/runtime/helpers/esm/${helper}`] = diff --git a/package.json b/package.json index 21848c57..ec7ab1a8 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,9 @@ "name": "downshift", "version": "0.0.0-semantically-released", "description": "🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.", - "main": "dist/downshift.cjs.js", - "react-native": "dist/downshift.native.cjs.js", - "module": "dist/downshift.esm.js", + "main": "dist/downshift.cjs.cjs", + "react-native": "dist/downshift.native.cjs.cjs", + "module": "dist/downshift.esm.mjs", "typings": "typings/index.d.ts", "types": "typings/index.d.ts", "sideEffects": false, @@ -50,13 +50,13 @@ ], "exports": { ".": { - "import": "./dist/downshift.esm.js", - "require": "./dist/downshift.cjs.js", + "import": "./dist/downshift.esm.mjs", + "require": "./dist/downshift.cjs.cjs", "types": "./typings/index.d.ts", - "default": "./dist/downshift.esm.js" + "default": "./dist/downshift.esm.mjs" }, "./react-native": { - "require": "./dist/downshift.native.cjs.js", + "require": "./dist/downshift.native.cjs.cjs", "types": "./typings/index.d.ts" } }, @@ -122,7 +122,7 @@ "flow-bin": "^0.299.0", "flow-coverage-report": "^0.8.0", "get-pkg-repo": "5.0.0", - "kcd-scripts": "^15.0.1", + "kcd-scripts": "^17.0.0", "node-polyfill-webpack-plugin": "^4.1.0", "npm-run-all": "^4.1.5", "preact": "^10.28.2",