From 825e9ed7fd68ad78b669cbb4e333ab4186b6512b Mon Sep 17 00:00:00 2001 From: Not Existing <61290107+N0tExisting@users.noreply.github.com> Date: Fri, 14 Jan 2022 19:26:20 +0100 Subject: [PATCH 1/3] fix: add `"type": "module"` & use `exports` field also bump version --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a15a001..bca9cdb 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,9 @@ { "name": "@torchlight-api/torchlight-cli", - "version": "0.1.2", + "version": "0.1.3", "description": "A CLI for Torchlight - the syntax highlighting API", - "main": "index.js", + "type": "module", + "exports": "index.js", "scripts": { "test": "standard --env jest && jest", "build": "babel src --out-dir lib --copy-files \"--ignore\" \"src/stubs/**/*\"" From 374e51fe71e9ececca53a0efdc5741da884c3f53 Mon Sep 17 00:00:00 2001 From: Not Existing <61290107+N0tExisting@users.noreply.github.com> Date: Fri, 14 Jan 2022 19:34:31 +0100 Subject: [PATCH 2/3] fix: targets must start with `./` --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bca9cdb..0ab2d7d 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.3", "description": "A CLI for Torchlight - the syntax highlighting API", "type": "module", - "exports": "index.js", + "exports": "./index.js", "scripts": { "test": "standard --env jest && jest", "build": "babel src --out-dir lib --copy-files \"--ignore\" \"src/stubs/**/*\"" From f3f53efe80b3505ff04caf0e049786f45b7afe88 Mon Sep 17 00:00:00 2001 From: Not Existing <61290107+N0tExisting@users.noreply.github.com> Date: Sat, 15 Jan 2022 14:42:27 +0100 Subject: [PATCH 3/3] fix: Add `.js` ext to imports --- index.js | 4 ++-- src/bin/torchlight.js | 2 +- src/block.js | 4 ++-- src/cli.js | 10 +++++----- src/commands/highlight.js | 8 ++++---- src/commands/init.js | 2 +- src/config.js | 4 ++-- src/torchlight.js | 4 ++-- tests/highlight.test.js | 6 +++--- tests/support/helpers.js | 6 +++--- 10 files changed, 25 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index 7aeb2f9..ca451a0 100755 --- a/index.js +++ b/index.js @@ -1,5 +1,5 @@ -import torchlight from './src/torchlight' -import Block from './src/block' +import torchlight from './src/torchlight.js' +import Block from './src/block.js' export { torchlight, diff --git a/src/bin/torchlight.js b/src/bin/torchlight.js index 10ac0e5..2359fe6 100755 --- a/src/bin/torchlight.js +++ b/src/bin/torchlight.js @@ -1,4 +1,4 @@ #! /usr/bin/env node -import { makeProgram } from '../cli' +import { makeProgram } from '../cli.js' makeProgram().parse() diff --git a/src/block.js b/src/block.js index 9e3e8d4..7ba4497 100644 --- a/src/block.js +++ b/src/block.js @@ -1,6 +1,6 @@ import md5 from 'md5' -import guid from './support/guid' -import torchlight from './torchlight' +import guid from './support/guid.js' +import torchlight from './torchlight.js' export default function Block (opts = {}) { opts = { diff --git a/src/cli.js b/src/cli.js index 085e826..886c171 100644 --- a/src/cli.js +++ b/src/cli.js @@ -1,9 +1,9 @@ import { program } from 'commander' -import torchlight from './torchlight' -import highlight from './commands/highlight' -import init from './commands/init' -import cacheClear from './commands/cache/clear' -import { makeConfig, makeCache } from './config' +import torchlight from './torchlight.js' +import highlight from './commands/highlight.js' +import init from './commands/init.js' +import cacheClear from './commands/cache/clear.js' +import { makeConfig, makeCache } from './config.js' /** * Configure the commander CLI application. diff --git a/src/commands/highlight.js b/src/commands/highlight.js index ae62cc6..d9036c3 100644 --- a/src/commands/highlight.js +++ b/src/commands/highlight.js @@ -1,11 +1,11 @@ import path from 'path' -import torchlight from '../torchlight' -import Block from '../block' +import torchlight from '../torchlight.js' +import Block from '../block.js' import cheerio from 'cheerio' import chokidar from 'chokidar' -import log from '../support/log' +import log from '../support/log.js' import fs from 'fs-extra' -import { bus, FILE_WATCHING_COMPLETE } from '../support/bus' +import { bus, FILE_WATCHING_COMPLETE } from '../support/bus.js' export default function (torchlight, options) { options = { diff --git a/src/commands/init.js b/src/commands/init.js index 1e188c8..ce36a3c 100644 --- a/src/commands/init.js +++ b/src/commands/init.js @@ -1,7 +1,7 @@ import fs from 'fs-extra' import path from 'path' import inquirer from 'inquirer' -import log from '../support/log' +import log from '../support/log.js' function write (location) { const source = path.resolve(path.join(__dirname, '../stubs/config.js')) diff --git a/src/config.js b/src/config.js index 044581d..76cfbeb 100644 --- a/src/config.js +++ b/src/config.js @@ -1,7 +1,7 @@ import fs from 'fs-extra' import path from 'path' -import FileCache from './cache/file' -import MemoryCache from './cache/memory' +import FileCache from './cache/file.js' +import MemoryCache from './cache/memory.js' /** * @param {string|object} config diff --git a/src/torchlight.js b/src/torchlight.js index 913d046..0a9a443 100644 --- a/src/torchlight.js +++ b/src/torchlight.js @@ -2,8 +2,8 @@ import axios from 'axios' import md5 from 'md5' import get from 'lodash.get' import chunk from 'lodash.chunk' -import log from './support/log' -import MemoryCache from './cache/memory' +import log from './support/log.js' +import MemoryCache from './cache/memory.js' /** * @constructor diff --git a/tests/highlight.test.js b/tests/highlight.test.js index d4952de..966196d 100644 --- a/tests/highlight.test.js +++ b/tests/highlight.test.js @@ -1,6 +1,6 @@ -import torchlight from '../src/torchlight'; -import {mockApi, fixture} from './support/helpers'; -import log from '../src/support/log'; +import torchlight from '../src/torchlight.js'; +import {mockApi, fixture} from './support/helpers.js'; +import log from '../src/support/log.js'; process.env.TORCHLIGHT_TOKEN = 'test' diff --git a/tests/support/helpers.js b/tests/support/helpers.js index 2bf6bd2..2de5bed 100644 --- a/tests/support/helpers.js +++ b/tests/support/helpers.js @@ -1,7 +1,7 @@ -import { bus, FILE_WATCHING_COMPLETE } from '../../src/support/bus' -import { testCli } from '../../src/cli' import { readFileSync } from 'fs-extra' -import torchlight from '../../src/torchlight' +import { bus, FILE_WATCHING_COMPLETE } from '../../src/support/bus.js' +import { testCli } from '../../src/cli.js' +import torchlight from '../../src/torchlight.js' function fixture (file, callback, options = {}) { options = {