Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try adding real exportmaps #3826

Closed
  •  
  •  
  •  
96 changes: 49 additions & 47 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -25,51 +25,53 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build:types
- run: npx playwright install --with-deps
- run: npm test

build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run build
- run: |
git add --all && \
git diff-index --cached HEAD --stat --exit-code || \
(echo && echo "The above files changed because the build is not up to date." && echo "Please rebuild Prism." && exit 1)

lint:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js 14.x
uses: actions/setup-node@v3
with:
node-version: 14.x
- run: npm ci
- run: npm run lint:ci

coverage:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Use Node.js 14.x
uses: actions/setup-node@v3
with:
node-version: 14.x
- run: npm ci
- run: npm run regex-coverage
# build:
#
# runs-on: ubuntu-latest
#
# strategy:
# matrix:
# node-version: [18.x, 20.x]
#
# steps:
# - uses: actions/checkout@v3
# - name: Use Node.js ${{ matrix.node-version }}
# uses: actions/setup-node@v3
# with:
# node-version: ${{ matrix.node-version }}
# - run: npm ci
# - run: npm run build
# - run: |
# git add --all && \
# git diff-index --cached HEAD --stat --exit-code || \
# (echo && echo "The above files changed because the build is not up to date." && echo "Please rebuild Prism." && exit 1)

# lint:
#
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v3
# - name: Use Node.js 20.x
# uses: actions/setup-node@v3
# with:
# node-version: 20.x
# - run: npm ci
# - run: npm run lint:ci
#
# coverage:
#
# runs-on: ubuntu-latest
#
# steps:
# - uses: actions/checkout@v3
# - name: Use Node.js 20.x
# uses: actions/setup-node@v3
# with:
# node-version: 20.x
# - run: npm ci
# - run: npm run regex-coverage
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ node_modules

benchmark/remotes/
benchmark/downloads/
components/*.d.ts
prism-core.d.ts
prism.d.ts
69 changes: 68 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,72 @@
# Prism Changelog

## 1.29.0-fix.6 (09/17/2024)

- Add legitimate exportmaps for CDNs like JSPM.io [#5](https://github.com/KonnorRogers/prism-esm/pull/5)

## 1.29.0-fix.5 (09/17/2024)

- Fixed subpath exports for CDNs like JSPM.io and TS errors with regexes. [#4](https://github.com/KonnorRogers/prism-esm/pull/4)

## 1.29.0-fix.2 (11-28-2023)

- Added `.d.ts` types.
- Fixed an issue with script tags.

## 1.29.0-fix.1 (11-26-2023)

- fix: export `Token` in main entrypoint.
- fix: `manual: true` is now the proper default

## 1.29.0-fix.0 (11-26-2023)

- BREAKING_CHANGE: Convert from UMD to ESM.
- BREAKING_CHANGE: The autoloader does not currently work. Will require updates to be ESM compatible.
- BREAKING_CHANGE: Prism is now an instantiable ES6 class instead of a UMD global.
- BREAKING_CHANGE: Components no longer automatically bind to globally scoped Prism instance. Instead, now you import the `loader` and pass in the Prism instance which will add a language to the Prism instance. Like so:

```js
import { Prism } from "prism-esm"
import { loader as haskellLoader } from "prism-esm/components/prism-haskell.js"

const prism = new Prism()
haskellLoader(prism)

// Loaders will check if they've already loaded. If they've been loaded already, they'll no-op.
// To force a language to reload itself, pass in `{ force: true }`. Like so:
haskellLoader(prism, { force: true })
```

- BREAKING_CHANGE: The `manual` flag is no longer read globally. Instead Prism is now a class.

```js
import { Prism } from "prism-esm"
new Prism() // Automatic highlighting enabled by default
new Prism({ manual: true }) // Disable automatic highlighting
```

- BREAKING_CHANGE: `Prism` no longer automatically binds to the global for it's environment. To restore the behavior, do the following:

```js
import { Prism, environment } from "prism-esm"
const prism = new Prism()
environment.Prism = prism
```

- BREAKING_CHANGE: `prism/dependencies.js` has been removed. Instead, `loaders` are now responsible for being idempotent.
- BREAKING_CHANGE: Plugins now export a `Plugin` function to be called on the prism instance. Like so:

```js
import { Prism } from "prism-esm"
import { Plugin as FileHighlightPlugin } from "./plugins/file-highlight/prism-file-highlight.js"

const prism = new Prism()
FileHighlightPlugin(prism)
```

- BREAKING_CHANGE: Token.stringify now requires a `prism` instance as its final parameter.
- BREAKING_CHANGE: for users of older Node / Browser versions, the internal clone function has been replaced with `structuredClone()` a polyfill may be necessary for your environment.

## 1.29.0 (2022-08-23)

### New components
Expand Down Expand Up @@ -3065,4 +3132,4 @@
* Line Numbers
* Show Invisibles
* Show Language
* WebPlatform Docs
* WebPlatform Docs
51 changes: 50 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,52 @@
> [!CAUTION]
> This is a fork of [Prism](https://prismjs.com) intended for ESM.
> Some things will be slightly different.
> This project is not associated with PrismJS.

## Why was this fork made?

I wanted to use Prism in a library, however, being a UMD global, I didn't want to interfere
with other people using the library. I also couldn't get it working with [Web Test Runner]()

## Behaving like the old version

```js
import { Prism, environment } from "prism-esm"

// {manual: false} turns ON automatic highlighting. Automatic highlighting is disabled by default.
const prism = new Prism({ manual: false })

// `environment` is basically `globalThis`. In browsers, it refers to `window`.
environment.Prism = prism
```

## Loading languages

```js
import { Prism } from "prism-esm"
import { loader as RubyLoader } from "prism-esm/components/prism-ruby.js"

const prism = new Prism()
RubyLoader(prism)
```

## Plugins

```js
import { Prism } from "prism-esm"
import { Plugin as Autolinker } from "prism-esm/plugins/autolinker.js"

const prism = new Prism()
Autolinker(prism)
```

## Auto-import languages

This hasn't been set up yet, and probably won't be anytime soon as I currently don't really have a need for it
and there's quite a lot of complexity around load orders.

### END of fork note

# [Prism](https://prismjs.com/)

[![Build Status](https://github.com/PrismJS/prism/workflows/CI/badge.svg)](https://github.com/PrismJS/prism/actions)
Expand Down Expand Up @@ -48,4 +97,4 @@ Prism will run on [almost any browser](https://prismjs.com/#features-full) and N

## Translations

* [简体中文](https://www.awesomes.cn/repo/PrismJS/prism) (if unavailable, see [here](https://deepmind.t-salon.cc/article/113))
* [简体中文](https://www.awesomes.cn/repo/PrismJS/prism) (if unavailable, see [here](https://deepmind.t-salon.cc/article/113))
2 changes: 1 addition & 1 deletion benchmark/benchmark.js → benchmark/benchmark.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -451,4 +451,4 @@ function toArray(value) {
}


runBenchmark(getConfig());
runBenchmark(getConfig());
2 changes: 1 addition & 1 deletion benchmark/config.js → benchmark/config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,4 @@ const config = {
}
};

module.exports = config;
module.exports = config;
3 changes: 1 addition & 2 deletions components.js

Large diffs are not rendered by default.

56 changes: 0 additions & 56 deletions components/index.js

This file was deleted.

Loading
Loading