diff --git a/Cargo.lock b/Cargo.lock index 5840ce33da9..b095945aac8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3325,7 +3325,6 @@ dependencies = [ "dashmap 5.5.3", "either", "jsonc-parser 0.23.0", - "once_cell", "rspack_ast", "rspack_core", "rspack_error", diff --git a/crates/rspack_loader_swc/Cargo.toml b/crates/rspack_loader_swc/Cargo.toml index abc63064460..5c675f85231 100644 --- a/crates/rspack_loader_swc/Cargo.toml +++ b/crates/rspack_loader_swc/Cargo.toml @@ -22,7 +22,6 @@ base64 = { version = "0.22" } dashmap = { version = "5.5.3" } either = "1" jsonc-parser = { version = "0.23.0", features = ["serde"] } -once_cell = { workspace = true } rspack_ast = { path = "../rspack_ast" } rspack_core = { path = "../rspack_core" } rspack_error = { path = "../rspack_error" } diff --git a/crates/rspack_loader_swc/src/options.rs b/crates/rspack_loader_swc/src/options.rs index 5c4c30a579b..3d5cae664b5 100644 --- a/crates/rspack_loader_swc/src/options.rs +++ b/crates/rspack_loader_swc/src/options.rs @@ -1,8 +1,4 @@ -use rspack_swc_visitors::{ - EmotionOptions, ImportOptions, PreactOptions, RawEmotionOptions, RawImportOptions, - RawPreactOptions, RawRelayOptions, RawStyledComponentsOptions, RelayOptions, - StyledComponentsOptions, -}; +use rspack_swc_visitors::{ImportOptions, PreactOptions, RawImportOptions, RawPreactOptions}; use serde::Deserialize; use swc_config::config_types::BoolConfig; use swc_core::base::config::{ @@ -13,31 +9,22 @@ use swc_core::base::config::{ #[derive(Default, Deserialize, Debug)] #[serde(rename_all = "camelCase", default)] pub struct RawRspackExperiments { - pub relay: Option, - pub styled_components: Option, pub import: Option>, - pub emotion: Option, pub preact: Option, } #[derive(Default, Debug)] pub(crate) struct RspackExperiments { - pub(crate) relay: Option, - pub(crate) styled_components: Option, pub(crate) import: Option>, - pub(crate) emotion: Option, pub(crate) preact: Option, } impl From for RspackExperiments { fn from(value: RawRspackExperiments) -> Self { Self { - relay: value.relay.map(|v| v.into()), - styled_components: value.styled_components.map(|v| v.into()), import: value .import .map(|i| i.into_iter().map(|v| v.into()).collect()), - emotion: value.emotion, preact: value.preact, } } diff --git a/crates/rspack_loader_swc/src/transformer.rs b/crates/rspack_loader_swc/src/transformer.rs index f0bf67a42c0..f569b378e7a 100644 --- a/crates/rspack_loader_swc/src/transformer.rs +++ b/crates/rspack_loader_swc/src/transformer.rs @@ -1,18 +1,13 @@ -use std::path::{Path, PathBuf}; +use std::path::Path; use std::sync::Arc; use either::Either; -use once_cell::sync::Lazy; use rspack_core::CompilerOptions; -use rspack_swc_visitors::{styled_components, PreactOptions, StyledComponentsOptions}; +use rspack_swc_visitors::PreactOptions; use swc_core::atoms::Atom; use swc_core::common::collections::AHashMap; -use swc_core::common::{ - chain, - comments::{Comments, NoopComments}, - Mark, SourceMap, -}; -use swc_core::common::{BytePos, FileName}; +use swc_core::common::BytePos; +use swc_core::common::{chain, comments::Comments, Mark, SourceMap}; use swc_core::ecma::ast::Ident; use swc_core::ecma::visit::{noop_visit_type, Visit}; use swc_core::ecma::{transforms::base::pass::noop, visit::Fold}; @@ -40,52 +35,21 @@ macro_rules! either { #[allow(clippy::too_many_arguments)] pub(crate) fn transform<'a>( - resource_path: &'a Path, - rspack_options: &'a CompilerOptions, - comments: Option<&'a dyn Comments>, + _resource_path: &'a Path, + _rspack_options: &'a CompilerOptions, + _comments: Option<&'a dyn Comments>, _top_level_mark: Mark, - unresolved_mark: Mark, - cm: Arc, + _unresolved_mark: Mark, + _cm: Arc, content: &'a String, rspack_experiments: &'a RspackExperiments, ) -> impl Fold + 'a { - use rspack_swc_visitors::EmotionOptions; - let content_hash = Lazy::new(|| xxh32(content.as_bytes(), 0)); - chain!( - either!(rspack_experiments.emotion, |options: &EmotionOptions| { - rspack_swc_visitors::emotion( - options.clone(), - resource_path, - *content_hash, - cm.clone(), - comments, - ) - }), - either!( - rspack_experiments.styled_components, - |options: &StyledComponentsOptions| { - styled_components( - FileName::Real(resource_path.into()), - (*content_hash).into(), - options.clone(), - NoopComments, - ) - } - ), - either!(rspack_experiments.relay, |options| { - rspack_swc_visitors::relay( - options, - resource_path, - PathBuf::from(AsRef::::as_ref(&rspack_options.context)), - unresolved_mark, - ) - }), either!(rspack_experiments.import, |options| { rspack_swc_visitors::import(options) }), either!(rspack_experiments.preact, |options: &PreactOptions| { - rspack_swc_visitors::preact(options.clone(), (*content_hash).to_string()) + rspack_swc_visitors::preact(options.clone(), xxh32(content.as_bytes(), 0).to_string()) }), ) } diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-custom/custom/MyComponent.graphql.ts b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-custom/custom/MyComponent.graphql.ts deleted file mode 100644 index bd816eaba4c..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-custom/custom/MyComponent.graphql.ts +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-custom/index.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-custom/index.js deleted file mode 100644 index 428e75ae807..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-custom/index.js +++ /dev/null @@ -1,11 +0,0 @@ -const { graphql } = require("react-relay"); - -it("graphql", () => { - const query = graphql` - fragment MyComponent on Type { - field - } - `; - - expect(query).toBe(1); -}); diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-custom/rspack.config.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-custom/rspack.config.js deleted file mode 100644 index c9f019715a7..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-custom/rspack.config.js +++ /dev/null @@ -1,22 +0,0 @@ -/** @type {import("@rspack/core").Configuration} */ -module.exports = { - resolve: { - extensions: ["...", ".ts", ".tsx", ".jsx"] - }, - module: { - rules: [ - { - test: /\.js$/, - loader: "builtin:swc-loader", - options: { - rspackExperiments: { - relay: { - language: "typescript", - artifactDirectory: "./custom" - } - } - } - } - ] - } -}; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/custom/MyComponent.graphql.ts b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/custom/MyComponent.graphql.ts deleted file mode 100644 index bd816eaba4c..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/custom/MyComponent.graphql.ts +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/index.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/index.js deleted file mode 100644 index 428e75ae807..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/index.js +++ /dev/null @@ -1,11 +0,0 @@ -const { graphql } = require("react-relay"); - -it("graphql", () => { - const query = graphql` - fragment MyComponent on Type { - field - } - `; - - expect(query).toBe(1); -}); diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/relay.config.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/relay.config.js deleted file mode 100644 index cb368f17caf..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/relay.config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - language: "typescript", - artifactDirectory: "./custom" -}; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/rspack.config.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/rspack.config.js deleted file mode 100644 index de9866240d8..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-js/rspack.config.js +++ /dev/null @@ -1,19 +0,0 @@ -/** @type {import("@rspack/core").Configuration} */ -module.exports = { - resolve: { - extensions: ["...", ".ts", ".tsx", ".jsx"] - }, - module: { - rules: [ - { - test: /\.js$/, - loader: "builtin:swc-loader", - options: { - rspackExperiments: { - relay: true - } - } - } - ] - } -}; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/custom/MyComponent.graphql.ts b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/custom/MyComponent.graphql.ts deleted file mode 100644 index bd816eaba4c..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/custom/MyComponent.graphql.ts +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/index.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/index.js deleted file mode 100644 index 428e75ae807..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/index.js +++ /dev/null @@ -1,11 +0,0 @@ -const { graphql } = require("react-relay"); - -it("graphql", () => { - const query = graphql` - fragment MyComponent on Type { - field - } - `; - - expect(query).toBe(1); -}); diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/relay.config.json b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/relay.config.json deleted file mode 100644 index a80d534946b..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/relay.config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "language": "typescript", - "artifactDirectory": "./custom" -} diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/rspack.config.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/rspack.config.js deleted file mode 100644 index de9866240d8..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-config-json/rspack.config.js +++ /dev/null @@ -1,19 +0,0 @@ -/** @type {import("@rspack/core").Configuration} */ -module.exports = { - resolve: { - extensions: ["...", ".ts", ".tsx", ".jsx"] - }, - module: { - rules: [ - { - test: /\.js$/, - loader: "builtin:swc-loader", - options: { - rspackExperiments: { - relay: true - } - } - } - ] - } -}; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-default/__generated__/MyComponent.graphql.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-default/__generated__/MyComponent.graphql.js deleted file mode 100644 index bd816eaba4c..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-default/__generated__/MyComponent.graphql.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-default/index.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-default/index.js deleted file mode 100644 index 428e75ae807..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-default/index.js +++ /dev/null @@ -1,11 +0,0 @@ -const { graphql } = require("react-relay"); - -it("graphql", () => { - const query = graphql` - fragment MyComponent on Type { - field - } - `; - - expect(query).toBe(1); -}); diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-default/rspack.config.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-default/rspack.config.js deleted file mode 100644 index de9866240d8..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-default/rspack.config.js +++ /dev/null @@ -1,19 +0,0 @@ -/** @type {import("@rspack/core").Configuration} */ -module.exports = { - resolve: { - extensions: ["...", ".ts", ".tsx", ".jsx"] - }, - module: { - rules: [ - { - test: /\.js$/, - loader: "builtin:swc-loader", - options: { - rspackExperiments: { - relay: true - } - } - } - ] - } -}; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/__generated__/MyComponent.graphql.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/__generated__/MyComponent.graphql.js deleted file mode 100644 index bd816eaba4c..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/__generated__/MyComponent.graphql.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = 1; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/index.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/index.js deleted file mode 100644 index 428e75ae807..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/index.js +++ /dev/null @@ -1,11 +0,0 @@ -const { graphql } = require("react-relay"); - -it("graphql", () => { - const query = graphql` - fragment MyComponent on Type { - field - } - `; - - expect(query).toBe(1); -}); diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/package.json b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/package.json deleted file mode 100644 index c7b2e5c1852..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "relay": { - "language": "javascript" - } -} \ No newline at end of file diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/rspack.config.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/rspack.config.js deleted file mode 100644 index de9866240d8..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-json/rspack.config.js +++ /dev/null @@ -1,19 +0,0 @@ -/** @type {import("@rspack/core").Configuration} */ -module.exports = { - resolve: { - extensions: ["...", ".ts", ".tsx", ".jsx"] - }, - module: { - rules: [ - { - test: /\.js$/, - loader: "builtin:swc-loader", - options: { - rspackExperiments: { - relay: true - } - } - } - ] - } -}; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/custom/MyComponent.graphql.ts b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/custom/MyComponent.graphql.ts deleted file mode 100644 index 0e35d0cbb39..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/custom/MyComponent.graphql.ts +++ /dev/null @@ -1 +0,0 @@ -module.exports = new Error("should never resolved here"); diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/index.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/index.js deleted file mode 100644 index 8449c845709..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/index.js +++ /dev/null @@ -1,15 +0,0 @@ -const { graphql } = require("react-relay"); - -it("graphql", () => { - // https://github.com/web-infra-dev/rspack/issues/2440 - // This will transformed to require('./custom/MyComponent.graphql.ts'), - // If succeed, `require` would become `__webpack_require__`, - // Then it will resolved to mock.js - const mock = graphql` - fragment MyComponent on Type { - field - } - `; - - expect(mock.found).toBeTruthy(); -}); diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/mock.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/mock.js deleted file mode 100644 index 7911b6106eb..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/mock.js +++ /dev/null @@ -1,3 +0,0 @@ -module.exports = { - found: true -}; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/relay.config.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/relay.config.js deleted file mode 100644 index 5ec440eecb7..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/relay.config.js +++ /dev/null @@ -1,4 +0,0 @@ -module.exports = { - language: "typescript", - artifactDirectory: "custom" -}; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/rspack.config.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/rspack.config.js deleted file mode 100644 index d9854529216..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/relay-webpack-require/rspack.config.js +++ /dev/null @@ -1,27 +0,0 @@ -const { resolve } = require("path"); - -/** @type {import("@rspack/core").Configuration} */ -module.exports = { - resolve: { - alias: { - [resolve(__dirname, "./custom/MyComponent.graphql.ts")]: resolve( - __dirname, - "./mock.js" - ) - }, - extensions: ["...", ".ts", ".tsx", ".jsx"] - }, - module: { - rules: [ - { - test: /\.js$/, - loader: "builtin:swc-loader", - options: { - rspackExperiments: { - relay: true - } - } - } - ] - } -}; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/Button/index.jsx b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/Button/index.jsx deleted file mode 100644 index b6953c26160..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/Button/index.jsx +++ /dev/null @@ -1,17 +0,0 @@ -// @ts-ignore -import styled from "@xstyled/styled-components"; -import React from "react"; - -export const Button = () => { - return ( - - {/* @ts-ignore */} -
Hello, Rspack!
-
- ); -}; - -export const Container = styled.div` - padding: 2rem; - background-color: pink; -`; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/Button2/index.jsx b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/Button2/index.jsx deleted file mode 100644 index d82db267b51..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/Button2/index.jsx +++ /dev/null @@ -1,17 +0,0 @@ -// @ts-ignore -import { styled } from "@xstyled/styled-components"; -import React from "react"; - -export const Button = () => { - return ( - - {/* @ts-ignore */} -
Hello, Rspack!
-
- ); -}; - -export const Container = styled.div` - padding: 2rem; - background-color: pink; -`; diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/index.jsx b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/index.jsx deleted file mode 100644 index 5f63de1c27d..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/index.jsx +++ /dev/null @@ -1,11 +0,0 @@ -import { Container } from "./Button"; -import { Container as Container2 } from "./Button2"; - -it("styled components", () => { - expect(Container.styledComponentId).toMatch( - /^Button__Container-rspack-test__/ - ); - expect(Container2.styledComponentId).toMatch( - /^Button2__Container-rspack-test__/ - ); -}); diff --git a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/rspack.config.js b/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/rspack.config.js deleted file mode 100644 index ec413d6b090..00000000000 --- a/packages/rspack-test-tools/tests/configCases/builtin-swc-loader/styled-components/rspack.config.js +++ /dev/null @@ -1,43 +0,0 @@ -/** @type {import('@rspack/core').Configuration}*/ -module.exports = { - entry: "./index.jsx", - resolve: { - alias: { - "@xstyled/styled-components": "styled-components" - }, - extensions: ["...", ".ts", ".tsx", ".jsx"] - }, - module: { - rules: [ - { - test: /\.jsx?$/, - loader: "builtin:swc-loader", - options: { - jsc: { - parser: { - syntax: "ecmascript", - jsx: true - } - }, - rspackExperiments: { - styledComponents: { - displayName: true, - ssr: true, - fileName: true, - meaninglessFileNames: ["index", "styles"], - namespace: "rspack-test", - topLevelImportPaths: [ - "@xstyled/styled-components", - "@xstyled/styled-components/*" - ], - transpileTemplateLiterals: true, - minify: true, - pure: true, - cssProps: true - } - } - } - } - ] - } -}; diff --git a/packages/rspack/src/config/adapterRuleUse.ts b/packages/rspack/src/config/adapterRuleUse.ts index 88227766b88..0073f6b4aaa 100644 --- a/packages/rspack/src/config/adapterRuleUse.ts +++ b/packages/rspack/src/config/adapterRuleUse.ts @@ -207,20 +207,9 @@ type GetLoaderOptions = ( const getSwcLoaderOptions: GetLoaderOptions = (o, options) => { if (o && typeof o === "object" && o.rspackExperiments) { let expr = o.rspackExperiments; - const contextPath = options.context!; - const production = options.mode === "production" || !options.mode; - if (expr.emotion) { - expr.emotion = resolveEmotion(expr.emotion, production); - } - if (expr.relay) { - expr.relay = resolveRelay(expr.relay, contextPath); - } if (expr.import || expr.pluginImport) { expr.import = resolvePluginImport(expr.import || expr.pluginImport); } - if (expr.react) { - expr.react = resolveReact(expr.react); - } if (expr.preact) { expr.preact = resolvePreact(expr.preact); } diff --git a/website/docs/en/config/builtins.mdx b/website/docs/en/config/builtins.mdx index 4e48a7e8a29..2df3ff3ca52 100644 --- a/website/docs/en/config/builtins.mdx +++ b/website/docs/en/config/builtins.mdx @@ -3,7 +3,7 @@ import { ApiMeta, Stability } from '@components/ApiMeta.tsx'; # Builtins - + Used to set the built-in functions provided by Rspack. - **Type:** `Record` diff --git a/website/docs/en/guide/features/builtin-swc-loader.mdx b/website/docs/en/guide/features/builtin-swc-loader.mdx index 6cfee4025c8..e7253a58bc5 100644 --- a/website/docs/en/guide/features/builtin-swc-loader.mdx +++ b/website/docs/en/guide/features/builtin-swc-loader.mdx @@ -320,7 +320,17 @@ import 'antd/es/button/style'; ### rspackExperiments.relay - + + +:::warning +Please migrate to [builtin:swc-loader plugins](/guide/features/builtin-swc-loader#jscexperimentalplugins) with [@swc/plugin-relay](https://github.com/swc-project/plugins/tree/main/packages/relay) instead. + +Note: options might be _CHANGED_ accordingly, please refer to the document over there. +::: Converted `graphql` call expression to corresponding `require` call expression. @@ -343,7 +353,17 @@ If specific configuration is passed, Rspack will not attempt to locate any `rela ### rspackExperiments.emotion - + + +:::warning +Please migrate to [builtin:swc-loader plugins](/guide/features/builtin-swc-loader#jscexperimentalplugins) with [@swc/plugin-emotion](https://github.com/swc-project/plugins/tree/main/packages/emotion) instead. + +Note: options might be _CHANGED_ accordingly, please refer to the document over there. +::: Using optimization for emotion in compile-time. @@ -451,7 +471,17 @@ This option allows you to tell Rspack what imports it should look at to determin ### rspackExperiments.styledComponents - + + +:::warning +Please migrate to [builtin:swc-loader plugins](/guide/features/builtin-swc-loader#jscexperimentalplugins) with [@swc/plugin-styled-components](https://github.com/swc-project/plugins/tree/main/packages/styled-components) instead. + +Note: options might be _CHANGED_ accordingly, please refer to the document over there. +::: - **Type:** diff --git a/website/docs/zh/config/builtins.mdx b/website/docs/zh/config/builtins.mdx index 10d6c565711..bea7f4ead1d 100644 --- a/website/docs/zh/config/builtins.mdx +++ b/website/docs/zh/config/builtins.mdx @@ -4,7 +4,7 @@ import { Table } from '@builtIns'; # Builtins - + 内置功能:该选项用于设置 Rspack 提供的内置功能。 diff --git a/website/docs/zh/guide/features/builtin-swc-loader.mdx b/website/docs/zh/guide/features/builtin-swc-loader.mdx index 8824a6deb0a..1347694b49f 100644 --- a/website/docs/zh/guide/features/builtin-swc-loader.mdx +++ b/website/docs/zh/guide/features/builtin-swc-loader.mdx @@ -317,7 +317,17 @@ import 'antd/es/button/style'; ### rspackExperiments.relay - + + +:::warning +请迁移至 [builtin:swc-loader plugin 配置](/guide/features/builtin-swc-loader#jscexperimentalplugins),并使用 [@swc/plugin-relay](https://github.com/swc-project/plugins/tree/main/packages/relay). + +注意:配置可能会因此发生变化,请参考对应文档 +::: 将项目中的 `graphql` 调用转换成相对应的 `require`。 @@ -340,7 +350,17 @@ type RelayOptions = ### rspackExperiments.emotion - + + +:::warning +请迁移至 [builtin:swc-loader plugin 配置](/guide/features/builtin-swc-loader#jscexperimentalplugins),并使用 [@swc/plugin-emotion](https://github.com/swc-project/plugins/tree/main/packages/emotion). + +注意:配置可能会因此发生变化,请参考对应文档 +::: 用于设置对 emotion 的编译优化。 @@ -448,7 +468,17 @@ export type ImportMap = ### rspackExperiments.styledComponents - + + +:::warning +请迁移至 [builtin:swc-loader plugin 配置](/guide/features/builtin-swc-loader#jscexperimentalplugins),并使用 [@swc/plugin-styled-components](https://github.com/swc-project/plugins/tree/main/packages/styled-components). + +注意:配置可能会因此发生变化,请参考对应文档 +::: - **Type:** diff --git a/website/project-words.txt b/website/project-words.txt index 72f52afb916..99c76446e61 100644 --- a/website/project-words.txt +++ b/website/project-words.txt @@ -159,3 +159,4 @@ lightningcss Idents idents xxhash +jscexperimentalplugins \ No newline at end of file