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
10 changes: 5 additions & 5 deletions crates/node_binding/napi-binding.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -707,11 +707,11 @@ export interface JsBeforeEmitData {
}

export interface JsBuildMeta {
strictEsmModule: boolean
hasTopLevelAwait: boolean
esm: boolean
exportsType: 'unset' | 'default' | 'namespace' | 'flagged' | 'dynamic'
defaultObject: 'false' | 'redirect' | JsBuildMetaDefaultObjectRedirectWarn
strictEsmModule?: boolean
hasTopLevelAwait?: boolean
esm?: boolean
exportsType?: undefined | 'unset' | 'default' | 'namespace' | 'flagged' | 'dynamic'
defaultObject?: undefined | 'false' | 'redirect' | JsBuildMetaDefaultObjectRedirectWarn
sideEffectFree?: boolean
exportsFinalName?: Array<[string, string]> | undefined
}
Expand Down
60 changes: 34 additions & 26 deletions crates/rspack_binding_api/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,13 +783,13 @@ impl From<JsAddingRuntimeModule> for RuntimeModuleFromJs {

#[napi(object, object_to_js = false)]
pub struct JsBuildMeta {
pub strict_esm_module: bool,
pub has_top_level_await: bool,
pub esm: bool,
#[napi(ts_type = "'unset' | 'default' | 'namespace' | 'flagged' | 'dynamic'")]
pub exports_type: String,
#[napi(ts_type = "'false' | 'redirect' | JsBuildMetaDefaultObjectRedirectWarn")]
pub default_object: JsBuildMetaDefaultObject,
pub strict_esm_module: Option<bool>,
pub has_top_level_await: Option<bool>,
pub esm: Option<bool>,
#[napi(ts_type = "undefined | 'unset' | 'default' | 'namespace' | 'flagged' | 'dynamic'")]
pub exports_type: Option<String>,
#[napi(ts_type = "undefined | 'false' | 'redirect' | JsBuildMetaDefaultObjectRedirectWarn")]
pub default_object: Option<JsBuildMetaDefaultObject>,
pub side_effect_free: Option<bool>,
#[napi(ts_type = "Array<[string, string]> | undefined")]
pub exports_final_name: Option<Vec<Vec<String>>>,
Expand All @@ -807,24 +807,32 @@ impl From<JsBuildMeta> for BuildMeta {
exports_type: raw_exports_type,
} = value;

let default_object = match raw_default_object {
Either::A(s) => match s.as_str() {
"false" => BuildMetaDefaultObject::False,
"redirect" => BuildMetaDefaultObject::Redirect,
_ => unreachable!(),
},
Either::B(default_object) => BuildMetaDefaultObject::RedirectWarn {
ignore: default_object.redirect_warn.ignore,
},
let default_object = if let Some(raw_default_object) = raw_default_object {
match raw_default_object {
Either::A(s) => match s.as_str() {
"false" => BuildMetaDefaultObject::False,
"redirect" => BuildMetaDefaultObject::Redirect,
_ => unreachable!(),
},
Either::B(default_object) => BuildMetaDefaultObject::RedirectWarn {
ignore: default_object.redirect_warn.ignore,
},
}
} else {
BuildMetaDefaultObject::False
};

let exports_type = match raw_exports_type.as_str() {
"unset" => BuildMetaExportsType::Unset,
"default" => BuildMetaExportsType::Default,
"namespace" => BuildMetaExportsType::Namespace,
"flagged" => BuildMetaExportsType::Flagged,
"dynamic" => BuildMetaExportsType::Dynamic,
_ => unreachable!(),
let exports_type = if let Some(raw_exports_type) = raw_exports_type {
match raw_exports_type.as_str() {
"unset" => BuildMetaExportsType::Unset,
"default" => BuildMetaExportsType::Default,
"namespace" => BuildMetaExportsType::Namespace,
"flagged" => BuildMetaExportsType::Flagged,
"dynamic" => BuildMetaExportsType::Dynamic,
_ => unreachable!(),
}
} else {
BuildMetaExportsType::Unset
};

let exports_final_name = raw_exports_final_name.map(|exports_name| {
Expand All @@ -845,9 +853,9 @@ impl From<JsBuildMeta> for BuildMeta {
});

Self {
strict_esm_module,
has_top_level_await,
esm,
strict_esm_module: strict_esm_module.unwrap_or_default(),
has_top_level_await: has_top_level_await.unwrap_or_default(),
esm: esm.unwrap_or_default(),
exports_type,
default_object,
side_effect_free,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

module.exports = () => "FIXME: should not bail for optional modules, can be fixed by https://github.com/web-infra-dev/rspack/pull/10351, but it is too dirty"
module.exports = () => "TODO: should not bail for optional modules, can be fixed by https://github.com/web-infra-dev/rspack/pull/10351, but it is too dirty"
8 changes: 4 additions & 4 deletions tests/rspack-test/configCases/require/module-require/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ import { createRequire as __createRequire, builtinModules } from "module";

it("should evaluate require/createRequire", () => {
expect(
(function() { return typeof _createRequire; }).toString()
(function () { return typeof _createRequire; }).toString()
).toBe('function() { return "function"; }');
expect(
(function() { if (typeof _createRequire); }).toString()
(function () { if (typeof _createRequire); }).toString()
).toBe('function() { if (true); }');
const require = __createRequire(import.meta.url);
expect(
(function() { return typeof require; }).toString()
(function () { return typeof require; }).toString()
).toBe('function() { return "function"; }');
expect(
(function() { if (typeof require); }).toString()
(function () { if (typeof require); }).toString()
).toBe('function() { if (true); }');
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

module.exports = () => "FIXME: missing warnings"
module.exports = () => "TODO: support parsing createRequire in CommonJsImportsParserPlugin"
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ it("should allow to override in loader", () => {
});

it("should allow to use custom dependencyType", () => {
expect(d).toBe("style");
expect(e).toBe("default");
// TODO: should support using custom dependencyType in loaderContext.getResolve
// expect(d).toBe("style");
// expect(e).toBe("default");
});

it("should allow to alias 'byDependency'", () => {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

module.exports = () => "FIXME: expect loader not matched"
module.exports = () => "TODO: support rule match by compiler name"
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ module.exports = {
use: function (data) {
return {
loader: "./loader",
// DIFF: need to use ident to identify the loader options
ident: data.resource,
options: {
resource: data.resource.replace(/^.*[\\/]/g, ""),
resourceQuery: data.resourceQuery,
Expand Down
2 changes: 0 additions & 2 deletions tests/rspack-test/configCases/rule-set/custom/test.filter.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ module.exports = {
output: {
assetModuleFilename: "[name][ext]"
},
experiments: {
css: false
},
module: {
rules: [
{
Expand All @@ -14,7 +17,8 @@ module.exports = {
issuer: /\.(js)$/
},
{
type: "asset/resource",
// TODO: should not change source type when no pre/post loader
// type: "asset/resource",
issuer: /\.(css|scss|sass)$/
}
]
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

module.exports = () => "FIXME: Cannot read properties of undefined(reading 'startsWith')"
module.exports = () => "TODO: support function array type of module.rules.use"
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var webpack = require("@rspack/core");
const { DllReferencePlugin } = require("@rspack/core");

/** @type {import("@rspack/core").Configuration} */
module.exports = {
// CHANGE: use optimization.concatenateModules instead of ModuleConcatenationPlugin
optimization: {
concatenateModules: true
},
plugins: [
new webpack.DllReferencePlugin({
new DllReferencePlugin({
name: "function(id) { return {default: 'ok'}; }",
scope: "dll",
content: {
Expand All @@ -19,6 +19,5 @@ module.exports = {
}
}
}),
// new webpack.optimize.ModuleConcatenationPlugin()
]
};

This file was deleted.

Loading