aanckar / react-pdf-tailwind

Use Tailwind CSS to style PDFs created with react-pdf
315 stars 11 forks source link

Build issue #6

Closed hwb15 closed 1 year ago

hwb15 commented 1 year ago

Hi!

I'm trying to change up the way the createTw module is exported so I can use it within the react-pdf-repl although can't seem to get a build done?

Getting the following issue, any ideas would be much appreciated?

src/index.ts → dist/index.js, dist/index.mjs... [!] (plugin esbuild) Error: Transform failed with 1 error: /Users/user/Code/react-pdf-tailwind/node_modules/esbuild/lib/main.js:244:12: ERROR: Invalid option in transform() call: "bundle"

hwb15 commented 1 year ago

Sorted by rewriting the rollup.config to:

import esbuild from "rollup-plugin-esbuild";
const pkg = require("./package.json");

const name = pkg.main.replace(/\.js$/, "");

export default [
  {
    input: "src/index.ts",
    external: [
      ...Object.keys(pkg.dependencies || {}),
      ...Object.keys(pkg.peerDependencies || {}),
    ],
    plugins: [
      esbuild({
        include: /\.ts?$/,
        target: "es2017",
      }),
    ],
    output: [
      {
        file: `${name}.js`,
        format: "cjs",
        sourcemap: true,
      },
      {
        file: `${name}.mjs`,
        format: "es",
        sourcemap: true,
      },
    ],
  },
  {
    input: "src/index.ts",
    plugins: [dts()],
    output: {
      file: `${name}.d.ts`,
      format: "es",
    },
  },
];
aanckar commented 1 year ago

Hi, I just published a new version of this package, where I updated some dependencies and the build process as well (among other things, I removed the apparently now deprecated bundle option from esbuild). Could you check if the update works for you (without changing the rollup config)?

hwb15 commented 1 year ago

Hi @aanckar, I'll test it now - I was going to fork the repo and make changes to the export of createTw so it works within the react-pdf-repl, it needs to be a named export instead of export default to work with the repl (https://github.com/jeetiss/react-pdf-repl)

hwb15 commented 1 year ago

Hi, I just published a new version of this package, where I updated some dependencies and the build process as well (among other things, I removed the apparently now deprecated bundle option from esbuild). Could you check if the update works for you (without changing the rollup config)?

Works as expected now and allows building, I've made the changes to the export and also works great just needs to be imported as: import { createTw} from 'react-pdf-tailwind'