diff --git a/README.md b/README.md index eb149895..98db232c 100644 --- a/README.md +++ b/README.md @@ -60,27 +60,27 @@ or via CDN Sortable, Droppable, Swappable, - } from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/index.js'; + } from 'https://cdn.jsdelivr.net/npm/@shopify/draggable/build/esm/index.mjs'; diff --git a/package.json b/package.json index 19d22f8d..57c690ee 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,9 @@ "drag-and-drop", "es6" ], - "main": "build/cjs/index.js", - "module": "build/esm/index.js", - "esnext": "build/esnext/index.esnext", + "main": "build/cjs/index.cjs", + "module": "build/esm/index.mjs", + "esnext": "build/esnext/index.mjs", "umd": "build/umd/index.js", "types": "./index.d.ts", "scripts": { @@ -68,6 +68,7 @@ "jest-environment-jsdom": "^29.7.0", "prettier": "^3.0.3", "rollup": "^3.29.3", + "rollup-plugin-cleanup": "^3.2.1", "rollup-plugin-includepaths": "^0.2.4", "rollup-plugin-node-externals": "^6.1.1", "timers": "^0.1.1", diff --git a/rollup.config.ts b/rollup.config.ts index 50f68089..2b497dab 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -6,6 +6,7 @@ import {babel, RollupBabelInputPluginOptions} from '@rollup/plugin-babel'; import commonjs from '@rollup/plugin-commonjs'; import {nodeResolve} from '@rollup/plugin-node-resolve'; import includePaths from 'rollup-plugin-includepaths'; +import cleanupPlugin from 'rollup-plugin-cleanup'; const packageJSON = readFileSync( new URL('./package.json', import.meta.url).pathname, @@ -29,9 +30,9 @@ export function generateConfig({ shared: 'src/shared', }, paths: ['src/'], - extensions: ['.js', '.ts'], + extensions: [...extensions], }), - nodeResolve({extensions}), + nodeResolve({extensions: [...extensions]}), commonjs(), babel({ extensions, @@ -40,6 +41,10 @@ export function generateConfig({ envName: 'production', targets, }), + cleanupPlugin({ + extensions: [...extensions], + maxEmptyLines: 1, + }), ], output, }; @@ -53,14 +58,14 @@ const config = [ format: 'cjs', dir: path.dirname(pkg.main), preserveModules: true, - entryFileNames: '[name].js', + entryFileNames: '[name].cjs', exports: 'named', }, { format: 'esm', dir: path.dirname(pkg.module), preserveModules: true, - entryFileNames: '[name].js', + entryFileNames: '[name].mjs', }, { format: 'umd', @@ -76,7 +81,7 @@ const config = [ format: 'esm', dir: path.dirname(pkg.esnext), preserveModules: true, - entryFileNames: '[name].esnext', + entryFileNames: '[name].mjs', }, ], }), diff --git a/src/Draggable/README.md b/src/Draggable/README.md index 244110f9..cd9a9ccf 100644 --- a/src/Draggable/README.md +++ b/src/Draggable/README.md @@ -18,7 +18,7 @@ const draggable = new Draggable(document.querySelectorAll('ul'), { ```html