Skip to content

Commit b87b44f

Browse files
authored
Disable esModuleInterop and remove unquote dependency (quantizor#426)
1 parent 1824730 commit b87b44f

8 files changed

+33
-18
lines changed

index.compiler.spec.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { compiler } from './index'
2-
import React from 'react'
3-
import ReactDOM from 'react-dom'
4-
import fs from 'fs'
5-
import theredoc from 'theredoc'
2+
import * as React from 'react'
3+
import * as ReactDOM from 'react-dom'
4+
import * as fs from 'fs'
5+
import * as theredoc from 'theredoc'
66

77
const root = document.body.appendChild(
88
document.createElement('div')

index.component.spec.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Markdown from './index'
2-
import React from 'react'
3-
import ReactDOM from 'react-dom'
2+
import * as React from 'react'
3+
import * as ReactDOM from 'react-dom'
44

55
const root = document.body.appendChild(document.createElement('div'))
66

index.tsx

+14-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44
* from Khan Academy. Thank you Khan devs for making such an awesome and extensible
55
* parsing infra... without it, half of the optimizations here wouldn't be feasible. 🙏🏼
66
*/
7-
import React from 'react'
8-
/// <reference path="unquote.d.ts" />
9-
import unquote from 'unquote'
7+
import * as React from 'react'
108

119
export namespace MarkdownToJSX {
1210
/**
@@ -426,6 +424,19 @@ function containsBlockSyntax(input: string) {
426424
return BLOCK_SYNTAXES.some(r => r.test(input))
427425
}
428426

427+
/** Remove symmetrical leading and trailing quotes */
428+
function unquote(str: string) {
429+
const first = str[0]
430+
if (
431+
(first === '"' || first === "'") &&
432+
str.length >= 2 &&
433+
str[str.length - 1] === first
434+
) {
435+
return str.slice(1, -1)
436+
}
437+
return str
438+
}
439+
429440
// based on https://stackoverflow.com/a/18123682/1141611
430441
// not complete, but probably good enough
431442
function slugify(str: string) {

package.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@
6565
"styled-components": "^5.1.1",
6666
"theredoc": "^1.0.0",
6767
"ts-jest": "^27.0.3",
68-
"typescript": "^4.1.3",
69-
"unquote": "^1.1.0"
68+
"typescript": "^4.1.3"
7069
},
7170
"peerDependencies": {
7271
"react": ">= 0.14.0"
@@ -92,6 +91,13 @@
9291
],
9392
"jest": {
9493
"preset": "ts-jest",
94+
"globals": {
95+
"ts-jest": {
96+
"diagnostics": {
97+
"ignoreCodes": ["TS151001"]
98+
}
99+
}
100+
},
95101
"testEnvironment": "jsdom",
96102
"snapshotSerializers": [
97103
"jest-serializer-html"

site.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @jsx React.createElement */
22
import { lighten, rgba } from 'polished'
3-
import React from 'react'
4-
import ReactDOM from 'react-dom'
3+
import * as React from 'react'
4+
import * as ReactDOM from 'react-dom'
55
import styled, { createGlobalStyle, css, CSSProp } from 'styled-components'
66
import Markdown from './'
77

tsconfig.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{
22
"compilerOptions": {
33
"declaration": true,
4-
"esModuleInterop": true,
4+
// Disable because enabling this option can also force consuming libraries to enable it
5+
"esModuleInterop": false,
56
"incremental": true,
67
"jsx": "react",
78
"module": "ESNext",

unquote.d.ts

-3
This file was deleted.

yarn.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -8248,7 +8248,7 @@ universalify@^0.1.0, universalify@^0.1.2:
82488248
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
82498249
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
82508250

8251-
unquote@^1.1.0, unquote@~1.1.1:
8251+
unquote@~1.1.1:
82528252
version "1.1.1"
82538253
resolved "https://registry.yarnpkg.com/unquote/-/unquote-1.1.1.tgz#8fded7324ec6e88a0ff8b905e7c098cdc086d544"
82548254
integrity sha1-j97XMk7G6IoP+LkF58CYzcCG1UQ=

0 commit comments

Comments
 (0)