-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
fix: Update package.json for "type": "module" with updated size-limit
tests for index.cjs
and index.module.js
(replacing index.js
)
#500
Conversation
Attempting to retry build tests for #498 with most-recent code base.
…e path (to fix working directory issue in github `test` action)
…arated module and `.cjs` files
size-limit
tests for index.cjs
and index.module.js
(replacing index.js
)
@@ -23,6 +23,7 @@ | |||
"LICENSE", | |||
"README.md" | |||
], | |||
"type": "module", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Original change suggested in #498.
@@ -88,7 +89,11 @@ | |||
}, | |||
"size-limit": [ | |||
{ | |||
"path": "dist/index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing type
to module
affects the build
command in package.json
, such that index.js
is no longer built to ./dist
, but a common js file (index.cjs
) and an ES script file (index.module.js
) are output instead, so new tests are needed to replace this one (see below).
"limit": "6 kB" | ||
}, | ||
{ | ||
"path": "./dist/index.module.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new tests reflect the new output files (index.cjs
and index.module.js
which replace the old output/built file index.js
by setting type
to module
).
@probablyup now that these tests are building, could you take a look at this fix for #495 and possibly close #498 (as this would fix the build issues experienced in #498). This PR and #498 do the exact same functional changes, this just fixes the build tests as well. |
} | ||
}, | ||
"main": "dist/index.js", | ||
"main": "dist/index.cjs", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updating main
based on the build manager, microbundle
's, instructions (https://github.com/developit/microbundle#-installation--setup--)
@probablyup any chance you could take a look at this? It's causing our build pipeline to fail and I'd love to get it working. Thanks! |
@probablyup any updates on this? |
I can't wait any longer for this; had to switch to a custom solution with import React from "react";
import { default as ReactMarkdown } from "react-markdown";
import {
Link,
List,
ListItem,
ListItemText,
Paper,
Table,
TableBody,
TableCell,
TableContainer,
TableRow,
Typography,
useTheme,
} from "@mui/material";
import remarkGfm from "remark-gfm";
import { default as SyntaxHighlighter } from "react-syntax-highlighter";
import {
tomorrow as lightHighlightStyle,
tomorrowNight as darkHighlightStyle,
} from "react-syntax-highlighter/dist/cjs/styles/hljs";
import GlobalStyles from "@mui/material/GlobalStyles";
export default function Markdown({ markdown }: { markdown: string; }) {
const theme = useTheme();
return (
<ReactMarkdown
remarkPlugins={[remarkGfm]}
components={{
// *********
// * Links *
// *********
a: ({ href, title, children }) => (<Link href={href} underline={"always"}>{children}</Link>),
// ********
// * Text *
// ********
p: ({ children }) => (<Typography sx={{ mt: 1 }}>{children}</Typography>),
del: ({ children }) => (<Typography sx={{ mt: 1, textDecoration: "line-through" }}>{children}</Typography>),
em: ({ children }) => (<Typography sx={{ mt: 1, fontStyle: "italic" }}>{children}</Typography>),
strong: ({ children }) => (<Typography sx={{ mt: 1, fontWeight: "bold" }}>{children}</Typography>),
b: ({ children }) => (<Typography sx={{ mt: 1, fontWeight: "bold" }}>{children}</Typography>),
h1: ({ children }) => (<Typography gutterBottom sx={{ mt: 2 }} variant={"h1"}>{children}</Typography>),
h2: ({ children }) => (<Typography gutterBottom sx={{ mt: 2 }} variant={"h2"}>{children}</Typography>),
h3: ({ children }) => (<Typography gutterBottom sx={{ mt: 2 }} variant={"h3"}>{children}</Typography>),
h4: ({ children }) => (<Typography gutterBottom sx={{ mt: 2 }} variant={"h4"}>{children}</Typography>),
h5: ({ children }) => (<Typography gutterBottom sx={{ mt: 2 }} variant={"h5"}>{children}</Typography>),
h6: ({ children }) => (<Typography gutterBottom sx={{ mt: 2 }} variant={"h6"}>{children}</Typography>),
// **********
// * Tables *
// **********
table: ({ children }) => (<TableContainer component={Paper} sx={{ mt: 2 }}>
<Table size="small">{children}</Table>
</TableContainer>),
tbody: ({ children }) => (<TableBody>{children}</TableBody>),
// th: ({ children }) => (<TableHead>{children}</TableHead>),
tr: ({ children }) => (<TableRow>{children}</TableRow>),
td: ({ children }) => (<TableCell><Typography>{children}</Typography></TableCell>),
// *********
// * Lists *
// *********
ol: ({ children }) => (<List sx={{
listStyleType: "decimal",
mt: 2,
pl: 2,
"& .MuiListItem-root": {
display: "list-item",
},
}}>{children}</List>),
ul: ({ children }) => (<List sx={{
listStyleType: "disc",
mt: 2,
pl: 2,
"& .MuiListItem-root": {
display: "list-item",
},
}}>{children}</List>),
li: ({ children, ...props }) => (
<ListItem sx={{ m: 0, p: 0, ml: 2 }} disableGutters {...props}><ListItemText
sx={{ pl: 0.25 }}>{children}</ListItemText></ListItem>),
// ********
// * Code *
// ********
code: ({ node, inline, className, children, ...props }) => {
const match = /language-(\w+)/.exec(className || "");
return (
<>
<GlobalStyles styles={{ code: { color: "inherit", background: "transparent" } }} />
<SyntaxHighlighter
style={theme.palette.mode === "light" ? lightHighlightStyle : darkHighlightStyle}
language={match ? match[1] : undefined}
PreTag="div"
>
{String(children).replace(/\n$/, "")}
</SyntaxHighlighter>
</>
);
},
}}
>
{markdown}
</ReactMarkdown>
);
} |
Apologies for the delay on this, had to make a few more changes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
@probablyup thanks for getting to this! |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [markdown-to-jsx](https://probablyup.github.io/markdown-to-jsx) ([source](https://togithub.com/probablyup/markdown-to-jsx)) | [`7.2.0` -> `7.3.2`](https://renovatebot.com/diffs/npm/markdown-to-jsx/7.2.0/7.3.2) | [![age](https://developer.mend.io/api/mc/badges/age/npm/markdown-to-jsx/7.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/markdown-to-jsx/7.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/markdown-to-jsx/7.2.0/7.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/markdown-to-jsx/7.2.0/7.3.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>probablyup/markdown-to-jsx (markdown-to-jsx)</summary> ### [`v7.3.2`](https://togithub.com/probablyup/markdown-to-jsx/releases/tag/v7.3.2) [Compare Source](https://togithub.com/probablyup/markdown-to-jsx/compare/v7.3.1...v7.3.2) fix(types): path to esm types in "exports" **Full Changelog**: quantizor/markdown-to-jsx@v7.3.1...v7.3.2 ### [`v7.3.1`](https://togithub.com/probablyup/markdown-to-jsx/releases/tag/v7.3.1) [Compare Source](https://togithub.com/probablyup/markdown-to-jsx/compare/v7.3.0...v7.3.1) #### What's Changed - add dev-time error if trying to provide bad input **Full Changelog**: quantizor/markdown-to-jsx@v7.3.0...v7.3.1 ### [`v7.3.0`](https://togithub.com/probablyup/markdown-to-jsx/releases/tag/v7.3.0) [Compare Source](https://togithub.com/probablyup/markdown-to-jsx/compare/v7.2.1...v7.3.0) #### What's Changed - chore(deps): bump word-wrap from 1.2.3 to 1.2.4 by [@​dependabot](https://togithub.com/dependabot) in [quantizor/markdown-to-jsx#505 - chore(deps): bump semver from 6.3.0 to 6.3.1 by [@​dependabot](https://togithub.com/dependabot) in [quantizor/markdown-to-jsx#504 - chore(deps): bump tough-cookie from 4.1.2 to 4.1.3 by [@​dependabot](https://togithub.com/dependabot) in [quantizor/markdown-to-jsx#503 - [#​379](https://togithub.com/probablyup/markdown-to-jsx/issues/379) - Allow more custom HTML character codes by [@​brianfryer](https://togithub.com/brianfryer) in [quantizor/markdown-to-jsx#502 - fix: correctly parse markdown inside of a table row when a preceding column has nested HTML elements by [@​gusbmurphy](https://togithub.com/gusbmurphy) in [quantizor/markdown-to-jsx#501 - add option to enforce a space between headings by [@​insanicly](https://togithub.com/insanicly) in [quantizor/markdown-to-jsx#440 - fix: Update package.json for "type": "module" with updated `size-limit` tests for `index.cjs` and `index.module.js` (replacing `index.js`) by [@​nbarrow-inspire-labs](https://togithub.com/nbarrow-inspire-labs) in [quantizor/markdown-to-jsx#500 #### New Contributors - [@​brianfryer](https://togithub.com/brianfryer) made their first contribution in [quantizor/markdown-to-jsx#502 - [@​gusbmurphy](https://togithub.com/gusbmurphy) made their first contribution in [quantizor/markdown-to-jsx#501 - [@​insanicly](https://togithub.com/insanicly) made their first contribution in [quantizor/markdown-to-jsx#440 - [@​nbarrow-inspire-labs](https://togithub.com/nbarrow-inspire-labs) made their first contribution in [quantizor/markdown-to-jsx#500 **Full Changelog**: quantizor/markdown-to-jsx@v7.2.1...v7.3.0 ### [`v7.2.1`](https://togithub.com/probablyup/markdown-to-jsx/releases/tag/v7.2.1) [Compare Source](https://togithub.com/probablyup/markdown-to-jsx/compare/v7.2.0...v7.2.1) #### What's Changed - fix: move `types` condition to the front by [@​Andarist](https://togithub.com/Andarist) in [quantizor/markdown-to-jsx#492 #### New Contributors - [@​Andarist](https://togithub.com/Andarist) made their first contribution in [quantizor/markdown-to-jsx#492 **Full Changelog**: quantizor/markdown-to-jsx@v7.2.0...v7.2.1 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "before 4am on Monday" (UTC), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/kivra/toybox). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNi40My4yIiwidXBkYXRlZEluVmVyIjoiMzYuNDMuMiIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Marcus Tisäter <77273035+marcustisater-kivra@users.noreply.github.com>
Closes #498
Fixes #495
This would fix #495. This PR specifically is attempting to retry build tests for #498 with most-recent code base, as well as updating the tests run in
package.json
relating tosize-limit
andnpm run size
.The issues with #498 are solely related to the github action not being able to find index.js. It looks like changing
type
tomodule
affects the build command (npm run build
), such thatindex.js
is no longer output, butindex.cjs
(for common) andindex.module.js
(for ES) are output, which in turn affects thesize-limit
config inpackage.json
(since the output fileindex.js
that the test--npm run size
--builds on no longer exists). Updating this test, and including the original change from @greypants in #498, now passes all tests successfully.This would finally fix the
Cannot use import statement outside a module
error originally noted in #495 with 100% passing tests.