Skip to content

Commit

Permalink
chore: Updated dependencies and added the new swc shared configs (#51)
Browse files Browse the repository at this point in the history
  • Loading branch information
patricklafrance committed Jun 17, 2023
1 parent f0ec5e9 commit 4f1e57c
Show file tree
Hide file tree
Showing 26 changed files with 1,024 additions and 1,196 deletions.
4 changes: 2 additions & 2 deletions docs/getting-started/create-local-module.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ order: 80

Local modules are regular modules that are part of the **host application build**. They are independent modules that expose a `registration` function to the host application's bootstrapping code. A local module can be a standalone package, a sibling project (in a monorepo setup), or even a local folder within the host application.

Local modules are useful when migrating from a monolithic application to a distributed application or when launching a new product with an unrefined business domain.
Local modules are useful when **migrating** from a **monolithic application** to a distributed application or when **launching** a **new product** with an unrefined business domain.

Let's add a local module to demonstrate how it's done!

Expand All @@ -16,7 +16,7 @@ Let's add a local module to demonstrate how it's done!
>
> To facilitate this transition, this shell also supports local modules that are loaded at build time.
>
> Both remote and local modules can be used within same application as this shell supports dual bootstrapping. For example, an application can be configured to load a few remote modules at runtime while also loading a few local modules at build time.
> Both remote and local modules can be used within same application as this shell supports dual bootstrapping. For example, an application can be configured to load a few remote modules at runtime while also loading a few local modules.
## Install the packages

Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,13 @@
"devDependencies": {
"@changesets/cli": "2.26.1",
"@changesets/changelog-github": "0.4.8",
"@workleap/eslint-plugin": "1.8.1",
"@workleap/typescript-configs": "2.3.1",
"@typescript-eslint/parser": "5.59.11",
"@workleap/eslint-plugin": "1.8.2",
"@workleap/typescript-configs": "2.3.2",
"cross-env": "7.0.3",
"eslint": "8.42.0",
"jest": "29.5.0",
"netlify-cli": "15.4.1",
"netlify-cli": "15.6.0",
"npm-check-updates": "16.10.12",
"retypeapp": "3.0.3",
"ts-node": "10.9.1",
Expand Down
13 changes: 7 additions & 6 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,16 @@
"react-dom": "*"
},
"devDependencies": {
"@types/react": "18.2.9",
"@types/react-dom": "18.2.4",
"@workleap/eslint-plugin": "1.8.1",
"@workleap/tsup-configs": "1.0.1",
"@workleap/typescript-configs": "2.3.1",
"@types/react": "18.2.12",
"@types/react-dom": "18.2.5",
"@workleap/eslint-plugin": "1.8.2",
"@workleap/tsup-configs": "2.0.0",
"@workleap/typescript-configs": "2.3.2",
"npm-check-updates": "16.10.12",
"react": "18.2.0",
"react-dom": "18.2.0",
"tsup": "6.7.0"
"tsup": "7.0.0",
"typescript": "5.0.4"
},
"dependencies": {
"eventemitter3": "5.0.1"
Expand Down
9 changes: 5 additions & 4 deletions packages/fakes/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@
},
"devDependencies": {
"@types/jest": "29.5.2",
"@workleap/eslint-plugin": "1.8.1",
"@workleap/tsup-configs": "1.0.1",
"@workleap/typescript-configs": "2.3.1",
"@workleap/eslint-plugin": "1.8.2",
"@workleap/tsup-configs": "2.0.0",
"@workleap/typescript-configs": "2.3.2",
"jest": "29.5.0",
"npm-check-updates": "16.10.12",
"tsup": "6.7.0"
"tsup": "7.0.0",
"typescript": "5.0.4"
},
"dependencies": {
"@squide/core": "workspace:*"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-router/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Config } from "jest";
import { pathsToModuleNameMapper } from "ts-jest";
import { config as swcConfig } from "./swc.jest.ts";
import { swcConfig } from "./swc.jest.ts";
import { compilerOptions } from "./tsconfig.json";

const config: Config = {
Expand Down
18 changes: 10 additions & 8 deletions packages/react-router/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,27 +34,29 @@
"react-router-dom": "*"
},
"devDependencies": {
"@swc/core": "1.3.62",
"@swc/core": "1.3.64",
"@swc/helpers": "0.5.1",
"@swc/jest": "0.2.26",
"@testing-library/react": "14.0.0",
"@types/jest": "29.5.2",
"@types/react": "18.2.9",
"@types/react-dom": "18.2.4",
"@types/react": "18.2.12",
"@types/react-dom": "18.2.5",
"@types/react-test-renderer": "18.0.0",
"@workleap/eslint-plugin": "1.8.1",
"@workleap/tsup-configs": "1.0.1",
"@workleap/typescript-configs": "2.3.1",
"@workleap/eslint-plugin": "1.8.2",
"@workleap/swc-configs": "1.0.0",
"@workleap/tsup-configs": "2.0.0",
"@workleap/typescript-configs": "2.3.2",
"jest": "29.5.0",
"jest-environment-jsdom": "29.5.0",
"npm-check-updates": "16.10.12",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-router-dom": "6.12.1",
"react-router-dom": "6.13.0",
"react-test-renderer": "18.2.0",
"ts-node": "10.9.1",
"ts-jest": "29.1.0",
"tsup": "6.7.0"
"tsup": "7.0.0",
"typescript": "5.0.4"
},
"dependencies": {
"@squide/core": "workspace:*"
Expand Down
33 changes: 5 additions & 28 deletions packages/react-router/swc.jest.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
import type { Config } from "@swc/core";
import { defineJestConfig } from "@workleap/swc-configs";

export const swcConfig = defineJestConfig({
react: true
});

export const config: Config = {
jsc: {
parser: {
syntax: "typescript",
tsx: true
},
// The output environment that the code will be compiled for.
target: "es2022",
transform: {
react: {
// Use "react/jsx-runtime".
runtime: "automatic",
// Use the native "Object.assign()" instead of "_extends".
useBuiltins: true
}
},
// Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
// Requires to add "@swc/helpers" as a project dependency
externalHelpers: true
},
module: {
// The output module resolution system that the code will be compiled for.
type: "es6",
// Prevent SWC from exporting the `__esModule` property.
strict: true
}
};
2 changes: 1 addition & 1 deletion packages/webpack-module-federation/jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Config } from "jest";
import { pathsToModuleNameMapper } from "ts-jest";
import { config as swcConfig } from "./swc.jest.ts";
import { swcConfig } from "./swc.jest.ts";
import { compilerOptions } from "./tsconfig.json";

const config: Config = {
Expand Down
17 changes: 10 additions & 7 deletions packages/webpack-module-federation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,25 @@
"webpack": ">=5.0.0"
},
"devDependencies": {
"@swc/core": "1.3.62",
"@swc/core": "1.3.64",
"@swc/helpers": "0.5.1",
"@swc/jest": "0.2.26",
"@types/jest": "29.5.2",
"@types/react": "18.2.9",
"@types/react-dom": "18.2.4",
"@workleap/eslint-plugin": "1.8.1",
"@workleap/tsup-configs": "1.0.1",
"@workleap/typescript-configs": "2.3.1",
"@types/react": "18.2.12",
"@types/react-dom": "18.2.5",
"@workleap/eslint-plugin": "1.8.2",
"@workleap/swc-configs": "1.0.0",
"@workleap/tsup-configs": "2.0.0",
"@workleap/typescript-configs": "2.3.2",
"jest": "29.5.0",
"npm-check-updates": "16.10.12",
"react": "18.2.0",
"react-dom": "18.2.0",
"ts-node": "10.9.1",
"ts-jest": "29.1.0",
"tsup": "6.7.0"
"tsup": "7.0.0",
"typescript": "5.0.4",
"webpack": "5.87.0"
},
"dependencies": {
"@squide/core": "workspace:*",
Expand Down
12 changes: 7 additions & 5 deletions packages/webpack-module-federation/src/configTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,25 +46,27 @@ const ReactRouterSharedDependencies: ModuleFederationPluginOptions = {
}
};

function mergeOptions(targetOptions: ModuleFederationPluginOptions, { router = "react-router", pluginOptions = {} }: ModuleFederationOptions) {
function resolvePluginOptions(baseOptions: ModuleFederationPluginOptions, { router = "react-router", pluginOptions = {} }: ModuleFederationOptions) {
return merge.all<ModuleFederationPluginOptions>([
targetOptions,
baseOptions,
DefaultSharedDependencies,
router === "react-router" ? ReactRouterSharedDependencies : {},
pluginOptions
]);
}

function validateConfig(config: webpack.Configuration) {
if (!isNil(config.plugins) && config.plugins.some(x => x.constructor.name === webpack.container.ModuleFederationPlugin.name)) {
// There doesn't seem to be an exported Webpack type for this.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (!isNil(config.plugins) && config.plugins.some((x: any) => x.constructor.name === webpack.container.ModuleFederationPlugin.name)) {
throw new Error("ModuleFederationPlugin has already been configured. Please remove ModuleFederationPlugin from your configuration plugins before calling this function.");
}
}

export function hostTransformer(config: webpack.Configuration, name: string, options: ModuleFederationOptions = {}): webpack.Configuration {
validateConfig(config);

const pluginOptions = mergeOptions({ name }, options);
const pluginOptions = resolvePluginOptions({ name }, options);

return {
...config,
Expand All @@ -78,7 +80,7 @@ export function hostTransformer(config: webpack.Configuration, name: string, opt
export function remoteTransformer(config: webpack.Configuration, name: string, options: ModuleFederationOptions = {}): webpack.Configuration {
validateConfig(config);

const pluginOptions = mergeOptions({
const pluginOptions = resolvePluginOptions({
name,
filename: RemoteEntryPoint,
exposes: {
Expand Down
22 changes: 2 additions & 20 deletions packages/webpack-module-federation/swc.jest.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
import type { Config } from "@swc/core";
import { defineJestConfig } from "@workleap/swc-configs";

export const config: Config = {
jsc: {
parser: {
syntax: "typescript",
tsx: true
},
// The output environment that the code will be compiled for.
target: "es2022",
// Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
// Requires to add "@swc/helpers" as a project dependency
externalHelpers: true
},
module: {
// The output module resolution system that the code will be compiled for.
type: "es6",
// Prevent SWC from exporting the `__esModule` property.
strict: true
}
};
export const swcConfig = defineJestConfig();
Loading

0 comments on commit 4f1e57c

Please sign in to comment.