Skip to content

Commit b6e7167

Browse files
authored
Make Expressive Code packages ESM-only (#177)
1 parent b9a5614 commit b6e7167

File tree

9 files changed

+30
-24
lines changed

9 files changed

+30
-24
lines changed

.changeset/swift-trees-sniff.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@expressive-code/plugin-collapsible-sections': minor
3+
'@expressive-code/plugin-line-numbers': minor
4+
'@expressive-code/plugin-text-markers': minor
5+
'@expressive-code/plugin-frames': minor
6+
'@expressive-code/plugin-shiki': minor
7+
'remark-expressive-code': minor
8+
'@expressive-code/core': minor
9+
'expressive-code': minor
10+
---
11+
12+
Since this version, all packages are only distributed in modern ESM format, which greatly reduces bundle size.
13+
14+
Most projects should not be affected by this change at all, but in case you still need to import Expressive Code packages into a CommonJS project, you can use the widely supported `await import(...)` syntax.

packages/@expressive-code/core/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111
"directory": "packages/@expressive-code/core"
1212
},
1313
"type": "module",
14-
"main": "./dist/index.cjs",
14+
"main": "./dist/index.js",
1515
"module": "./dist/index.js",
1616
"exports": {
1717
"types": "./dist/index.d.ts",
18-
"require": "./dist/index.cjs",
1918
"default": "./dist/index.js"
2019
},
2120
"types": "./dist/index.d.ts",
2221
"files": [
2322
"dist"
2423
],
2524
"scripts": {
26-
"build": "tsup ./src/index.ts --format esm,cjs --dts --sourcemap --clean",
25+
"build": "tsup ./src/index.ts --format esm --dts --sourcemap --clean",
2726
"coverage": "vitest run --coverage",
2827
"test": "vitest run --reporter verbose",
2928
"test-short": "vitest run --reporter basic",

packages/@expressive-code/plugin-collapsible-sections/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111
"directory": "packages/@expressive-code/plugin-collapsible-sections"
1212
},
1313
"type": "module",
14-
"main": "./dist/index.cjs",
14+
"main": "./dist/index.js",
1515
"module": "./dist/index.js",
1616
"exports": {
1717
"types": "./dist/index.d.ts",
18-
"require": "./dist/index.cjs",
1918
"default": "./dist/index.js"
2019
},
2120
"types": "./dist/index.d.ts",
2221
"files": [
2322
"dist"
2423
],
2524
"scripts": {
26-
"build": "tsup ./src/index.ts --format esm,cjs --dts --sourcemap --clean",
25+
"build": "tsup ./src/index.ts --format esm --dts --sourcemap --clean",
2726
"coverage": "vitest run --coverage",
2827
"test": "vitest run --reporter verbose",
2928
"test-short": "vitest run --reporter basic",

packages/@expressive-code/plugin-frames/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111
"directory": "packages/@expressive-code/plugin-frames"
1212
},
1313
"type": "module",
14-
"main": "./dist/index.cjs",
14+
"main": "./dist/index.js",
1515
"module": "./dist/index.js",
1616
"exports": {
1717
"types": "./dist/index.d.ts",
18-
"require": "./dist/index.cjs",
1918
"default": "./dist/index.js"
2019
},
2120
"types": "./dist/index.d.ts",
2221
"files": [
2322
"dist"
2423
],
2524
"scripts": {
26-
"build": "pnpm build-js-modules && tsup ./src/index.ts --format esm,cjs --dts --sourcemap --clean",
25+
"build": "pnpm build-js-modules && tsup ./src/index.ts --format esm --dts --sourcemap --clean",
2726
"build-js-modules": "tsm --require=../../../scripts/lib/filter-warnings.cjs ../../../scripts/build-js-module.ts ./src/copy-js-module.ts",
2827
"coverage": "vitest run --coverage",
2928
"test": "vitest run --reporter verbose",

packages/@expressive-code/plugin-line-numbers/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111
"directory": "packages/@expressive-code/plugin-line-numbers"
1212
},
1313
"type": "module",
14-
"main": "./dist/index.cjs",
14+
"main": "./dist/index.js",
1515
"module": "./dist/index.js",
1616
"exports": {
1717
"types": "./dist/index.d.ts",
18-
"require": "./dist/index.cjs",
1918
"default": "./dist/index.js"
2019
},
2120
"types": "./dist/index.d.ts",
2221
"files": [
2322
"dist"
2423
],
2524
"scripts": {
26-
"build": "tsup ./src/index.ts --format esm,cjs --dts --sourcemap --clean",
25+
"build": "tsup ./src/index.ts --format esm --dts --sourcemap --clean",
2726
"coverage": "vitest run --coverage",
2827
"test": "vitest run --reporter verbose",
2928
"test-short": "vitest run --reporter basic",

packages/@expressive-code/plugin-shiki/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111
"directory": "packages/@expressive-code/plugin-shiki"
1212
},
1313
"type": "module",
14-
"main": "./dist/index.cjs",
14+
"main": "./dist/index.js",
1515
"module": "./dist/index.js",
1616
"exports": {
1717
"types": "./dist/index.d.ts",
18-
"require": "./dist/index.cjs",
1918
"default": "./dist/index.js"
2019
},
2120
"types": "./dist/index.d.ts",
2221
"files": [
2322
"dist"
2423
],
2524
"scripts": {
26-
"build": "tsup ./src/index.ts --format esm,cjs --dts --sourcemap --clean",
25+
"build": "tsup ./src/index.ts --format esm --dts --sourcemap --clean",
2726
"coverage": "vitest run --coverage",
2827
"test": "vitest run --reporter verbose",
2928
"test-short": "vitest run --reporter basic",

packages/@expressive-code/plugin-text-markers/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111
"directory": "packages/@expressive-code/plugin-text-markers"
1212
},
1313
"type": "module",
14-
"main": "./dist/index.cjs",
14+
"main": "./dist/index.js",
1515
"module": "./dist/index.js",
1616
"exports": {
1717
"types": "./dist/index.d.ts",
18-
"require": "./dist/index.cjs",
1918
"default": "./dist/index.js"
2019
},
2120
"types": "./dist/index.d.ts",
2221
"files": [
2322
"dist"
2423
],
2524
"scripts": {
26-
"build": "tsup ./src/index.ts --format esm,cjs --dts --sourcemap --clean",
25+
"build": "tsup ./src/index.ts --format esm --dts --sourcemap --clean",
2726
"coverage": "vitest run --coverage",
2827
"test": "vitest run --reporter verbose",
2928
"test-short": "vitest run --reporter basic",

packages/expressive-code/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111
"directory": "packages/expressive-code"
1212
},
1313
"type": "module",
14-
"main": "./dist/index.cjs",
14+
"main": "./dist/index.js",
1515
"module": "./dist/index.js",
1616
"exports": {
1717
"types": "./dist/index.d.ts",
18-
"require": "./dist/index.cjs",
1918
"default": "./dist/index.js"
2019
},
2120
"types": "./dist/index.d.ts",
2221
"files": [
2322
"dist"
2423
],
2524
"scripts": {
26-
"build": "tsup ./src/index.ts --format esm,cjs --dts --sourcemap --clean",
25+
"build": "tsup ./src/index.ts --format esm --dts --sourcemap --clean",
2726
"coverage": "vitest run --coverage",
2827
"test": "vitest run --reporter verbose",
2928
"test-short": "vitest run --reporter basic",

packages/remark-expressive-code/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111
"directory": "packages/remark-expressive-code"
1212
},
1313
"type": "module",
14-
"main": "./dist/index.cjs",
14+
"main": "./dist/index.js",
1515
"module": "./dist/index.js",
1616
"exports": {
1717
"types": "./dist/index.d.ts",
18-
"require": "./dist/index.cjs",
1918
"default": "./dist/index.js"
2019
},
2120
"types": "./dist/index.d.ts",
2221
"files": [
2322
"dist"
2423
],
2524
"scripts": {
26-
"build": "tsup ./src/index.ts --format esm,cjs --dts --sourcemap --clean",
25+
"build": "tsup ./src/index.ts --format esm --dts --sourcemap --clean",
2726
"coverage": "vitest run --coverage",
2827
"test": "vitest run --reporter verbose",
2928
"test-short": "vitest run --reporter basic",

0 commit comments

Comments
 (0)