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(libs): fix import error on multiple libs #4869

Merged
merged 4 commits into from
Sep 10, 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
8 changes: 5 additions & 3 deletions libs/events/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cowprotocol/events",
"version": "1.4.0",
"version": "1.4.1-RC.0",
"type": "commonjs",
"description": "CoW Swap events",
"main": "index.js",
Expand All @@ -19,5 +19,7 @@
"cowswap",
"dex"
],
"dependencies": {}
}
"dependencies": {
"@cowprotocol/types": "^1.1.1-RC.0"
}
}
4 changes: 2 additions & 2 deletions libs/events/src/types/orders.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SupportedChainId, EnrichedOrder, OrderKind } from '@cowprotocol/cow-sdk'
import { TokenInfo, UiOrderType } from '@cowprotocol/types'
import type { EnrichedOrder, OrderKind, SupportedChainId } from '@cowprotocol/cow-sdk'
import type { TokenInfo, UiOrderType } from '@cowprotocol/types'

type BaseOrderPayload = {
chainId: SupportedChainId
Expand Down
1 change: 1 addition & 0 deletions libs/events/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default defineConfig(({ mode }) => {
dts({
entryRoot: 'src',
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
pathsToAliases: false,
}),
react(),
viteTsConfigPaths({
Expand Down
4 changes: 2 additions & 2 deletions libs/types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cowprotocol/types",
"version": "1.1.0",
"version": "1.1.1-RC.0",
"type": "commonjs",
"description": "CoW Swap events",
"main": "index.js",
Expand All @@ -21,4 +21,4 @@
"widget-lib"
],
"dependencies": {}
}
}
6 changes: 3 additions & 3 deletions libs/types/src/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { ReactNode } from 'react'

import { latest } from '@cowprotocol/app-data'
import { SupportedChainId } from '@cowprotocol/cow-sdk'
import { Currency, CurrencyAmount } from '@uniswap/sdk-core'
import type { latest } from '@cowprotocol/app-data'
import type { SupportedChainId } from '@cowprotocol/cow-sdk'
import type { Currency, CurrencyAmount } from '@uniswap/sdk-core'

import { Command } from './common'

Expand Down
1 change: 1 addition & 0 deletions libs/types/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default defineConfig(({ mode }) => {
dts({
entryRoot: 'src',
tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
pathsToAliases: false,
}),
react(),
viteTsConfigPaths({
Expand Down
6 changes: 3 additions & 3 deletions libs/widget-lib/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cowprotocol/widget-lib",
"version": "0.14.0",
"version": "0.14.1-RC.0",
"type": "commonjs",
"description": "CoW Swap Widget Library. Allows you to easily embed a CoW Swap widget on your website.",
"main": "index.js",
Expand All @@ -21,6 +21,6 @@
"widget-lib"
],
"dependencies": {
"@cowprotocol/events": "^1.3.0"
"@cowprotocol/events": "^1.4.1-RC.0"
}
}
}
2 changes: 1 addition & 1 deletion libs/widget-lib/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export default defineConfig(({ command }) => {
dts({
entryRoot: 'src',
tsconfigPath: joinPathFragments(__dirname, 'tsconfig.lib.json'),
pathsToAliases: false,
}),

viteTsConfigPaths({
root: '../../../',
}),
Expand Down
4 changes: 2 additions & 2 deletions libs/widget-react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cowprotocol/widget-react",
"version": "0.10.1",
"version": "0.10.2-RC.0",
"type": "commonjs",
"description": "CoW Swap Widget Library. Allows you to easily embed a CoW Swap widget on your React application.",
"main": "index.js",
Expand All @@ -22,6 +22,6 @@
"react"
],
"dependencies": {
"@cowprotocol/widget-lib": "^0.14.0"
"@cowprotocol/widget-lib": "^0.14.1-RC.0"
}
}
2 changes: 1 addition & 1 deletion libs/widget-react/src/lib/CowSwapWidget.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useCallback, useEffect, useRef, useState } from 'react'

import type { CowEventListeners } from '@cowprotocol/events'
import { Command } from '@cowprotocol/types'
import type { Command } from '@cowprotocol/types'
import {
CowSwapWidgetHandler,
CowSwapWidgetParams,
Expand Down
19 changes: 1 addition & 18 deletions libs/widget-react/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,19 @@ import { defineConfig } from 'vite'
import dts from 'vite-plugin-dts'
import viteTsConfigPaths from 'vite-tsconfig-paths'

import { writeFileSync } from 'fs'
import { join } from 'path'

// Workaround to generate the declaration file for the bundle in a way that does not replace the import of the widget-lib with a local path
// If you know a better way to do this, please let me know
function generateBundleDeclarationFile(outDir: string) {
return {
name: 'generate-bundle-declaration-file',
writeBundle() {
const content = `export * from './lib/CowSwapWidget';\nexport * from '@cowprotocol/widget-lib';`
const outputPath = join(outDir, 'index.d.ts')
writeFileSync(outputPath, content)
console.log(`Generated declaration file at: ${outputPath}`)
},
}
}

export default defineConfig({
cacheDir: '../../../node_modules/.vite/widget-react',

plugins: [
dts({
entryRoot: 'src',
tsconfigPath: joinPathFragments(__dirname, 'tsconfig.lib.json'),
pathsToAliases: false,
}),
react(),
viteTsConfigPaths({
root: '../../../',
}),
generateBundleDeclarationFile('dist/libs/widget-react'),
],

// Uncomment this if you are using workers.
Expand Down
Loading