@rspack/core
Advanced tools
Comparing version 0.7.0-canary-c216972-20240528031643 to 0.7.0-canary-db5d248-20240530004121
@@ -30,4 +30,9 @@ { | ||
"type": "string" | ||
}, | ||
"defaultExport": { | ||
"type": "boolean", | ||
"description": "Duplicate the named export with CSS modules locals to the default export (only when `esModules: true` for css-loader).", | ||
"link": "https://github.com/webpack-contrib/mini-css-extract-plugin#defaultexports" | ||
} | ||
} | ||
} |
@@ -12,2 +12,3 @@ import type { LoaderDefinition } from "../.."; | ||
layer?: boolean; | ||
defaultExport?: boolean; | ||
} | ||
@@ -14,0 +15,0 @@ declare const loader: LoaderDefinition; |
@@ -136,12 +136,35 @@ "use strict"; | ||
} | ||
const result = locals | ||
? namedExport | ||
? Object.keys(locals) | ||
.map(key => `\nexport var ${key} = ${(0, utils_1.stringifyLocal)( | ||
/** @type {Locals} */ locals[key])};`) | ||
.join("") | ||
: `\n${esModule ? "export default" : "module.exports ="} ${JSON.stringify(locals)};` | ||
: esModule | ||
? `\nexport {};` | ||
: ""; | ||
const result = (function makeResult() { | ||
if (locals) { | ||
if (namedExport) { | ||
const identifiers = Array.from((function* generateIdentifiers() { | ||
let identifierId = 0; | ||
for (const key of Object.keys(locals)) { | ||
identifierId += 1; | ||
yield [`_${identifierId.toString(16)}`, key]; | ||
} | ||
})()); | ||
const localsString = identifiers | ||
.map(([id, key]) => `\nvar ${id} = ${(0, utils_1.stringifyLocal)( | ||
/** @type {Locals} */ locals[key])};`) | ||
.join(""); | ||
const exportsString = `export { ${identifiers | ||
.map(([id, key]) => `${id} as ${JSON.stringify(key)}`) | ||
.join(", ")} }`; | ||
const defaultExport = typeof options.defaultExport !== "undefined" | ||
? options.defaultExport | ||
: false; | ||
return defaultExport | ||
? `${localsString}\n${exportsString}\nexport default { ${identifiers | ||
.map(([id, key]) => `${JSON.stringify(key)}: ${id}`) | ||
.join(", ")} }\n` | ||
: `${localsString}\n${exportsString}\n`; | ||
} | ||
return `\n${esModule ? "export default" : "module.exports = "} ${JSON.stringify(locals)};`; | ||
} | ||
else if (esModule) { | ||
return "\nexport {};"; | ||
} | ||
return ""; | ||
})(); | ||
let resultSource = `// extracted by ${index_1.CssExtractRspackPlugin.pluginName}`; | ||
@@ -148,0 +171,0 @@ // only attempt hotreloading if the css is actually used for something other than hash values |
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
import { Compilation } from "../Compilation"; | ||
import { Mode, Resolve, RuleSetUseItem } from "./zod"; | ||
import { Mode, Resolve, RuleSetUseItem, Target } from "./zod"; | ||
export interface ComposeJsUseOptions { | ||
@@ -80,2 +80,3 @@ devtool: RawOptions["devtool"]; | ||
mode?: Mode; | ||
target?: Target; | ||
hot?: boolean; | ||
@@ -82,0 +83,0 @@ /** |
@@ -85,2 +85,6 @@ "use strict"; | ||
applyNodeDefaults(options.node, { targetProperties }); | ||
applyLoaderDefaults(options.loader, { | ||
targetProperties, | ||
environment: options.output.environment | ||
}); | ||
F(options, "performance", () => production && | ||
@@ -604,2 +608,24 @@ targetProperties && | ||
}; | ||
const applyLoaderDefaults = (loader, { targetProperties, environment }) => { | ||
F(loader, "target", () => { | ||
if (targetProperties) { | ||
if (targetProperties.electron) { | ||
if (targetProperties.electronMain) | ||
return "electron-main"; | ||
if (targetProperties.electronPreload) | ||
return "electron-preload"; | ||
if (targetProperties.electronRenderer) | ||
return "electron-renderer"; | ||
return "electron"; | ||
} | ||
if (targetProperties.nwjs) | ||
return "nwjs"; | ||
if (targetProperties.node) | ||
return "node"; | ||
if (targetProperties.web) | ||
return "web"; | ||
} | ||
}); | ||
D(loader, "environment", environment); | ||
}; | ||
const applyNodeDefaults = (node, { targetProperties }) => { | ||
@@ -606,0 +632,0 @@ if (node === false) |
@@ -11,3 +11,3 @@ /** | ||
import type { Compilation } from "../Compilation"; | ||
import type { AssetModuleFilename, Bail, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryFilename, EntryRuntime, Environment, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, InfrastructureLogging, LazyCompilationOptions, LibraryOptions, Mode, Name, Node, NoParseOption, Optimization, OutputModule, ParserOptionsByModuleType, Path, Performance, Plugins, Profile, PublicPath, Resolve, RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath } from "./zod"; | ||
import type { AssetModuleFilename, Bail, CacheOptions, ChunkFilename, ChunkLoading, ChunkLoadingGlobal, Clean, Context, CrossOriginLoading, CssChunkFilename, CssFilename, Dependencies, DevServer, DevTool, DevtoolFallbackModuleFilenameTemplate, DevtoolModuleFilenameTemplate, DevtoolNamespace, EnabledLibraryTypes, EnabledWasmLoadingTypes, EntryFilename, EntryRuntime, Environment, Externals, ExternalsPresets, ExternalsType, Filename, GeneratorOptionsByModuleType, GlobalObject, HashDigest, HashDigestLength, HashFunction, HashSalt, HotUpdateChunkFilename, HotUpdateGlobal, HotUpdateMainFilename, Iife, ImportFunctionName, InfrastructureLogging, LazyCompilationOptions, LibraryOptions, Loader, Mode, Name, Node, NoParseOption, Optimization, OutputModule, ParserOptionsByModuleType, Path, Performance, Plugins, Profile, PublicPath, Resolve, RspackFutureOptions, RspackOptions, RuleSetRules, ScriptType, SnapshotOptions, SourceMapFilename, StatsValue, StrictModuleErrorHandling, Target, TrustedTypes, UniqueName, WasmLoading, Watch, WatchOptions, WebassemblyModuleFilename, WorkerPublicPath } from "./zod"; | ||
export declare const getNormalizedRspackOptions: (config: RspackOptions) => RspackOptionsNormalized; | ||
@@ -114,2 +114,3 @@ export type EntryDynamicNormalized = () => Promise<EntryStaticNormalized>; | ||
node: Node; | ||
loader: Loader; | ||
snapshot: SnapshotOptions; | ||
@@ -116,0 +117,0 @@ cache?: CacheOptions; |
@@ -147,2 +147,3 @@ "use strict"; | ||
}), | ||
loader: cloneObject(config.loader), | ||
snapshot: nestedConfig(config.snapshot, _snapshot => ({})), | ||
@@ -149,0 +150,0 @@ cache: optionalNestedConfig(config.cache, cache => cache), |
@@ -588,2 +588,3 @@ "use strict"; | ||
const node = zod_1.z.literal(false).or(nodeOptions); | ||
const loader = zod_1.z.record(zod_1.z.string(), zod_1.z.any()); | ||
//#endregion | ||
@@ -832,2 +833,3 @@ //#region Snapshot | ||
node: node.optional(), | ||
loader: loader.optional(), | ||
ignoreWarnings: ignoreWarnings.optional(), | ||
@@ -834,0 +836,0 @@ watchOptions: watchOptions.optional(), |
@@ -342,2 +342,3 @@ "use strict"; | ||
loaderContext.mode = compiler.options.mode; | ||
Object.assign(loaderContext, compiler.options.loader); | ||
const getResolveContext = () => { | ||
@@ -344,0 +345,0 @@ // FIXME: resolve's fileDependencies will includes lots of dir, '/', etc |
{ | ||
"name": "@rspack/core", | ||
"version": "0.7.0-canary-c216972-20240528031643", | ||
"version": "0.7.0-canary-db5d248-20240530004121", | ||
"webpackVersion": "5.75.0", | ||
@@ -75,4 +75,4 @@ "license": "MIT", | ||
"zod-validation-error": "1.3.1", | ||
"@rspack/core": "0.7.0-canary-c216972-20240528031643", | ||
"@rspack/plugin-minify": "^0.7.0-canary-c216972-20240528031643" | ||
"@rspack/core": "0.7.0-canary-db5d248-20240530004121", | ||
"@rspack/plugin-minify": "^0.7.0-canary-db5d248-20240530004121" | ||
}, | ||
@@ -84,3 +84,3 @@ "dependencies": { | ||
"webpack-sources": "3.2.3", | ||
"@rspack/binding": "0.7.0-canary-c216972-20240528031643" | ||
"@rspack/binding": "0.7.0-canary-db5d248-20240530004121" | ||
}, | ||
@@ -87,0 +87,0 @@ "peerDependencies": { |
Sorry, the diff of this file is too big to display
2496461
64606
+ Added@rspack/binding@0.7.0-canary-db5d248-20240530004121(transitive)
+ Added@rspack/binding-darwin-arm64@0.7.0-canary-db5d248-20240530004121(transitive)
+ Added@rspack/binding-darwin-x64@0.7.0-canary-db5d248-20240530004121(transitive)
+ Added@rspack/binding-linux-arm64-gnu@0.7.0-canary-db5d248-20240530004121(transitive)
+ Added@rspack/binding-linux-arm64-musl@0.7.0-canary-db5d248-20240530004121(transitive)
+ Added@rspack/binding-linux-x64-gnu@0.7.0-canary-db5d248-20240530004121(transitive)
+ Added@rspack/binding-linux-x64-musl@0.7.0-canary-db5d248-20240530004121(transitive)
+ Added@rspack/binding-win32-arm64-msvc@0.7.0-canary-db5d248-20240530004121(transitive)
+ Added@rspack/binding-win32-ia32-msvc@0.7.0-canary-db5d248-20240530004121(transitive)
+ Added@rspack/binding-win32-x64-msvc@0.7.0-canary-db5d248-20240530004121(transitive)
- Removed@rspack/binding@0.7.0-canary-c216972-20240528031643(transitive)
- Removed@rspack/binding-darwin-arm64@0.7.0-canary-c216972-20240528031643(transitive)
- Removed@rspack/binding-darwin-x64@0.7.0-canary-c216972-20240528031643(transitive)
- Removed@rspack/binding-linux-arm64-gnu@0.7.0-canary-c216972-20240528031643(transitive)
- Removed@rspack/binding-linux-arm64-musl@0.7.0-canary-c216972-20240528031643(transitive)
- Removed@rspack/binding-linux-x64-gnu@0.7.0-canary-c216972-20240528031643(transitive)
- Removed@rspack/binding-linux-x64-musl@0.7.0-canary-c216972-20240528031643(transitive)
- Removed@rspack/binding-win32-arm64-msvc@0.7.0-canary-c216972-20240528031643(transitive)
- Removed@rspack/binding-win32-ia32-msvc@0.7.0-canary-c216972-20240528031643(transitive)
- Removed@rspack/binding-win32-x64-msvc@0.7.0-canary-c216972-20240528031643(transitive)