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

Adds postcss-import plugin + fixes import for react phone styles #456

Merged
merged 8 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cuddly-starfishes-own.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@turnkey/sdk-react": patch
---

Fix build issues with React 19+ & NextJs 15+
13 changes: 7 additions & 6 deletions packages/sdk-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,22 @@
"@mui/material": "^6.1.5",
"@noble/hashes": "1.4.0",
"@react-oauth/google": "^0.12.1",
"@turnkey/sdk-browser": "workspace:*",
"@turnkey/wallet-stamper": "workspace:*",
"@turnkey/crypto": "workspace:*",
"@turnkey/sdk-browser": "workspace:*",
"@turnkey/sdk-server": "workspace:*",
"usehooks-ts": "^3.1.0",
"@turnkey/wallet-stamper": "workspace:*",
"libphonenumber-js": "^1.11.14",
"next": "^15.0.2",
"react-apple-login": "^1.1.6",
"react-international-phone": "^4.3.0"
"react-international-phone": "^4.3.0",
"usehooks-ts": "^3.1.0"
},
"peerDependencies": {
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
"@types/react": "^18.2.75"
},
"devDependencies": {
"@types/react": "^18.2.75",
"postcss-import": "^16.1.0",
"react": "^18.2.0"
},
"engines": {
Expand Down
69 changes: 39 additions & 30 deletions packages/sdk-react/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,47 +1,54 @@
import typescript from "@rollup/plugin-typescript";
import nodeExternals from "rollup-plugin-node-externals";
import path from "node:path";
import postcss from "rollup-plugin-postcss";
import preserveDirectives from "rollup-preserve-directives";
import url from "@rollup/plugin-url";
import alias from "@rollup/plugin-alias";
import copy from "rollup-plugin-copy";
import typescript from '@rollup/plugin-typescript';
import nodeExternals from 'rollup-plugin-node-externals';
Copy link
Collaborator

Choose a reason for hiding this comment

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

would expect these to be double quotes

Copy link
Contributor

Choose a reason for hiding this comment

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

from all the package READMES it shows single quotes actually. It seems like we were incorrect before

import path from 'node:path';
import postcss from 'rollup-plugin-postcss';
import preserveDirectives from 'rollup-preserve-directives';
import url from '@rollup/plugin-url';
import alias from '@rollup/plugin-alias';
import copy from 'rollup-plugin-copy';
import postcssImport from 'postcss-import';

const getFormatConfig = (format) => {
const pkgPath = path.join(process.cwd(), "package.json");
const pkgPath = path.join(process.cwd(), 'package.json');
const __dirname = path.dirname(new URL(import.meta.url).pathname);

return {
input: 'src/index.ts',
output: {
format,
dir: "dist",
dir: 'dist',
entryFileNames: `[name].${format === 'esm' ? 'mjs' : 'js'}`,
preserveModules: true,
sourcemap: true,
},
plugins: [
alias({ // required for svg assets
alias({
// required for svg assets
entries: [
{ find: 'assets', replacement: path.resolve(__dirname, 'src/assets') }
]
{
find: 'assets',
replacement: path.resolve(__dirname, 'src/assets'),
},
],
}),
postcss({ // required for css module bundling
postcss({
// required for css module bundling
modules: true,
extensions: ['.css', '.scss'],
use: ['sass'],
extract: `styles.${format}.css`,
minimize: true,
sourceMap: true,
plugins: [postcssImport()],
}),
typescript({
outputToFilesystem: true,
tsconfig: './tsconfig.json',
compilerOptions: {
outDir: "dist",
outDir: 'dist',
composite: false,
declaration: format === 'esm',
declarationMap: format === "esm",
declarationMap: format === 'esm',
sourceMap: true,
},
}),
Expand All @@ -50,29 +57,31 @@ const getFormatConfig = (format) => {
packagePath: pkgPath,
builtinsPrefix: 'ignore',
}),
url({ // required for fonts and assets
url({
// required for fonts and assets
include: [
'**/*.svg',
'**/*.png',
'**/*.jpg',
'**/*.svg',
'**/*.png',
'**/*.jpg',
'**/*.gif',
'**/*.woff',
'**/*.woff2',
'**/*.ttf',
'**/*.eot'
'**/*.woff',
'**/*.woff2',
'**/*.ttf',
'**/*.eot',
],
limit: 8192,
emitFiles: true,
fileName: 'assets/fonts/[name].[hash][extname]',
emitFiles: true,
fileName: 'assets/fonts/[name].[hash][extname]',
}),
copy({ // required for fonts
copy({
// required for fonts
targets: [
{
src: path.resolve(__dirname, "src/assets/fonts/**/*"),
dest: path.resolve(__dirname, "dist/assets/fonts"),
src: path.resolve(__dirname, 'src/assets/fonts/**/*'),
dest: path.resolve(__dirname, 'dist/assets/fonts'),
},
],
verbose: false,
verbose: false,
}),
],
};
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk-react/src/components/auth/Auth.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"use client";

import styles from "./Auth.module.css";
import React, { useEffect, useState } from "react";
import { initOtpAuth, getSuborgs, createSuborg, oauth } from "../../actions/";
Expand Down
1 change: 0 additions & 1 deletion packages/sdk-react/src/components/auth/PhoneInput.css

This file was deleted.

3 changes: 1 addition & 2 deletions packages/sdk-react/src/components/auth/PhoneInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import "./PhoneInput.css";
import {
BaseTextFieldProps,
InputAdornment,
Expand All @@ -14,7 +13,7 @@ import {
usePhoneInput,
} from "react-international-phone";
import { FlagImage as OriginalFlagImage } from "react-international-phone";

import "react-international-phone/style.css";
const FlagImage = OriginalFlagImage as React.ElementType;
const allowedCountries = ["us", "ca"];

Expand Down
1 change: 0 additions & 1 deletion packages/sdk-react/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import "./components/auth/Auth.module.css";
import "./components/auth/OtpVerification.module.css";
import "./components/auth/PhoneInput.css";
import "./components/export/Export.module.css";
import "./components/import/Import.module.css";
import "./components/theme.css";
Expand Down
22 changes: 19 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading