From 29b3cf92586e8536a33f9414427a46a274438737 Mon Sep 17 00:00:00 2001 From: Not Existing <61290107+N0tExisting@users.noreply.github.com> Date: Fri, 14 Jan 2022 18:59:19 +0100 Subject: [PATCH 1/7] fix: Convert package to module, fixes #1 This pr fixes #1 by converting the package to an esm only package. --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 852938f..215658c 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "name": "remark-torchlight", "version": "0.0.2", "description": "A remark plugin for Torchlight - the syntax highlighting API.", - "main": "index.js", + "module": "index.js", + "type": "module", "scripts": { "test": "standard --env jest && jest" }, From 21a31e0a79f84cfec9392efbacf1f3080bc92ca2 Mon Sep 17 00:00:00 2001 From: Not Existing <61290107+N0tExisting@users.noreply.github.com> Date: Fri, 14 Jan 2022 19:01:03 +0100 Subject: [PATCH 2/7] chore: bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 215658c..21fb07f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "remark-torchlight", - "version": "0.0.2", + "version": "0.0.3", "description": "A remark plugin for Torchlight - the syntax highlighting API.", "module": "index.js", "type": "module", From c105482937658d3e5343d84473e8686769435b65 Mon Sep 17 00:00:00 2001 From: Not Existing <61290107+N0tExisting@users.noreply.github.com> Date: Fri, 14 Jan 2022 19:20:58 +0100 Subject: [PATCH 3/7] fix: Import correctly (hopefully) --- index.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 4521d39..32726e2 100755 --- a/index.js +++ b/index.js @@ -1,8 +1,9 @@ import parse5 from 'parse5' import { map } from 'unist-util-map' import { fromParse5 } from 'hast-util-from-parse5' - -import { torchlight, Block } from '@torchlight-api/torchlight-cli' +// work arround nodejs weird cjs importing behavoir +import tlCLI from '@torchlight-api/torchlight-cli' +const { torchlight, Block } = tlCLI export default function plugin (options = {}) { torchlight.init(options.config) From ead19215553e89f7c42d02d7be9e36eebe836e2e Mon Sep 17 00:00:00 2001 From: Not Existing <61290107+N0tExisting@users.noreply.github.com> Date: Fri, 14 Jan 2022 19:23:29 +0100 Subject: [PATCH 4/7] fix: use `exports` field --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 21fb07f..c79ff18 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "remark-torchlight", "version": "0.0.3", "description": "A remark plugin for Torchlight - the syntax highlighting API.", - "module": "index.js", + "exports": "index.js", "type": "module", "scripts": { "test": "standard --env jest && jest" From e722dc1c4997e46b1ce23c181340ba68a8e97487 Mon Sep 17 00:00:00 2001 From: Not Existing <61290107+N0tExisting@users.noreply.github.com> Date: Fri, 14 Jan 2022 19:34:41 +0100 Subject: [PATCH 5/7] fix: targets must start with `./` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c79ff18..d8c2538 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "remark-torchlight", "version": "0.0.3", "description": "A remark plugin for Torchlight - the syntax highlighting API.", - "exports": "index.js", + "exports": "./index.js", "type": "module", "scripts": { "test": "standard --env jest && jest" From 0fd0e435c012aa4cc50bab4cc01f30a2e15247ea Mon Sep 17 00:00:00 2001 From: Not Existing <61290107+N0tExisting@users.noreply.github.com> Date: Fri, 14 Jan 2022 19:42:46 +0100 Subject: [PATCH 6/7] fix: change import again to match torchlight-api/torchlight-cli#3 --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 32726e2..4521d39 100755 --- a/index.js +++ b/index.js @@ -1,9 +1,8 @@ import parse5 from 'parse5' import { map } from 'unist-util-map' import { fromParse5 } from 'hast-util-from-parse5' -// work arround nodejs weird cjs importing behavoir -import tlCLI from '@torchlight-api/torchlight-cli' -const { torchlight, Block } = tlCLI + +import { torchlight, Block } from '@torchlight-api/torchlight-cli' export default function plugin (options = {}) { torchlight.init(options.config) From 0ed20ce8888f74afd613bd5df12dd532c30b249c Mon Sep 17 00:00:00 2001 From: Not Existing <61290107+N0tExisting@users.noreply.github.com> Date: Sat, 15 Jan 2022 15:06:33 +0100 Subject: [PATCH 7/7] Fix tests --- tests/__snapshots__/render.test.js.snap | 2 +- tests/render.test.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/__snapshots__/render.test.js.snap b/tests/__snapshots__/render.test.js.snap index 96fe56e..a30e33f 100644 --- a/tests/__snapshots__/render.test.js.snap +++ b/tests/__snapshots__/render.test.js.snap @@ -2,6 +2,6 @@ exports[`it tests 1`] = ` "
this is test
-highlighted
+highlighted
"
`;
diff --git a/tests/render.test.js b/tests/render.test.js
index 50c6ba4..3b983f7 100644
--- a/tests/render.test.js
+++ b/tests/render.test.js
@@ -1,4 +1,4 @@
-import torchlight from '../index'
+import torchlight from '../index.js'
import { remark } from 'remark'
import html from 'remark-html'
import {mockApi} from '@torchlight-api/torchlight-cli/tests/support/helpers'