Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion crates/node_binding/napi-binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2130,7 +2130,6 @@ export interface RawEvalDevToolModulePluginOptions {
}

export interface RawExperiments {
topLevelAwait: boolean
incremental?: false | { [key: string]: boolean }
useInputFileSystem?: false | Array<RegExp>
css?: boolean
Expand Down
13 changes: 0 additions & 13 deletions crates/rspack/src/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3645,8 +3645,6 @@ impl OptimizationOptionsBuilder {
pub struct ExperimentsBuilder {
/// Incremental passes.
incremental: Option<IncrementalOptions>,
/// Whether to enable top level await.
top_level_await: Option<bool>,
/// Whether to enable output module.
output_module: Option<bool>,
/// Whether to enable future defaults.
Expand All @@ -3662,7 +3660,6 @@ impl From<Experiments> for ExperimentsBuilder {
fn from(value: Experiments) -> Self {
ExperimentsBuilder {
incremental: Some(value.incremental),
top_level_await: Some(value.top_level_await),
output_module: None,
future_defaults: None,
css: Some(value.css),
Expand All @@ -3675,7 +3672,6 @@ impl From<&mut ExperimentsBuilder> for ExperimentsBuilder {
fn from(value: &mut ExperimentsBuilder) -> Self {
ExperimentsBuilder {
incremental: value.incremental.take(),
top_level_await: value.top_level_await.take(),
output_module: value.output_module.take(),
future_defaults: value.future_defaults.take(),
css: value.css.take(),
Expand All @@ -3691,12 +3687,6 @@ impl ExperimentsBuilder {
self
}

/// Set whether to enable top level await.
pub fn top_level_await(&mut self, top_level_await: bool) -> &mut Self {
self.top_level_await = Some(top_level_await);
self
}

/// Set whether to enable future defaults.
pub fn future_defaults(&mut self, future_defaults: bool) -> &mut Self {
self.future_defaults = Some(future_defaults);
Expand Down Expand Up @@ -3735,8 +3725,6 @@ impl ExperimentsBuilder {
passes,
}
});
let top_level_await = d!(self.top_level_await, true);

// Builder specific
let future_defaults = w!(self.future_defaults, false);
w!(self.css, *future_defaults);
Expand All @@ -3745,7 +3733,6 @@ impl ExperimentsBuilder {

Ok(Experiments {
incremental,
top_level_await,
css: d!(self.css, false),
lazy_barrel: true,
defer_import: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1514,7 +1514,6 @@ CompilerOptions {
MAKE | EMIT_ASSETS,
),
},
top_level_await: true,
css: false,
lazy_barrel: true,
defer_import: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use super::WithFalse;
#[derive(Debug)]
#[napi(object, object_to_js = false)]
pub struct RawExperiments {
pub top_level_await: bool,
#[napi(ts_type = "false | { [key: string]: boolean }")]
pub incremental: Option<WithFalse<RawIncremental>>,
#[napi(ts_type = "false | Array<RegExp>")]
Expand All @@ -30,7 +29,6 @@ impl From<RawExperiments> for Experiments {
},
None => IncrementalOptions::empty_passes(),
},
top_level_await: value.top_level_await,
css: value.css.unwrap_or(false),
lazy_barrel: value.lazy_barrel,
defer_import: value.defer_import,
Expand Down
1 change: 0 additions & 1 deletion crates/rspack_core/src/options/experiments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use crate::incremental::IncrementalOptions;
#[derive(Debug)]
pub struct Experiments {
pub incremental: IncrementalOptions,
pub top_level_await: bool,
pub css: bool,
pub lazy_barrel: bool,
pub defer_import: bool,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,8 @@ impl JavascriptParser<'_> {
);
}

fn handle_top_level_await(&mut self, allow_top_level: bool, span: Span) {
if !allow_top_level {
self.throw_top_level_await_error("The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)".into(), span);
} else if self.is_esm {
fn handle_top_level_await(&mut self, span: Span) {
if self.is_esm {
self.build_meta.has_top_level_await = true;
} else {
self.throw_top_level_await_error(
Expand All @@ -41,15 +39,8 @@ impl JavascriptParser<'_> {
}
}

pub struct ESMDetectionParserPlugin {
top_level_await: bool,
}

impl ESMDetectionParserPlugin {
pub fn new(top_level_await: bool) -> Self {
Self { top_level_await }
}
}
#[derive(Default)]
pub struct ESMDetectionParserPlugin;

// nonHarmonyIdentifiers
fn is_non_esm_identifier(name: &str) -> bool {
Expand Down Expand Up @@ -87,7 +78,7 @@ impl JavascriptParserPlugin for ESMDetectionParserPlugin {
let lo = expr.span_lo();
let hi = lo.add(BytePos(AWAIT_LEN));
let span = Span::new(lo, hi);
parser.handle_top_level_await(self.top_level_await, span);
parser.handle_top_level_await(span);
}

fn top_level_for_of_await_stmt(
Expand All @@ -99,7 +90,7 @@ impl JavascriptParserPlugin for ESMDetectionParserPlugin {
let lo = stmt.span_lo().add(BytePos(offset));
let hi = lo.add(BytePos(AWAIT_LEN));
let span = Span::new(lo, hi);
parser.handle_top_level_await(self.top_level_await, span);
parser.handle_top_level_await(span);
}

fn evaluate_typeof<'a>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,7 @@ impl<'parser> JavascriptParser<'parser> {

if module_type.is_js_auto() || module_type.is_js_esm() {
plugins.push(Box::new(parser_plugin::ESMTopLevelThisParserPlugin));
plugins.push(Box::new(parser_plugin::ESMDetectionParserPlugin::new(
compiler_options.experiments.top_level_await,
)));
plugins.push(Box::new(parser_plugin::ESMDetectionParserPlugin::default()));
plugins.push(Box::new(
parser_plugin::ImportMetaContextDependencyParserPlugin,
));
Expand Down
1 change: 0 additions & 1 deletion packages/rspack-test-tools/src/case/normal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ function defaultOptions(
experiments: {
css: false,
asyncWebAssembly: true,
topLevelAwait: true,
// CHANGE: rspack does not support `backCompat` yet.
// backCompat: false,
// CHANGE: Rspack enables `css` by default.
Expand Down
3 changes: 0 additions & 3 deletions packages/rspack/etc/core.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -2439,7 +2439,6 @@ interface ExecuteModuleContext {
export type Experiments = {
asyncWebAssembly?: boolean;
outputModule?: boolean;
topLevelAwait?: boolean;
css?: boolean;
layers?: boolean;
incremental?: IncrementalPresets | Incremental;
Expand Down Expand Up @@ -2525,8 +2524,6 @@ export interface ExperimentsNormalized {
// (undocumented)
outputModule?: boolean;
// (undocumented)
topLevelAwait?: boolean;
// (undocumented)
typeReexportsPresence?: boolean;
// (undocumented)
useInputFileSystem?: false | RegExp[];
Expand Down
1 change: 0 additions & 1 deletion packages/rspack/src/config/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,6 @@ const applyExperimentsDefaults = (experiments: ExperimentsNormalized) => {
D(experiments, 'futureDefaults', false);
D(experiments, 'asyncWebAssembly', experiments.futureDefaults);
D(experiments, 'css', experiments.futureDefaults ? true : undefined);
D(experiments, 'topLevelAwait', true);
D(experiments, 'deferImport', false);

D(experiments, 'buildHttp', undefined);
Expand Down
6 changes: 0 additions & 6 deletions packages/rspack/src/config/normalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,11 +379,6 @@ export const getNormalizedRspackOptions = (
'`experiments.layers` config is deprecated and will be removed in Rspack v2.0. Feature layers will always be enabled. Remove this option from your Rspack configuration.',
);
}
if (experiments.topLevelAwait === false) {
deprecate(
'`experiments.topLevelAwait` config is deprecated and will be removed in Rspack v2.0. Top-level await will always be enabled. Remove this option from your Rspack configuration.',
);
}
if (experiments.lazyBarrel) {
deprecate(
'`experiments.lazyBarrel` config is deprecated and will be removed in Rspack v2.0. Lazy barrel is already stable and enabled by default. Remove this option from your Rspack configuration.',
Expand Down Expand Up @@ -673,7 +668,6 @@ export type CacheNormalized =
export interface ExperimentsNormalized {
asyncWebAssembly?: boolean;
outputModule?: boolean;
topLevelAwait?: boolean;
css?: boolean;
/**
* @deprecated This option is deprecated, layers is enabled since v1.6.0
Expand Down
6 changes: 0 additions & 6 deletions packages/rspack/src/config/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2763,12 +2763,6 @@ export type Experiments = {
* @default false
*/
outputModule?: boolean;
/**
* Enable top-level await.
* @deprecated This option is deprecated, top-level await is enabled by default.
* @default true
*/
topLevelAwait?: boolean;
/**
* Enable CSS support.
*
Expand Down
1 change: 0 additions & 1 deletion tests/rspack-test/Defaults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ function assertWebpackConfig(config) {
trimObjectPaths(webpackBaseConfig, ignoredPaths);
filterObjectPaths(webpackBaseConfig, rspackSupportedConfig);
// PATCH DIFF
delete rspackBaseConfig.experiments.topLevelAwait;
delete rspackBaseConfig.optimization.inlineExports;
expect(rspackBaseConfig).toEqual(webpackBaseConfig);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@ module.exports = {
}
})
],
experiments: {
topLevelAwait: true
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,5 @@ module.exports = {
}
})
],
experiments: {
topLevelAwait: true
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,5 @@ module.exports = {
}
]
},
experiments: {
topLevelAwait: true
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { HotModuleReplacementPlugin } = require("@rspack/core");
/** @type {import("@rspack/core").Configuration} */
module.exports = {
devtool: false,
experiments: { topLevelAwait: true },
optimization: { usedExports: false, sideEffects: false },
plugins: [new HotModuleReplacementPlugin()]
};
1 change: 0 additions & 1 deletion tests/rspack-test/defaultsCases/default/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ module.exports = {
inlineConst: true,
inlineEnum: false,
lazyBarrel: true,
topLevelAwait: true,
typeReexportsPresence: false,
useInputFileSystem: false,
},
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,5 @@ module.exports = {
optimization: {
chunkIds: "deterministic" // To keep filename consistent between different modes (for example building only)
},
experiments: {
topLevelAwait: true
}

};
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ module.exports = {
},
experiments: {
asyncWebAssembly: true,
topLevelAwait: true
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = {
minimize: true
},
experiments: {
topLevelAwait: true,
outputModule: true
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ module.exports = (env, { testPath }) => ({
}
},
experiments: {
topLevelAwait: true,
outputModule: true
}
});
Loading
Loading