-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Redesign server plugins * Upgrade webpack server plugin * Upgrade vite server plugin * Update findCosmosPluginConfigs.test.ts * Add Codecov badge * Add dev server tests * Update setup.ts * Fix previous tests * Fix dev server test * Update mockConsole.ts * Update devServer.ts * Capture logs * Make importModule for importing server plugins * Add dev server plugin tests * Fix mocking * Make tests more resilient * Rename helper * Add test * Remove retry stuff * Remove unneeded .tsx extension * Create test helper for mocking plugin configs * Update devServerPlugin.ts * Reorganize imports * Fix test * Rename test file * Life mock files * Add export test * Test export plugin * Implement config hook * Implement config hook in exports * Move server plugins * Try to fix flaky test * Update cypress.config.ts * Find first available port * Improve port retry plugin * Update README.md * Use config hook in Vite plugin * Simplify file names * Use unique port in export tests * Update getUserWebpackConfig.ts * Separate importModule from importJson and get rid of deprecated boilerplate * Test change * Revert change * Test override example * Refactor FS module * Update webpack override example * Remove console.logs * Test message handler API * Test exporting UI plugins * Update exportUiPlugin.ts * Fix UI path on Windows * Clean up playground bundle mocks * Test plugin endpoint * Remove ambiguity * Fix UI path * Fix Window path * Fix Windows path * Fix Windows paths * Update devServerUiPlugin.ts * Update devServerUiPlugin.ts * Prettify and add code explanation * Fix explanation
- Loading branch information
Showing
67 changed files
with
1,319 additions
and
361 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 |
---|---|---|
|
@@ -3,6 +3,7 @@ npm-debug.log | |
yarn-error.log | ||
|
||
packages/*/dist | ||
__testFs__ | ||
|
||
coverage | ||
cypress/screenshots | ||
|
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
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
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,4 @@ | ||
export default function (webpackConfig, env) { | ||
// Customize webpack config for Cosmos... | ||
return webpackConfig; | ||
} |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
{ | ||
"name": "Vite", | ||
"devServer": "dist/viteDevServerPlugin.js", | ||
"export": "dist/viteExportPlugin.js" | ||
"server": "dist/viteServerPlugin.js" | ||
} |
17 changes: 17 additions & 0 deletions
17
packages/react-cosmos-plugin-vite/src/createViteCosmosConfig.ts
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,17 @@ | ||
import { CosmosConfig } from 'react-cosmos/server.js'; | ||
|
||
type ViteCosmosConfig = { | ||
port: number; | ||
}; | ||
|
||
type ViteCosmosConfigInput = Partial<ViteCosmosConfig>; | ||
|
||
export function createViteCosmosConfig( | ||
cosmosConfig: CosmosConfig | ||
): ViteCosmosConfig { | ||
const configInput: ViteCosmosConfigInput = cosmosConfig.vite || {}; | ||
|
||
return { | ||
port: configInput.port || 5050, | ||
}; | ||
} |
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,30 @@ | ||
import { | ||
CosmosConfig, | ||
CosmosConfigPluginArgs, | ||
findNextAvailablePort, | ||
} from 'react-cosmos/server.js'; | ||
import { createViteCosmosConfig } from './createViteCosmosConfig.js'; | ||
|
||
export async function viteConfigPlugin({ | ||
cosmosConfig, | ||
}: CosmosConfigPluginArgs): Promise<CosmosConfig> { | ||
const { rendererUrl } = cosmosConfig; | ||
if (rendererUrl) { | ||
return cosmosConfig; | ||
} | ||
|
||
const viteCosmosConfig = createViteCosmosConfig(cosmosConfig); | ||
const port = await findNextAvailablePort( | ||
viteCosmosConfig.port, | ||
cosmosConfig.portRetries | ||
); | ||
|
||
return { | ||
...cosmosConfig, | ||
rendererUrl: `http://localhost:${port}`, | ||
vite: { | ||
...viteCosmosConfig, | ||
port: port, | ||
}, | ||
}; | ||
} |
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,13 @@ | ||
import { CosmosServerPlugin } from 'react-cosmos/server.js'; | ||
import { viteConfigPlugin } from './viteConfigPlugin.js'; | ||
import { viteDevServerPlugin } from './viteDevServerPlugin.js'; | ||
import { viteExportPlugin } from './viteExportPlugin.js'; | ||
|
||
const viteServerPlugin: CosmosServerPlugin = { | ||
name: 'vite', | ||
config: viteConfigPlugin, | ||
devServer: viteDevServerPlugin, | ||
export: viteExportPlugin, | ||
}; | ||
|
||
export default viteServerPlugin; |
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 |
---|---|---|
@@ -1,6 +1,5 @@ | ||
{ | ||
"name": "Webpack", | ||
"ui": "dist/ui/build.js", | ||
"devServer": "dist/server/webpackDevServerPlugin.js", | ||
"export": "dist/server/webpackExportPlugin.js" | ||
"server": "dist/server/webpackServerPlugin.js" | ||
} |
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
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
Oops, something went wrong.