Skip to content

Commit

Permalink
Reorganize files
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Aug 13, 2021
1 parent 56da82e commit b2dd046
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 16 deletions.
8 changes: 8 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict'

/**
* @typedef {import('./lib/react-markdown.js').ReactMarkdownOptions} Options
* @typedef {import('./lib/ast-to-react.js').Components} Components
*/

module.exports = require('./lib/react-markdown.js')
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
17 changes: 10 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@
"Dennis S <denis.s@svsg.co>",
"Evan Hensleigh <futuraprime@gmail.com>"
],
"types": "src/react-markdown.d.ts",
"main": "src/react-markdown.js",
"types": "index.d.ts",
"main": "index.js",
"unpkg": "react-markdown.min.js",
"files": [
"src/",
"lib/",
"index.d.ts",
"index.js",
"react-markdown.min.js"
],
"dependencies": {
Expand Down Expand Up @@ -123,8 +125,8 @@
},
"scripts": {
"prepack": "npm run build && npm run format",
"build:ts": "rimraf \"{src/**,test/**,}.d.ts\" && tsc && type-coverage",
"build:umd": "esbuild src/react-markdown.js --bundle --minify --target=es2015 --outfile=react-markdown.min.js --global-name=ReactMarkdown --banner:js=\"(function (g, f) {typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = f() : typeof define === 'function' && define.amd ? define([], f) : (g = typeof globalThis !== 'undefined' ? globalThis : g || self, g.ReactMarkdown = f()); }(this, (function () { 'use strict';\" --footer:js=\"return ReactMarkdown;})));\"",
"build:ts": "rimraf \"{lib/**,test/**,*}.d.ts\" && tsc && type-coverage",
"build:umd": "esbuild index.js --bundle --minify --target=es2015 --outfile=react-markdown.min.js --global-name=ReactMarkdown --banner:js=\"(function (g, f) {typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = f() : typeof define === 'function' && define.amd ? define([], f) : (g = typeof globalThis !== 'undefined' ? globalThis : g || self, g.ReactMarkdown = f()); }(this, (function () { 'use strict';\" --footer:js=\"return ReactMarkdown;})));\"",
"build": "run-s build:*",
"format": "remark . -qfo --ignore-pattern test/ && prettier . -w --loglevel warn && xo --fix",
"test": "run-s build format test:coverage",
Expand Down Expand Up @@ -158,7 +160,8 @@
"ignoreCatch": true,
"#": "below is ignored because some proptypes will `any`",
"ignoreFiles": [
"src/react-markdown.d.ts"
"lib/react-markdown.d.ts",
"index.d.ts"
]
},
"prettier": {
Expand All @@ -179,7 +182,7 @@
"overrides": [
{
"files": [
"src/**/*.js"
"lib/**/*.js"
],
"extends": [
"plugin:es/restrict-to-es2015",
Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ abide by its terms.

[cm-html]: https://spec.commonmark.org/0.29/#html-blocks

[uri]: https://github.com/remarkjs/react-markdown/blob/main/src/uri-transformer.js
[uri]: https://github.com/remarkjs/react-markdown/blob/main/lib/uri-transformer.js

[security]: #security

Expand Down
15 changes: 8 additions & 7 deletions test/test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const gfm = require('remark-gfm')
const visit = require('unist-util-visit')
const ReactDom = require('react-dom/server')
const raw = require('rehype-raw')
const Markdown = require('../src/react-markdown.js')
const Markdown = require('../index.js')
const toc = require('remark-toc')

const own = {}.hasOwnProperty
Expand All @@ -19,7 +19,7 @@ const own = {}.hasOwnProperty
* @typedef {import('hast').Element} Element
* @typedef {import('hast').Text} Text
* @typedef {import('react').ReactNode} ReactNode
* @typedef {import('../src/ast-to-react').Components} Components
* @typedef {import('../index.js').Components} Components
*/

/**
Expand All @@ -39,7 +39,7 @@ test('should warn when passed `source`', () => {
/** @type {unknown} */
let message

console.warn = (d) => {
console.warn = (/** @type {unknown} */ d) => {
message = d
}

Expand All @@ -59,7 +59,7 @@ test('should warn when passed non-string children (number)', () => {
let message

console.error = () => {}
console.warn = (d) => {
console.warn = (/** @type {unknown} */ d) => {
message = d
}

Expand All @@ -80,7 +80,7 @@ test('should warn when passed non-string children (boolean)', () => {
let message

console.error = () => {}
console.warn = (d) => {
console.warn = (/** @type {unknown} */ d) => {
message = d
}

Expand Down Expand Up @@ -110,7 +110,7 @@ test('should warn when passed `allowDangerousHtml`', () => {
/** @type {unknown} */
let message

console.warn = (d) => {
console.warn = (/** @type {unknown} */ d) => {
message = d
}

Expand Down Expand Up @@ -1067,6 +1067,7 @@ test('should pass index of a node under its parent to components if `includeElem
* @param {object} props
* @param {Element} props.node
* @param {ReactNode[]} props.children
* @param {number} [props.index]
*/
const p = ({node, ...otherProps}) => {
assert.equal(typeof otherProps.index === 'number', true)
Expand All @@ -1082,7 +1083,7 @@ test('should pass index of a node under its parent to components if `includeElem
test('should be able to render components with forwardRef in HOC', () => {
/**
* @typedef {import('react').Ref<HTMLAnchorElement>} Ref
* @typedef {JSX.IntrinsicElements['a'] & import('../src/ast-to-react').ReactMarkdownProps} Props
* @typedef {JSX.IntrinsicElements['a'] & import('../lib/ast-to-react').ReactMarkdownProps} Props
*/

/**
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"include": ["*.js", "src/**.js", "test/**.js"],
"include": ["lib/**.js", "test/**.jsx", "index.js"],
"exclude": ["**/*.min.js"],
"compilerOptions": {
"target": "ES2015",
Expand Down

0 comments on commit b2dd046

Please sign in to comment.