-
-
Notifications
You must be signed in to change notification settings - Fork 283
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(rsbuild-plugin): update mf format judgment conditions (#3564)
- Loading branch information
Showing
6 changed files
with
122 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@module-federation/rsbuild-plugin': patch | ||
--- | ||
|
||
chore(rsbuild-plugin): update mf format judgment conditions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { isMFFormat } from '../../src/cli'; | ||
import type { Rspack } from '@rsbuild/core'; | ||
|
||
describe('isMFFormat', () => { | ||
it('should return true when library config is not present', () => { | ||
const config: Partial<Rspack.Configuration> = { | ||
output: {}, | ||
}; | ||
expect(isMFFormat(config as Rspack.Configuration)).toBe(true); | ||
}); | ||
|
||
it('should return true when library is not an object', () => { | ||
const config: Partial<Rspack.Configuration> = { | ||
output: { | ||
library: 'myLib', | ||
}, | ||
}; | ||
expect(isMFFormat(config as Rspack.Configuration)).toBe(true); | ||
}); | ||
|
||
it('should return true when library is an array', () => { | ||
const config: Partial<Rspack.Configuration> = { | ||
output: { | ||
library: ['myLib'], | ||
}, | ||
}; | ||
expect(isMFFormat(config as Rspack.Configuration)).toBe(true); | ||
}); | ||
|
||
it('should return false when library.type is commonjs', () => { | ||
const config: Partial<Rspack.Configuration> = { | ||
output: { | ||
library: { | ||
type: 'commonjs', | ||
}, | ||
}, | ||
}; | ||
expect(isMFFormat(config as Rspack.Configuration)).toBe(false); | ||
}); | ||
|
||
it('should return false when library.type is umd', () => { | ||
const config: Partial<Rspack.Configuration> = { | ||
output: { | ||
library: { | ||
type: 'umd', | ||
}, | ||
}, | ||
}; | ||
expect(isMFFormat(config as Rspack.Configuration)).toBe(false); | ||
}); | ||
|
||
it('should return false when library.type is modern-module', () => { | ||
const config: Partial<Rspack.Configuration> = { | ||
output: { | ||
library: { | ||
type: 'modern-module', | ||
}, | ||
}, | ||
}; | ||
expect(isMFFormat(config as Rspack.Configuration)).toBe(false); | ||
}); | ||
|
||
it('should return false when library.type contains commonjs', () => { | ||
const config: Partial<Rspack.Configuration> = { | ||
output: { | ||
library: { | ||
type: 'commonjs-static', | ||
}, | ||
}, | ||
}; | ||
expect(isMFFormat(config as Rspack.Configuration)).toBe(false); | ||
}); | ||
|
||
it('should return true when library.type is other value', () => { | ||
const config: Partial<Rspack.Configuration> = { | ||
output: { | ||
library: { | ||
type: 'var', | ||
}, | ||
}, | ||
}; | ||
expect(isMFFormat(config as Rspack.Configuration)).toBe(true); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// <reference types="vitest" /> | ||
import { defineConfig } from 'vite'; | ||
|
||
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'; | ||
|
||
export default defineConfig({ | ||
cacheDir: '../../node_modules/.vite/rsbuild-plugin', | ||
|
||
plugins: [nxViteTsPaths()], | ||
|
||
// Uncomment this if you are using workers. | ||
// worker: { | ||
// plugins: [ nxViteTsPaths() ], | ||
// }, | ||
|
||
test: { | ||
cache: { | ||
dir: '../../node_modules/.vitest', | ||
}, | ||
environment: 'node', | ||
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'], | ||
reporters: ['default'], | ||
}, | ||
}); |