tatethurston / nextjs-routes

Type safe routing for Next.js
MIT License
557 stars 21 forks source link

use `tsup` for bundling instead of `webpack` #121

Closed ckt1031 closed 1 year ago

ckt1031 commented 1 year ago

And also fixed serval bugs:

Changes:

const { withRoutes } = require("nextjs-routes/config");
// CJS tsup doesn't support default export, so it will be changed like this

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  typescript: {
    ignoreBuildErrors: true,
  },
};

module.exports = withRoutes()(nextConfig);
ckt1031 commented 1 year ago

Prettier isn't running well currently, you can format the code before merging to the main branch.

tatethurston commented 1 year ago

Hi @cktsun1031 thank you for contributing. Could you talk through these proposed changes a bit more?

transformation, so you don't have to config tsc and webpack-cli

This project uses tsc and webpack. What advantages does moving to tsup bring? tsc will still be required for typechecking, so this would be a substitution of webpack for tsup, netting the same project dependencies.

E2E are not using local packages, it uses production version from npm, so the tests are redundant because of that, but now it uses local's one

This is not true. This project uses pnpm workspaces, which installs the local packages. You can read more about this here https://pnpm.io/workspaces.

tatethurston commented 1 year ago

The change to withRoutes from a default export to a named export is a breaking change.

ckt1031 commented 1 year ago

Unfortunately, my machine installed the remote version instead of the local one, idk whether it's my issue or not

ckt1031 commented 1 year ago

The main advantage is that you can use the single cli command to bundle and export two both CJS and ESM formats, it also does bundling like solving json imports and automatically dts exporting, tsup does type checking before finishing the building.

ckt1031 commented 1 year ago

You can ignore 😓 this PR if you want to stay in webpack, tsc bundling instead of tsup.