diff --git a/packages/code-highlight/README.md b/packages/code-highlight/README.md new file mode 100644 index 00000000..17e729c7 --- /dev/null +++ b/packages/code-highlight/README.md @@ -0,0 +1,3 @@ +# code-highlight + +repack Prismjs to make it compatible with esm diff --git a/packages/code-highlight/babel.config.js b/packages/code-highlight/babel.config.js new file mode 100644 index 00000000..31b0cefc --- /dev/null +++ b/packages/code-highlight/babel.config.js @@ -0,0 +1,12 @@ +module.exports = { + plugins: [ + [ + 'prismjs', + { + languages: ['javascript', 'css', 'markup', 'typescript', 'php', 'python'], + theme: 'default', + css: true, + }, + ], + ], +} diff --git a/packages/code-highlight/package.json b/packages/code-highlight/package.json new file mode 100644 index 00000000..4c38ee1c --- /dev/null +++ b/packages/code-highlight/package.json @@ -0,0 +1,27 @@ +{ + "name": "@storipress/code-highlight", + "packageManager": "yarn@3.6.2", + "exports": { + ".": { + "types": "./dist/code-highlight.d.ts", + "import": "./dist/code-highlight.mjs" + } + }, + "scripts": { + "build": "vite build", + "prepack": "yarn build", + "lint": "eslint .", + "release": "yarn run lint && yarn run prepack && changelogen --release && yarn npm publish && git push --follow-tags" + }, + "dependencies": { + "@types/prismjs": "^1.26.0" + }, + "devDependencies": { + "@babel/core": "^7.22.20", + "babel-plugin-prismjs": "^2.1.0", + "changelogen": "0.5.5", + "eslint": "^8.49.0", + "vite": "^4.4.9", + "vite-plugin-babel": "^1.1.3" + } +} diff --git a/packages/code-highlight/public/code-highlight.d.ts b/packages/code-highlight/public/code-highlight.d.ts new file mode 100644 index 00000000..b2699a88 --- /dev/null +++ b/packages/code-highlight/public/code-highlight.d.ts @@ -0,0 +1 @@ +export * from 'prismjs' diff --git a/packages/code-highlight/src/index.js b/packages/code-highlight/src/index.js new file mode 100644 index 00000000..cb4c6fd4 --- /dev/null +++ b/packages/code-highlight/src/index.js @@ -0,0 +1,3 @@ +import Prism from 'prismjs' + +export default Prism diff --git a/packages/code-highlight/vite.config.ts b/packages/code-highlight/vite.config.ts new file mode 100644 index 00000000..03ca1a7f --- /dev/null +++ b/packages/code-highlight/vite.config.ts @@ -0,0 +1,21 @@ +import { defineConfig } from 'vite' +import Babel from 'vite-plugin-babel' + +export default defineConfig({ + build: { + lib: { + entry: './src/index.js', + formats: ['es'], + }, + rollupOptions: { + output: { + assetFileNames: 'code-highlight.css', + }, + }, + }, + plugins: [ + Babel({ + filter: /\.(js|jsx|ts|tsx)$/, + }), + ], +}) diff --git a/packages/karbon/package.json b/packages/karbon/package.json index 5005a05f..2f7066ee 100644 --- a/packages/karbon/package.json +++ b/packages/karbon/package.json @@ -228,4 +228,4 @@ "access": "public" }, "gitHead": "8df1f4d5837a7e2ddbff6cc79f5fec256c34a394" -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 4e96b8d2..42176240 100644 --- a/yarn.lock +++ b/yarn.lock @@ -200,6 +200,29 @@ __metadata: languageName: node linkType: hard +"@babel/core@npm:^7.22.20": + version: 7.22.20 + resolution: "@babel/core@npm:7.22.20" + dependencies: + "@ampproject/remapping": ^2.2.0 + "@babel/code-frame": ^7.22.13 + "@babel/generator": ^7.22.15 + "@babel/helper-compilation-targets": ^7.22.15 + "@babel/helper-module-transforms": ^7.22.20 + "@babel/helpers": ^7.22.15 + "@babel/parser": ^7.22.16 + "@babel/template": ^7.22.15 + "@babel/traverse": ^7.22.20 + "@babel/types": ^7.22.19 + convert-source-map: ^1.7.0 + debug: ^4.1.0 + gensync: ^1.0.0-beta.2 + json5: ^2.2.3 + semver: ^6.3.1 + checksum: 73663a079194b5dc406b2e2e5e50db81977d443e4faf7ef2c27e5836cd9a359e81e551115193dc9b1a93471275351a972e54904f4d3aa6cb156f51e26abf6765 + languageName: node + linkType: hard + "@babel/generator@npm:^7.22.15": version: 7.22.15 resolution: "@babel/generator@npm:7.22.15" @@ -253,6 +276,13 @@ __metadata: languageName: node linkType: hard +"@babel/helper-environment-visitor@npm:^7.22.20": + version: 7.22.20 + resolution: "@babel/helper-environment-visitor@npm:7.22.20" + checksum: d80ee98ff66f41e233f36ca1921774c37e88a803b2f7dca3db7c057a5fea0473804db9fb6729e5dbfd07f4bed722d60f7852035c2c739382e84c335661590b69 + languageName: node + linkType: hard + "@babel/helper-environment-visitor@npm:^7.22.5": version: 7.22.5 resolution: "@babel/helper-environment-visitor@npm:7.22.5" @@ -312,6 +342,21 @@ __metadata: languageName: node linkType: hard +"@babel/helper-module-transforms@npm:^7.22.20": + version: 7.22.20 + resolution: "@babel/helper-module-transforms@npm:7.22.20" + dependencies: + "@babel/helper-environment-visitor": ^7.22.20 + "@babel/helper-module-imports": ^7.22.15 + "@babel/helper-simple-access": ^7.22.5 + "@babel/helper-split-export-declaration": ^7.22.6 + "@babel/helper-validator-identifier": ^7.22.20 + peerDependencies: + "@babel/core": ^7.0.0 + checksum: 8fce25362df8711bd4620f41c5c18769edfeafe7f8f1dae9691966ef368e57f9da68dfa1707cd63c834c89dc4eaa82c26f12ea33e88fd262ac62844b11dcc389 + languageName: node + linkType: hard + "@babel/helper-optimise-call-expression@npm:^7.22.5": version: 7.22.5 resolution: "@babel/helper-optimise-call-expression@npm:7.22.5" @@ -382,6 +427,13 @@ __metadata: languageName: node linkType: hard +"@babel/helper-validator-identifier@npm:^7.22.19, @babel/helper-validator-identifier@npm:^7.22.20": + version: 7.22.20 + resolution: "@babel/helper-validator-identifier@npm:7.22.20" + checksum: 136412784d9428266bcdd4d91c32bcf9ff0e8d25534a9d94b044f77fe76bc50f941a90319b05aafd1ec04f7d127cd57a179a3716009ff7f3412ef835ada95bdc + languageName: node + linkType: hard + "@babel/helper-validator-option@npm:^7.22.15": version: 7.22.15 resolution: "@babel/helper-validator-option@npm:7.22.15" @@ -420,6 +472,15 @@ __metadata: languageName: node linkType: hard +"@babel/parser@npm:^7.22.16": + version: 7.22.16 + resolution: "@babel/parser@npm:7.22.16" + bin: + parser: ./bin/babel-parser.js + checksum: 944c756b5bdeb07b9fec16ecef6b3c61aff9d4c4b924abadcf01afa1840a740b8e2357ae00482b5b37daad6d2bfd848c947f27ad65138d687b6fdc924bc59edd + languageName: node + linkType: hard + "@babel/plugin-syntax-import-meta@npm:^7.10.4": version: 7.10.4 resolution: "@babel/plugin-syntax-import-meta@npm:7.10.4" @@ -512,6 +573,24 @@ __metadata: languageName: node linkType: hard +"@babel/traverse@npm:^7.22.20": + version: 7.22.20 + resolution: "@babel/traverse@npm:7.22.20" + dependencies: + "@babel/code-frame": ^7.22.13 + "@babel/generator": ^7.22.15 + "@babel/helper-environment-visitor": ^7.22.20 + "@babel/helper-function-name": ^7.22.5 + "@babel/helper-hoist-variables": ^7.22.5 + "@babel/helper-split-export-declaration": ^7.22.6 + "@babel/parser": ^7.22.16 + "@babel/types": ^7.22.19 + debug: ^4.1.0 + globals: ^11.1.0 + checksum: 97da9afa7f8f505ce52c36ac2531129bc4a0e250880aaf9b467dc044f30a5bce2b756c1af4d961958bc225659546e811a7d536ab3d920fd60921087989b841b9 + languageName: node + linkType: hard + "@babel/types@npm:^7.21.5, @babel/types@npm:^7.22.15, @babel/types@npm:^7.22.4, @babel/types@npm:^7.22.5, @babel/types@npm:^7.8.3": version: 7.22.15 resolution: "@babel/types@npm:7.22.15" @@ -523,6 +602,17 @@ __metadata: languageName: node linkType: hard +"@babel/types@npm:^7.22.19": + version: 7.22.19 + resolution: "@babel/types@npm:7.22.19" + dependencies: + "@babel/helper-string-parser": ^7.22.5 + "@babel/helper-validator-identifier": ^7.22.19 + to-fast-properties: ^2.0.0 + checksum: 2d69740e69b55ba36ece0c17d5afb7b7213b34297157df39ef9ba24965aff677c56f014413052ecc5b2fbbf26910c63e5bb24a969df84d7a17153750cf75915e + languageName: node + linkType: hard + "@cloudflare/kv-asset-handler@npm:^0.3.0": version: 0.3.0 resolution: "@cloudflare/kv-asset-handler@npm:0.3.0" @@ -3132,6 +3222,20 @@ __metadata: languageName: node linkType: hard +"@storipress/code-highlight@workspace:packages/code-highlight": + version: 0.0.0-use.local + resolution: "@storipress/code-highlight@workspace:packages/code-highlight" + dependencies: + "@babel/core": ^7.22.20 + "@types/prismjs": ^1.26.0 + babel-plugin-prismjs: ^2.1.0 + changelogen: 0.5.5 + eslint: ^8.49.0 + vite: ^4.4.9 + vite-plugin-babel: ^1.1.3 + languageName: unknown + linkType: soft + "@storipress/create-karbon@workspace:packages/create-karbon": version: 0.0.0-use.local resolution: "@storipress/create-karbon@workspace:packages/create-karbon" @@ -3748,6 +3852,13 @@ __metadata: languageName: node linkType: hard +"@types/prismjs@npm:^1.26.0": + version: 1.26.0 + resolution: "@types/prismjs@npm:1.26.0" + checksum: cd5e7a6214c1f4213ec512a5fcf6d8fe37a56b813fc57ac95b5ff5ee074742bfdbd2f2730d9fd985205bf4586728e09baa97023f739e5aa1c9735a7c1ecbd11a + languageName: node + linkType: hard + "@types/qs@npm:^6.5.3": version: 6.9.7 resolution: "@types/qs@npm:6.9.7" @@ -5426,6 +5537,15 @@ __metadata: languageName: node linkType: hard +"babel-plugin-prismjs@npm:^2.1.0": + version: 2.1.0 + resolution: "babel-plugin-prismjs@npm:2.1.0" + peerDependencies: + prismjs: ^1.18.0 + checksum: 8bc59ca46b493cb255ec914e26a0dd39c1aaee881e3701d6726db40152d4a176a96ac1438f80b0d705b188bee4106538de809bc79dff9774400da3d8331affce + languageName: node + linkType: hard + "balanced-match@npm:^1.0.0": version: 1.0.2 resolution: "balanced-match@npm:1.0.2" @@ -8209,7 +8329,7 @@ __metadata: languageName: node linkType: hard -"eslint@npm:8.49.0": +"eslint@npm:8.49.0, eslint@npm:^8.49.0": version: 8.49.0 resolution: "eslint@npm:8.49.0" dependencies: @@ -17652,6 +17772,16 @@ __metadata: languageName: node linkType: hard +"vite-plugin-babel@npm:^1.1.3": + version: 1.1.3 + resolution: "vite-plugin-babel@npm:1.1.3" + peerDependencies: + "@babel/core": ^7.0.0 + vite: ^2.7.0 || ^3.0.0 || ^4.0.0 + checksum: 1d092122bc896de8f0cff7d27c27092a92475823419ad1c57408dd9f5b5886cc10861999de74fe62536689c2c2db144e7f616c48db2c752abc4d7e969b8caa34 + languageName: node + linkType: hard + "vite-plugin-checker@npm:^0.6.1": version: 0.6.2 resolution: "vite-plugin-checker@npm:0.6.2"