Skip to content

Commit bc02e42

Browse files
authored
Merge pull request #165 from dev-five-git/fix-webpack-issue
Fix webpack issue
2 parents 7f8c5d7 + 5a2ab9d commit bc02e42

File tree

5 files changed

+35
-12
lines changed

5 files changed

+35
-12
lines changed

.changeset/modern-bats-decide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@devup-ui/webpack-plugin": patch
3+
---
4+
5+
Fix webpack issue

packages/webpack-plugin/package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@
3232
"dist"
3333
],
3434
"dependencies": {
35-
"@devup-ui/wasm": "workspace:*",
36-
"webpack": "^5.98"
35+
"@devup-ui/wasm": "workspace:*"
3736
},
3837
"peerDependencies": {
39-
"@devup-ui/wasm": "*",
40-
"webpack": "*"
38+
"@devup-ui/wasm": "*"
4139
},
4240
"devDependencies": {
4341
"vite": "^6.2.2",

packages/webpack-plugin/src/__tests__/plugin.test.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import {
77
} from 'node:fs'
88
import { join, resolve } from 'node:path'
99

10-
import { getCss, getThemeInterface, registerTheme } from '@devup-ui/wasm'
10+
import {
11+
getCss,
12+
getDefaultTheme,
13+
getThemeInterface,
14+
registerTheme,
15+
} from '@devup-ui/wasm'
1116
import { describe } from 'vitest'
1217

1318
import { DevupUIWebpackPlugin } from '../plugin'
@@ -113,8 +118,11 @@ describe('devupUIPlugin', () => {
113118
tapAsync: vi.fn(),
114119
},
115120
},
116-
}
117-
plugin.apply(compiler as any)
121+
webpack: {
122+
DefinePlugin: vi.fn(),
123+
},
124+
} as any
125+
plugin.apply(compiler)
118126
// asyncCompile
119127
const add = vi.fn()
120128
vi.mocked(compiler.hooks.afterCompile.tap).mock.calls[0][1]({
@@ -151,6 +159,9 @@ describe('devupUIPlugin', () => {
151159
tapAsync: vi.fn(),
152160
},
153161
},
162+
webpack: {
163+
DefinePlugin: vi.fn(),
164+
},
154165
} as any)
155166

156167
expect(writeFileSync).toHaveBeenCalledWith('css', '', {
@@ -184,6 +195,9 @@ describe('devupUIPlugin', () => {
184195
tapAsync: vi.fn(),
185196
},
186197
},
198+
webpack: {
199+
DefinePlugin: vi.fn(),
200+
},
187201
} as any
188202
plugin.apply(compiler)
189203

@@ -214,6 +228,9 @@ describe('devupUIPlugin', () => {
214228
tapAsync: vi.fn(),
215229
},
216230
},
231+
webpack: {
232+
DefinePlugin: vi.fn(),
233+
},
217234
} as any
218235
vi.mocked(existsSync).mockReturnValue(true)
219236
plugin.apply(compiler)
@@ -297,6 +314,9 @@ describe('devupUIPlugin', () => {
297314
tapAsync: vi.fn(),
298315
},
299316
},
317+
webpack: {
318+
DefinePlugin: vi.fn(),
319+
},
300320
} as any
301321
plugin.apply(compiler)
302322

@@ -307,5 +327,8 @@ describe('devupUIPlugin', () => {
307327
encoding: 'utf-8',
308328
},
309329
)
330+
expect(compiler.webpack.DefinePlugin).toHaveBeenCalledWith({
331+
'process.env.DEVUP_UI_DEFAULT_THEME': JSON.stringify(getDefaultTheme()),
332+
})
310333
})
311334
})

packages/webpack-plugin/src/plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
registerTheme,
1717
setDebug,
1818
} from '@devup-ui/wasm'
19-
import { type Compiler, DefinePlugin } from 'webpack'
19+
import { type Compiler } from 'webpack'
2020

2121
export interface DevupUIWebpackPluginOptions {
2222
package: string
@@ -134,7 +134,7 @@ export class DevupUIWebpackPlugin {
134134
writeFileSync(this.options.cssFile, '', { encoding: 'utf-8' })
135135

136136
compiler.options.plugins.push(
137-
new DefinePlugin({
137+
new compiler.webpack.DefinePlugin({
138138
'process.env.DEVUP_UI_DEFAULT_THEME': JSON.stringify(getDefaultTheme()),
139139
}),
140140
)

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)