Skip to content

Commit

Permalink
chore(deps): bump Rslib to v0.2.2 (#8859)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan authored Dec 26, 2024
1 parent 1e12553 commit 170b877
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 152 deletions.
2 changes: 1 addition & 1 deletion packages/create-rspack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"create-rstack": "1.0.6"
},
"devDependencies": {
"@rslib/core": "0.0.15",
"@rslib/core": "0.2.2",
"typescript": "^5.7.2"
},
"publishConfig": {
Expand Down
5 changes: 1 addition & 4 deletions packages/create-rspack/rslib.config.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { defineConfig } from "@rslib/core";

export default defineConfig({
lib: [{ format: "esm", syntax: "es2021" }],
output: {
target: "node"
}
lib: [{ format: "esm", syntax: "es2021" }]
});
2 changes: 1 addition & 1 deletion packages/rspack-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"yargs": "17.6.2"
},
"devDependencies": {
"@rslib/core": "0.0.15",
"@rslib/core": "0.2.2",
"@rspack/core": "workspace:*",
"@types/interpret": "^1.1.3",
"@types/rechoir": "^0.6.1",
Expand Down
3 changes: 0 additions & 3 deletions packages/rspack-cli/rslib.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,5 @@ export default defineConfig({
],
source: {
tsconfigPath: "./tsconfig.build.json"
},
output: {
target: "node"
}
});
11 changes: 2 additions & 9 deletions packages/rspack-cli/src/utils/crossImport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,13 @@ import { pathToFileURL } from "node:url";

import isEsmFile from "./isEsmFile";

/**
* Dynamically import files. It will make sure it's not being compiled away by TS/Rslib.
*/
export const dynamicImport = new Function("path", "return import(path)");

const crossImport = async <T = any>(
export const crossImport = async <T = any>(
path: string,
cwd = process.cwd()
): Promise<T> => {
if (isEsmFile(path, cwd)) {
const url = pathToFileURL(path).href;
const { default: config } = await dynamicImport(url);
const { default: config } = await import(url);
return config;
}
let result = require(path);
Expand All @@ -23,5 +18,3 @@ const crossImport = async <T = any>(
}
return result;
};

export default crossImport;
6 changes: 3 additions & 3 deletions packages/rspack-cli/src/utils/loadConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "node:fs";
import path from "node:path";
import type { MultiRspackOptions, RspackOptions } from "@rspack/core";
import type { RspackCLIOptions } from "../types";
import crossImport, { dynamicImport } from "./crossImport";
import { crossImport } from "./crossImport";
import findConfig from "./findConfig";
import isEsmFile from "./isEsmFile";
import isTsFile from "./isTsFile";
Expand All @@ -22,7 +22,7 @@ const registerLoader = async (configPath: string) => {
return;
}

const { default: interpret } = await dynamicImport("interpret");
const { default: interpret } = await import("interpret");
const extensions = Object.fromEntries(
Object.entries(interpret.extensions).filter(([key]) => key === ext)
);
Expand All @@ -31,7 +31,7 @@ const registerLoader = async (configPath: string) => {
}

try {
const { default: rechoir } = await dynamicImport("rechoir");
const { default: rechoir } = await import("rechoir");
rechoir.prepare(extensions, configPath);
} catch (error) {
const failures = (error as RechoirError)?.failures;
Expand Down
3 changes: 1 addition & 2 deletions packages/rspack-cli/src/utils/profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import inspector from "node:inspector";
import path from "node:path";
import { URLSearchParams } from "node:url";
import { type Compiler, type RspackOptions, rspack } from "@rspack/core";
import { dynamicImport } from "./crossImport";

type JSCPUProfileOptionsOutput = string;
type JSCPUProfileOptions = {
Expand Down Expand Up @@ -210,7 +209,7 @@ class RspackProfileLoggingPlugin {
}

export async function applyProfile(profileValue: string, item: RspackOptions) {
const { default: exitHook } = await dynamicImport("exit-hook");
const { default: exitHook } = await import("exit-hook");
const entries = Object.entries(resolveProfile(profileValue));
if (entries.length <= 0) return;
await fs.promises.mkdir(defaultOutputDirname);
Expand Down
Loading

0 comments on commit 170b877

Please sign in to comment.