Skip to content

Commit

Permalink
Merge branch 'main' into docs/optimize-module-federation-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
zhoushaw committed Aug 13, 2024
2 parents 31cccf9 + 4999215 commit 69cca32
Show file tree
Hide file tree
Showing 12 changed files with 166 additions and 41 deletions.
2 changes: 1 addition & 1 deletion crates/rspack_binding_options/src/options/raw_devtool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl From<RawSourceMapDevToolPluginOptions> for SourceMapDevToolPluginOptions {
no_sources,
public_path: opts.public_path,
module_filename_template,
module: opts.module.unwrap_or(false),
module: opts.module.unwrap_or(true),
source_root: opts.source_root,
test,
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function App() {
return <div id="test">Hello Rspack!</div>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require("./App");

it("`module` should be enabled by default", async () => {
const path = require("path");
const fs = require("fs");

const source = fs.readFileSync(__filename + ".map", "utf-8");
const app = fs.readFileSync(path.resolve(CONTEXT, "./App.jsx"), "utf-8");
const map = JSON.parse(source);
const appSourceIndex = map.sources.indexOf("webpack:///./App.jsx")
expect(appSourceIndex).toBeGreaterThanOrEqual(0);
expect(map.sourcesContent[appSourceIndex]).toEqual(app);
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
const rspack = require("@rspack/core");
/** @type {import("@rspack/core").Configuration} */
module.exports = {
devtool: false,
resolve: {
extensions: ["...", ".ts", ".tsx", ".jsx"]
},
module: {
rules: [
{
test: /\.jsx$/,
loader: "builtin:swc-loader",
options: {
jsc: {
parser: {
syntax: "ecmascript",
jsx: true
}
}
}
}
]
},
plugins: [
new rspack.DefinePlugin({
CONTEXT: JSON.stringify(__dirname)
}),
new rspack.SourceMapDevToolPlugin({
filename: '[file].map[query]',
}),
]
};
72 changes: 72 additions & 0 deletions website/components/CommunityCompatibleTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,78 @@ export const CommunityPluginCompatibleTable: React.FC = () => {
status: CompatibleStatus.NotCompatible,
description: i18n[lang]['resolve-plugin-un-support-desc'],
},
{
name: '@ngtools/webpack',
url: 'https://www.npmjs.com/package/@ngtools/webpack',
status: CompatibleStatus.NotCompatible,
},
{
name: 'eslint-import-resolver-webpack',
url: 'https://www.npmjs.com/package/eslint-import-resolver-webpack',
status: CompatibleStatus.Compatible,
},
{
name: '@storybook/react-docgen-typescript-plugin',
url: 'https://github.com/hipstersmoothie/react-docgen-typescript-plugin',
status: CompatibleStatus.NotCompatible,
},
{
name: 'assets-webpack-plugin',
url: 'https://github.com/ztoben/assets-webpack-plugin',
status: CompatibleStatus.Compatible,
},
{
name: 'last-call-webpack-plugin',
url: 'https://github.com/NMFR/last-call-webpack-plugin',
status: CompatibleStatus.NotCompatible,
},
{
name: '@soda/friendly-errors-webpack-plugin',
url: 'https://github.com/sodatea/friendly-errors-webpack-plugin',
status: CompatibleStatus.Compatible,
},
{
name: 'webpack-assets-manifest',
url: 'https://github.com/webdeveric/webpack-assets-manifest',
status: CompatibleStatus.Compatible,
},
{
name: 'git-revision-webpack-plugin',
url: 'https://www.npmjs.com/package/git-revision-webpack-plugin',
status: CompatibleStatus.NotCompatible,
},
{
name: 'filemanager-webpack-plugin',
url: 'https://github.com/gregnb/filemanager-webpack-plugin',
status: CompatibleStatus.Compatible,
},
{
name: '@cypress/webpack-preprocessor',
url: 'https://github.com/cypress-io/cypress',
status: CompatibleStatus.NotCompatible,
},
{
name: '@intlify/unplugin-vue-i18n',
url: 'https://github.com/intlify/bundle-tools',
status: CompatibleStatus.NotCompatible,
},
{
name: 'add-asset-html-webpack-plugin',
url: 'https://github.com/SimenB/add-asset-html-webpack-plugin',
status: CompatibleStatus.PartiallyCompatible,
description: i18n[lang]['needs-html-webpack-plugin'],
},
{
name: 'webpack-remove-empty-scripts',
url: 'https://github.com/webdiscus/webpack-remove-empty-scripts',
status: CompatibleStatus.NotCompatible,
},
{
name: 'html-webpack-harddisk-plugin',
url: 'https://github.com/jantimon/html-webpack-harddisk-plugin',
status: CompatibleStatus.PartiallyCompatible,
description: i18n[lang]['needs-html-webpack-plugin'],
},
{
name: 'webpack-virtual-modules',
url: 'https://github.com/sysgears/webpack-virtual-modules',
Expand Down
3 changes: 2 additions & 1 deletion website/components/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"webpack-filter-warnings-plugin-desc": "Use [ignoreWarnings](/config/other-options#ignorewarnings) instead",
"speed-measure-webpack-plugin-desc": "Use [Rsdoctor](/guide/optimization/use-rsdoctor) instead",
"circular-dependency-plugin-desc": "Use Eslint [import/no-cycle](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md) rule instead",
"html-webpack-tags-plugin-desc": "This plugin depends on webpack and html-webpack-plugin"
"html-webpack-tags-plugin-desc": "This plugin depends on webpack and html-webpack-plugin",
"needs-html-webpack-plugin": "This plugin depends on html-webpack-plugin"
}
3 changes: 2 additions & 1 deletion website/components/i18n/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@
"webpack-filter-warnings-plugin-desc": "使用 [ignoreWarnings](/config/other-options#ignorewarnings) 替代",
"speed-measure-webpack-plugin-desc": "使用 [Rsdoctor](/guide/optimization/use-rsdoctor) 替代",
"circular-dependency-plugin-desc": "使用 Eslint [import/no-cycle](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-cycle.md) 规则替代",
"html-webpack-tags-plugin-desc": "该插件依赖了 webpack 和 html-webpack-plugin"
"html-webpack-tags-plugin-desc": "该插件依赖了 webpack 和 html-webpack-plugin",
"needs-html-webpack-plugin": "该插件依赖了 html-webpack-plugin"
}
2 changes: 1 addition & 1 deletion website/docs/en/config/optimization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ to false will disable this optimization.
/>

Customize the minimizer. By default, [`rspack.SwcJsMinimizerRspackPlugin`](/plugins/rspack/swc-js-minimizer-rspack-plugin)
and [`rspack.LightningCssMinimizerRspackPlugin`](/plugins/rspack/swc-css-minimizer-rspack-plugin) are used.
and [`rspack.LightningCssMinimizerRspackPlugin`](/plugins/rspack/lightning-css-minimizer-rspack-plugin) are used.
When `optimization.minimizer` is specified, the default minimizers will be disabled.

```js title=rspack.config.js
Expand Down
36 changes: 18 additions & 18 deletions website/docs/en/types/chunk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

```ts
type Chunk = {
name?: string;
id?: string;
ids: string[];
idNameHints: string[];
filenameTemplate?: string;
cssFilenameTemplate?: string;
files: Set<string>;
runtime: Set<string>;
hash?: string;
contentHash: Record<string, string>;
renderedHash?: string;
chunkReason?: string;
auxiliaryFiles: Set<string>;
isOnlyInitial(): boolean;
auxiliaryFiles: ReadonlySet<string>;
canBeInitial(): boolean;
chunkReason?: Readonly<string>;
contentHash: Readonly<Record<string, string>>;
cssFilenameTemplate?: Readonly<string>;
filenameTemplate?: Readonly<string>;
files: ReadonlySet<string>;
getAllAsyncChunks(): Iterable<Chunk>;
getAllInitialChunks(): Iterable<Chunk>;
getAllReferencedChunks(): Iterable<Chunk>;
get groupsIterable(): Iterable<ChunkGroup>;
hash?: Readonly<string>;
hasRuntime(): boolean;
groupsIterable: Set<ChunkGroup>;
getAllAsyncChunks(): Set<Chunk>;
getAllInitialChunks(): Set<Chunk>;
getAllReferencedChunks(): Set<Chunk>;
id?: Readonly<string>;
idNameHints: ReadonlyArray<string>;
ids: ReadonlyArray<string>;
isOnlyInitial(): boolean;
name?: Readonly<string>;
renderedHash?: Readonly<string>;
runtime: ReadonlySet<string>;
};
```

Expand Down
2 changes: 1 addition & 1 deletion website/docs/zh/config/optimization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ import WebpackLicense from '@components/WebpackLicense';
/>

自定义压缩器。默认使用 [`rspack.SwcJsMinimizerRspackPlugin`](/plugins/rspack/swc-js-minimizer-rspack-plugin)
[`rspack.LightningCssMinimizerRspackPlugin`](/plugins/rspack/swc-css-minimizer-rspack-plugin)。当声明了 `optimization.minimizer`,默认压缩器会被禁用。
[`rspack.LightningCssMinimizerRspackPlugin`](/plugins/rspack/lightning-css-minimizer-rspack-plugin)。当声明了 `optimization.minimizer`,默认压缩器会被禁用。

```js title=rspack.config.js
const terserPlugin = require('terser-webpack-plugin');
Expand Down
36 changes: 18 additions & 18 deletions website/docs/zh/types/chunk.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@

```ts
type Chunk = {
name?: string;
id?: string;
ids: string[];
idNameHints: string[];
filenameTemplate?: string;
cssFilenameTemplate?: string;
files: Set<string>;
runtime: Set<string>;
hash?: string;
contentHash: Record<string, string>;
renderedHash?: string;
chunkReason?: string;
auxiliaryFiles: Set<string>;
isOnlyInitial(): boolean;
auxiliaryFiles: ReadonlySet<string>;
canBeInitial(): boolean;
chunkReason?: Readonly<string>;
contentHash: Readonly<Record<string, string>>;
cssFilenameTemplate?: Readonly<string>;
filenameTemplate?: Readonly<string>;
files: ReadonlySet<string>;
getAllAsyncChunks(): Iterable<Chunk>;
getAllInitialChunks(): Iterable<Chunk>;
getAllReferencedChunks(): Iterable<Chunk>;
get groupsIterable(): Iterable<ChunkGroup>;
hash?: Readonly<string>;
hasRuntime(): boolean;
groupsIterable: Set<ChunkGroup>;
getAllAsyncChunks(): Set<Chunk>;
getAllInitialChunks(): Set<Chunk>;
getAllReferencedChunks(): Set<Chunk>;
id?: Readonly<string>;
idNameHints: ReadonlyArray<string>;
ids: ReadonlyArray<string>;
isOnlyInitial(): boolean;
name?: Readonly<string>;
renderedHash?: Readonly<string>;
runtime: ReadonlySet<string>;
};
```

Expand Down
3 changes: 3 additions & 0 deletions website/project-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Iife
indicatif
innovatively
IWANABETHATGUY
intlify
jantimon
JavaScript
jerrykingxyz
Expand Down Expand Up @@ -96,6 +97,7 @@ NAPI-RS
nativizing
nestjs
NestJS
ngtools
noimport
nosources
nwjs
Expand Down Expand Up @@ -159,6 +161,7 @@ typeofs
TypeScript
ulivz
Undelayed
unplugin
valorkin
vant
viktoriialurie
Expand Down

0 comments on commit 69cca32

Please sign in to comment.