@rspack/core
Advanced tools
Comparing version 0.0.0-20221101082124 to 0.0.0-20221102021023
@@ -41,3 +41,6 @@ import * as binding from "@rspack/binding"; | ||
unsafe_build(cb: Callback<Error, binding.StatsCompilation>): void; | ||
unsafe_rebuild(changedFiles: string[], cb: (error?: Error, stats?: binding.DiffStat) => void): void; | ||
unsafe_rebuild(changedFiles: string[], cb: (error?: Error, stats?: { | ||
diff: binding.DiffStat; | ||
stats: binding.StatsCompilation; | ||
}) => void): void; | ||
watch(watchOptions?: Watch, ws?: any): Promise<Watching>; | ||
@@ -44,0 +47,0 @@ purgeInputFileSystem(): void; |
@@ -214,2 +214,3 @@ "use strict"; | ||
const options = (0, watch_1.resolveWatchOption)(watchOptions); | ||
let logger = this.getInfrastructureLogger("watch"); | ||
const watcher = (await Promise.resolve().then(() => __importStar(require("chokidar")))).default.watch(this.options.context, { | ||
@@ -221,2 +222,5 @@ ignoreInitial: true, | ||
let stats = await util_1.default.promisify(this.unsafe_build.bind(this))(); | ||
if (stats.errors.length > 0) { | ||
logger.error("build failed:", stats.errors.map(x => x.message).join("\n")); | ||
} | ||
console.log("build success, time cost", Date.now() - begin, "ms"); | ||
@@ -240,3 +244,6 @@ let pendingChangedFilepaths = new Set(); | ||
const begin = Date.now(); | ||
this.unsafe_rebuild(changedFilepath, (error, diffStats) => { | ||
this.unsafe_rebuild(changedFilepath, (error, { diff, stats }) => { | ||
if (stats.errors.length > 0) { | ||
logger.error("build error:", stats.errors.map(err => err.message).join("\n")); | ||
} | ||
isBuildFinished = true; | ||
@@ -253,3 +260,3 @@ const hasPending = Boolean(pendingChangedFilepaths.size); | ||
} | ||
for (const [uri, stats] of Object.entries(diffStats)) { | ||
for (const [uri, stats] of Object.entries(diff)) { | ||
let relativePath = path_1.default.relative(this.options.context, uri); | ||
@@ -292,3 +299,3 @@ if (!(relativePath.startsWith("../") || relativePath.startsWith("./"))) { | ||
} | ||
console.log("rebuild success, time cost", Date.now() - begin); | ||
console.log("rebuild success, time cost", Date.now() - begin, "ms"); | ||
}); | ||
@@ -295,0 +302,0 @@ }; |
@@ -1,9 +0,14 @@ | ||
import type { RawBuiltins } from "@rspack/binding"; | ||
export declare type Builtins = Omit<RawBuiltins, "browserslist"> & { | ||
import type { RawBuiltins, RawHtmlPluginConfig } from "@rspack/binding"; | ||
export declare type BuiltinsHtmlPluginConfig = Omit<RawHtmlPluginConfig, "meta"> & { | ||
meta?: Record<string, string | Record<string, string>>; | ||
}; | ||
export declare type Builtins = Omit<RawBuiltins, "browserslist" | "html"> & { | ||
polyfillBuiltins?: boolean; | ||
html?: Array<BuiltinsHtmlPluginConfig>; | ||
}; | ||
export declare type ResolvedBuiltins = RawBuiltins & { | ||
export declare type ResolvedBuiltins = Omit<RawBuiltins, "html"> & { | ||
polyfillBuiltins?: boolean; | ||
html?: Array<BuiltinsHtmlPluginConfig>; | ||
}; | ||
export declare function resolveBuiltinsOptions(builtins: Builtins, contextPath: string): ResolvedBuiltins; | ||
//# sourceMappingURL=builtins.d.ts.map |
@@ -12,2 +12,16 @@ "use strict"; | ||
} | ||
function resolveHtml(html) { | ||
return html.map(c => { | ||
for (const key in c.meta) { | ||
const value = c.meta[key]; | ||
if (typeof value === "string") { | ||
c.meta[key] = { | ||
name: key, | ||
content: value | ||
}; | ||
} | ||
} | ||
return c; | ||
}); | ||
} | ||
function resolveBuiltinsOptions(builtins, contextPath) { | ||
@@ -17,2 +31,3 @@ const browserslist = (0, browserslist_1.loadConfig)({ path: contextPath }) || []; | ||
...builtins, | ||
html: resolveHtml(builtins.html || []), | ||
browserslist | ||
@@ -19,0 +34,0 @@ }; |
@@ -11,5 +11,8 @@ "use strict"; | ||
const devClientEntryPath = require.resolve("@rspack/dev-client"); | ||
const hotUpdateEntryPath = require.resolve("@rspack/dev-client/devServer"); | ||
const reactRefreshEntryPath = require.resolve("@rspack/dev-client/react-refresh"); | ||
const additionalEntry = { | ||
"rspack-dev-client": [devClientEntryPath], | ||
"rspack-hot-update": [require.resolve("@rspack/dev-client/devServer")] | ||
_rspack_dev_client: [devClientEntryPath], | ||
_rspack_hot_update: [hotUpdateEntryPath], | ||
_rspack_react_refresh: [reactRefreshEntryPath] | ||
}; | ||
@@ -16,0 +19,0 @@ return additionalEntry; |
@@ -44,16 +44,2 @@ "use strict"; | ||
exports.resolveEntryOptions = resolveEntryOptions; | ||
// export function resolveEntryOptions( | ||
// entry: Record<string, string> | string, | ||
// options: { context: string; dev: boolean } | ||
// ) { | ||
// if (typeof entry === "string") { | ||
// entry = { | ||
// main: entry | ||
// }; | ||
// } | ||
// return { | ||
// ...mapValues(entry, item => path.resolve(options.context, item)), | ||
// ...(options.dev ? getAdditionDevEntry() : {}) | ||
// }; | ||
// } | ||
//# sourceMappingURL=entry.js.map |
@@ -41,3 +41,3 @@ import type { Context, ResolvedContext } from "./context"; | ||
externals: ResolvedExternal; | ||
externalType: ResolvedExternalType; | ||
externalsType: ResolvedExternalType; | ||
output: ResolvedOutput; | ||
@@ -44,0 +44,0 @@ builtins: ResolvedBuiltins; |
@@ -24,3 +24,3 @@ "use strict"; | ||
const externals = (_c = config.externals) !== null && _c !== void 0 ? _c : {}; | ||
const externalType = (_d = config.externalsType) !== null && _d !== void 0 ? _d : ""; | ||
const externalsType = (_d = config.externalsType) !== null && _d !== void 0 ? _d : ""; | ||
const plugins = (_e = config.plugins) !== null && _e !== void 0 ? _e : []; | ||
@@ -40,3 +40,3 @@ const builtins = (0, builtins_1.resolveBuiltinsOptions)(config.builtins || {}, context); | ||
externals, | ||
externalType, | ||
externalsType, | ||
plugins, | ||
@@ -43,0 +43,0 @@ builtins, |
@@ -6,2 +6,3 @@ /// <reference types="node" /> | ||
export interface ModuleRule { | ||
name?: string; | ||
test?: RawModuleRule["test"]; | ||
@@ -70,5 +71,7 @@ resource?: RawModuleRule["resource"]; | ||
options?: unknown; | ||
name?: string; | ||
} | { | ||
loader: JsLoader; | ||
options?: unknown; | ||
name?: string; | ||
}; | ||
@@ -75,0 +78,0 @@ export declare function createRawModuleRuleUses(uses: ModuleRuleUse[], options: ComposeJsUseOptions): RawModuleRuleUse[]; |
@@ -55,3 +55,3 @@ "use strict"; | ||
"zlib", | ||
/^node:/, | ||
// /^node:/, | ||
// cspell:word pnpapi | ||
@@ -61,9 +61,5 @@ // Yarn PnP adds pnpapi as "builtin" | ||
]; | ||
// We do not support externalsType.node-commonjs yet, so I have to use eval to hack around the limitation | ||
function toEval(modName) { | ||
return `eval('require("${modName}")')`; | ||
} | ||
class NodeTargetPlugin { | ||
apply(compiler) { | ||
const externals = Object.fromEntries(builtins.map(x => [x, toEval(x)])); | ||
const externals = Object.fromEntries(builtins.map(x => [x, x])); | ||
compiler.options.externals = { | ||
@@ -70,0 +66,0 @@ ...externals, |
{ | ||
"name": "@rspack/core", | ||
"version": "0.0.0-20221101082124", | ||
"version": "0.0.0-20221102021023", | ||
"main": "./dist/index.js", | ||
@@ -10,3 +10,3 @@ "types": "./dist/index.d.ts", | ||
"devDependencies": { | ||
"@rspack/core": "0.0.0-20221101082124", | ||
"@rspack/core": "0.0.0-20221102021023", | ||
"@swc/helpers": "^0.4.12", | ||
@@ -28,6 +28,6 @@ "@types/jest": "29.0.2", | ||
"dependencies": { | ||
"@rspack/binding": "0.0.0-20221101082124", | ||
"@rspack/dev-client": "0.0.0-20221101082124", | ||
"@rspack/plugin-less": "^0.0.0-20221101082124", | ||
"@rspack/plugin-postcss": "^0.0.0-20221101082124", | ||
"@rspack/binding": "0.0.0-20221102021023", | ||
"@rspack/dev-client": "0.0.0-20221102021023", | ||
"@rspack/plugin-less": "^0.0.0-20221102021023", | ||
"@rspack/plugin-postcss": "^0.0.0-20221102021023", | ||
"browserslist": "^4.21.3", | ||
@@ -34,0 +34,0 @@ "chokidar": "3.5.3", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
215826
3185
+ Added@rspack/binding@0.0.0-20221102021023(transitive)
+ Added@rspack/dev-client@0.0.0-20221102021023(transitive)
- Removed@rspack/binding@0.0.0-20221101082124(transitive)
- Removed@rspack/dev-client@0.0.0-20221101082124(transitive)