Skip to content
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

Merged
merged 6 commits into from
Aug 3, 2023

Conversation

ghost
Copy link

@ghost ghost commented Jun 28, 2023

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 to size-limit and npm 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 to module affects the build command (npm run build), such that index.js is no longer output, but index.cjs (for common) and index.module.js (for ES) are output, which in turn affects the size-limit config in package.json (since the output file index.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.

Nicholas Barrow and others added 3 commits June 27, 2023 23:12
Attempting to retry build tests for #498 with most-recent code base.
…e path (to fix working directory issue in github `test` action)
@ghost ghost changed the title Update package.json fix: Update package.json for "type": "module" with updated size-limit tests for index.cjs and index.module.js (replacing index.js) Jun 28, 2023
@@ -23,6 +23,7 @@
"LICENSE",
"README.md"
],
"type": "module",
Copy link
Author

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",
Copy link
Author

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",
Copy link
Author

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).

@ghost
Copy link
Author

ghost commented Jun 28, 2023

@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",
Copy link
Author

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--)

@ghost
Copy link
Author

ghost commented Jul 1, 2023

@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!

@ghost
Copy link
Author

ghost commented Jul 7, 2023

@probablyup any updates on this?

@ghost
Copy link
Author

ghost commented Jul 14, 2023

I can't wait any longer for this; had to switch to a custom solution with react-markdown instead. For anyone else who needs it:

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>
  );
}

@quantizor
Copy link
Owner

Apologies for the delay on this, had to make a few more changes.

@quantizor quantizor enabled auto-merge (squash) August 3, 2023 12:54
Copy link
Owner

@quantizor quantizor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@quantizor quantizor merged commit a03e4ff into quantizor:main Aug 3, 2023
3 checks passed
@ghost ghost deleted the patch-1 branch August 13, 2023 04:34
@ghost
Copy link
Author

ghost commented Aug 13, 2023

@probablyup thanks for getting to this!

marcustisater-kivra added a commit to kivra/toybox that referenced this pull request Oct 23, 2023
[![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
[@&#8203;dependabot](https://togithub.com/dependabot) in
[quantizor/markdown-to-jsx#505
- chore(deps): bump semver from 6.3.0 to 6.3.1 by
[@&#8203;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
[@&#8203;dependabot](https://togithub.com/dependabot) in
[quantizor/markdown-to-jsx#503
-
[#&#8203;379](https://togithub.com/probablyup/markdown-to-jsx/issues/379)
- Allow more custom HTML character codes by
[@&#8203;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
[@&#8203;gusbmurphy](https://togithub.com/gusbmurphy) in
[quantizor/markdown-to-jsx#501
- add option to enforce a space between headings by
[@&#8203;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
[@&#8203;nbarrow-inspire-labs](https://togithub.com/nbarrow-inspire-labs)
in
[quantizor/markdown-to-jsx#500

#### New Contributors

- [@&#8203;brianfryer](https://togithub.com/brianfryer) made their first
contribution in
[quantizor/markdown-to-jsx#502
- [@&#8203;gusbmurphy](https://togithub.com/gusbmurphy) made their first
contribution in
[quantizor/markdown-to-jsx#501
- [@&#8203;insanicly](https://togithub.com/insanicly) made their first
contribution in
[quantizor/markdown-to-jsx#440
-
[@&#8203;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
[@&#8203;Andarist](https://togithub.com/Andarist) in
[quantizor/markdown-to-jsx#492

#### New Contributors

- [@&#8203;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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot use import statement outside a module
3 participants