shakapacker 9.3.0.beta.4 → 9.3.0.beta.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -3
- data/CLAUDE.md +13 -0
- data/Gemfile.lock +1 -1
- data/README.md +19 -0
- data/docs/configuration.md +35 -0
- data/docs/early_hints.md +426 -0
- data/docs/early_hints_manual_api.md +454 -0
- data/docs/feature_testing.md +492 -0
- data/lib/install/config/shakapacker.yml +27 -0
- data/lib/shakapacker/configuration.rb +4 -0
- data/lib/shakapacker/helper.rb +409 -14
- data/lib/shakapacker/railtie.rb +4 -0
- data/lib/shakapacker/version.rb +1 -1
- data/package/configExporter/buildValidator.ts +1 -2
- data/package/configExporter/cli.ts +194 -28
- data/package/configExporter/fileWriter.ts +17 -8
- data/package/configExporter/types.ts +6 -1
- data/package/utils/errorCodes.ts +1 -0
- data/package/utils/errorHelpers.ts +16 -12
- data/package-lock.json +2 -2
- data/package.json +2 -2
- data/scripts/remove-use-strict.js +0 -1
- data/test/package/configExporter.test.js +45 -0
- data/test/package/rules/babel.test.js +1 -0
- data/test/package/rules/swc.test.js +1 -0
- metadata +5 -2
|
@@ -596,6 +596,9 @@ async function runValidateCommand(options: ExportOptions): Promise<number> {
|
|
|
596
596
|
clearBuildEnvironmentVariables()
|
|
597
597
|
restoreBuildEnvironmentVariables(savedEnv)
|
|
598
598
|
|
|
599
|
+
// Clear shakapacker config cache between builds
|
|
600
|
+
shakapackerConfigCache = null
|
|
601
|
+
|
|
599
602
|
// Get the build's environment to use for auto-detection
|
|
600
603
|
const buildConfig = config.builds[buildName]
|
|
601
604
|
const buildEnv =
|
|
@@ -692,6 +695,9 @@ async function runAllBuildsCommand(options: ExportOptions): Promise<number> {
|
|
|
692
695
|
clearBuildEnvironmentVariables()
|
|
693
696
|
restoreBuildEnvironmentVariables(savedEnv)
|
|
694
697
|
|
|
698
|
+
// Clear shakapacker config cache between builds
|
|
699
|
+
shakapackerConfigCache = null
|
|
700
|
+
|
|
695
701
|
// Create a modified options object for this build
|
|
696
702
|
const buildOptions = { ...resolvedOptions, build: buildName }
|
|
697
703
|
const configs = await loadConfigsForEnv(undefined, buildOptions, appRoot)
|
|
@@ -770,6 +776,9 @@ async function runDoctorMode(
|
|
|
770
776
|
clearBuildEnvironmentVariables()
|
|
771
777
|
restoreBuildEnvironmentVariables(savedEnv)
|
|
772
778
|
|
|
779
|
+
// Clear shakapacker config cache between builds
|
|
780
|
+
shakapackerConfigCache = null
|
|
781
|
+
|
|
773
782
|
const configs = await loadConfigsForEnv(
|
|
774
783
|
undefined,
|
|
775
784
|
{ ...options, build: buildName },
|
|
@@ -798,9 +807,13 @@ async function runDoctorMode(
|
|
|
798
807
|
// If config file exists but is invalid, show error and exit
|
|
799
808
|
const errorMessage =
|
|
800
809
|
error instanceof Error ? error.message : String(error)
|
|
801
|
-
console.error(`\n❌
|
|
810
|
+
console.error(`\n❌ Error loading build configuration:`)
|
|
811
|
+
console.error(`\n${errorMessage}`)
|
|
812
|
+
console.error(
|
|
813
|
+
`\n💡 To fix this issue, check your build config in ${configFilePath}`
|
|
814
|
+
)
|
|
802
815
|
console.error(
|
|
803
|
-
`
|
|
816
|
+
` or run: bin/shakapacker-config --init to regenerate it.\n`
|
|
804
817
|
)
|
|
805
818
|
throw error
|
|
806
819
|
}
|
|
@@ -825,6 +838,9 @@ async function runDoctorMode(
|
|
|
825
838
|
clearBuildEnvironmentVariables()
|
|
826
839
|
restoreBuildEnvironmentVariables(savedEnv)
|
|
827
840
|
|
|
841
|
+
// Clear shakapacker config cache between builds
|
|
842
|
+
shakapackerConfigCache = null
|
|
843
|
+
|
|
828
844
|
// Set WEBPACK_SERVE for HMR config
|
|
829
845
|
if (hmr) {
|
|
830
846
|
process.env.WEBPACK_SERVE = "true"
|
|
@@ -1039,6 +1055,12 @@ async function loadConfigsForEnv(
|
|
|
1039
1055
|
"DYLD_INSERT_LIBRARIES"
|
|
1040
1056
|
]
|
|
1041
1057
|
|
|
1058
|
+
if (process.env.VERBOSE) {
|
|
1059
|
+
console.log(
|
|
1060
|
+
`[Config Exporter] Setting environment variables from build config...`
|
|
1061
|
+
)
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1042
1064
|
for (const [key, value] of Object.entries(resolvedBuild.environment)) {
|
|
1043
1065
|
if (DANGEROUS_ENV_VARS.includes(key)) {
|
|
1044
1066
|
console.warn(
|
|
@@ -1053,6 +1075,9 @@ async function loadConfigsForEnv(
|
|
|
1053
1075
|
)
|
|
1054
1076
|
continue
|
|
1055
1077
|
}
|
|
1078
|
+
if (process.env.VERBOSE) {
|
|
1079
|
+
console.log(`[Config Exporter] ${key}=${value}`)
|
|
1080
|
+
}
|
|
1056
1081
|
process.env[key] = value
|
|
1057
1082
|
}
|
|
1058
1083
|
|
|
@@ -1080,6 +1105,21 @@ async function loadConfigsForEnv(
|
|
|
1080
1105
|
const railsEnv =
|
|
1081
1106
|
options.env || resolvedBuild.environment.RAILS_ENV || finalEnv
|
|
1082
1107
|
process.env.RAILS_ENV = railsEnv
|
|
1108
|
+
|
|
1109
|
+
// Auto-set CLIENT_BUNDLE_ONLY/SERVER_BUNDLE_ONLY from outputs if not already in environment
|
|
1110
|
+
// This allows webpack configs to return the correct number of bundles
|
|
1111
|
+
if (
|
|
1112
|
+
!resolvedBuild.environment.CLIENT_BUNDLE_ONLY &&
|
|
1113
|
+
!resolvedBuild.environment.SERVER_BUNDLE_ONLY
|
|
1114
|
+
) {
|
|
1115
|
+
if (buildOutputs.length === 1) {
|
|
1116
|
+
if (buildOutputs[0] === "client") {
|
|
1117
|
+
process.env.CLIENT_BUNDLE_ONLY = "yes"
|
|
1118
|
+
} else if (buildOutputs[0] === "server") {
|
|
1119
|
+
process.env.SERVER_BUNDLE_ONLY = "yes"
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1083
1123
|
} else {
|
|
1084
1124
|
// No build config - use CLI env or default
|
|
1085
1125
|
finalEnv = env || "development"
|
|
@@ -1092,6 +1132,7 @@ async function loadConfigsForEnv(
|
|
|
1092
1132
|
process.env.RAILS_ENV = finalEnv
|
|
1093
1133
|
}
|
|
1094
1134
|
|
|
1135
|
+
// Handle CLI flags for client/server only
|
|
1095
1136
|
if (options.clientOnly) {
|
|
1096
1137
|
process.env.CLIENT_BUNDLE_ONLY = "yes"
|
|
1097
1138
|
} else if (options.serverOnly) {
|
|
@@ -1165,7 +1206,19 @@ async function loadConfigsForEnv(
|
|
|
1165
1206
|
})
|
|
1166
1207
|
|
|
1167
1208
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
1168
|
-
let loadedConfig
|
|
1209
|
+
let loadedConfig: any
|
|
1210
|
+
try {
|
|
1211
|
+
loadedConfig = require(configFile)
|
|
1212
|
+
} catch (error: unknown) {
|
|
1213
|
+
const errorMessage = error instanceof Error ? error.message : String(error)
|
|
1214
|
+
throw new Error(
|
|
1215
|
+
`Failed to load webpack/rspack config file.\n\n` +
|
|
1216
|
+
`Config file: ${configFile}\n` +
|
|
1217
|
+
`Build: ${buildName || "default"}\n` +
|
|
1218
|
+
`Error: ${errorMessage}\n\n` +
|
|
1219
|
+
`Tip: Check that the config file is valid and doesn't have syntax errors.`
|
|
1220
|
+
)
|
|
1221
|
+
}
|
|
1169
1222
|
|
|
1170
1223
|
// Handle ES module default export
|
|
1171
1224
|
if (typeof loadedConfig === "object" && "default" in loadedConfig) {
|
|
@@ -1198,10 +1251,41 @@ async function loadConfigsForEnv(
|
|
|
1198
1251
|
} catch (error: unknown) {
|
|
1199
1252
|
const errorMessage =
|
|
1200
1253
|
error instanceof Error ? error.message : String(error)
|
|
1254
|
+
|
|
1255
|
+
// Build detailed environment information for debugging
|
|
1256
|
+
const envDetails = [
|
|
1257
|
+
`Config file: ${configFile}`,
|
|
1258
|
+
`Build: ${buildName || "default"}`,
|
|
1259
|
+
``,
|
|
1260
|
+
`Current Environment Variables:`,
|
|
1261
|
+
` NODE_ENV: ${process.env.NODE_ENV || "(not set)"}`,
|
|
1262
|
+
` RAILS_ENV: ${process.env.RAILS_ENV || "(not set)"}`,
|
|
1263
|
+
` CLIENT_BUNDLE_ONLY: ${process.env.CLIENT_BUNDLE_ONLY || "(not set)"}`,
|
|
1264
|
+
` SERVER_BUNDLE_ONLY: ${process.env.SERVER_BUNDLE_ONLY || "(not set)"}`,
|
|
1265
|
+
` WEBPACK_SERVE: ${process.env.WEBPACK_SERVE || "(not set)"}`,
|
|
1266
|
+
``,
|
|
1267
|
+
`Bundler env args: ${JSON.stringify(envObject)}`,
|
|
1268
|
+
`Mode: ${finalEnv}`,
|
|
1269
|
+
``,
|
|
1270
|
+
`Error: ${errorMessage}`,
|
|
1271
|
+
``
|
|
1272
|
+
]
|
|
1273
|
+
|
|
1274
|
+
// Add suggestion based on common error patterns
|
|
1275
|
+
let suggestion = `Check your webpack/rspack config for errors. The config function threw an exception when called.`
|
|
1276
|
+
if (errorMessage.includes("NODE_ENV") && !process.env.NODE_ENV) {
|
|
1277
|
+
suggestion =
|
|
1278
|
+
`NODE_ENV is not set. ` +
|
|
1279
|
+
`Your build config should set NODE_ENV in the 'environment' section.\n` +
|
|
1280
|
+
`Example:\n` +
|
|
1281
|
+
` environment:\n` +
|
|
1282
|
+
` NODE_ENV: "development"`
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1201
1285
|
throw new Error(
|
|
1202
1286
|
`Failed to execute config function: ${errorMessage}\n` +
|
|
1203
|
-
|
|
1204
|
-
|
|
1287
|
+
envDetails.join("\n") +
|
|
1288
|
+
`\nTip: ${suggestion}`
|
|
1205
1289
|
)
|
|
1206
1290
|
}
|
|
1207
1291
|
}
|
|
@@ -1212,29 +1296,81 @@ async function loadConfigsForEnv(
|
|
|
1212
1296
|
: [loadedConfig]
|
|
1213
1297
|
const results: Array<{ config: any; metadata: ConfigMetadata }> = []
|
|
1214
1298
|
|
|
1299
|
+
// Validate config count matches expected outputs
|
|
1300
|
+
if (buildOutputs.length > 0 && configs.length !== buildOutputs.length) {
|
|
1301
|
+
const errorLines = [
|
|
1302
|
+
`Webpack config returned ${configs.length} config(s) but outputs array specifies ${buildOutputs.length}.`,
|
|
1303
|
+
``,
|
|
1304
|
+
`Build: ${buildName || "default"}`,
|
|
1305
|
+
`Config file: ${configFile}`,
|
|
1306
|
+
`Expected outputs: [${buildOutputs.join(", ")}]`,
|
|
1307
|
+
`Actual configs returned: ${configs.length}`,
|
|
1308
|
+
``,
|
|
1309
|
+
`This mismatch means:`
|
|
1310
|
+
]
|
|
1311
|
+
|
|
1312
|
+
if (configs.length < buildOutputs.length) {
|
|
1313
|
+
errorLines.push(
|
|
1314
|
+
` - Your webpack config is returning FEWER configs than expected.`,
|
|
1315
|
+
` - Either update your webpack config to return ${buildOutputs.length} config(s),`,
|
|
1316
|
+
` - Or update the 'outputs' array in your build config to match what webpack returns.`
|
|
1317
|
+
)
|
|
1318
|
+
} else {
|
|
1319
|
+
errorLines.push(
|
|
1320
|
+
` - Your webpack config is returning MORE configs than expected.`,
|
|
1321
|
+
` - Either update the 'outputs' array to include all ${configs.length} outputs,`,
|
|
1322
|
+
` - Or update your webpack config to return only ${buildOutputs.length} config(s).`
|
|
1323
|
+
)
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
errorLines.push(
|
|
1327
|
+
``,
|
|
1328
|
+
`Example fix in build config:`,
|
|
1329
|
+
` outputs:`,
|
|
1330
|
+
...Array.from({ length: configs.length }, (_, i) =>
|
|
1331
|
+
i < buildOutputs.length
|
|
1332
|
+
? ` - ${buildOutputs[i]}`
|
|
1333
|
+
: ` - config-${i + 1} # Add a name for this config`
|
|
1334
|
+
)
|
|
1335
|
+
)
|
|
1336
|
+
|
|
1337
|
+
throw new Error(errorLines.join("\n"))
|
|
1338
|
+
}
|
|
1339
|
+
|
|
1340
|
+
// Debug logging
|
|
1341
|
+
if (process.env.VERBOSE || buildOutputs.length > 0) {
|
|
1342
|
+
console.log(
|
|
1343
|
+
`[Config Exporter] Webpack returned ${configs.length} config(s), buildOutputs: [${buildOutputs.join(", ")}]`
|
|
1344
|
+
)
|
|
1345
|
+
if (buildOutputs.length > 0 && configs.length === buildOutputs.length) {
|
|
1346
|
+
console.log(
|
|
1347
|
+
`[Config Exporter] ✓ Config count matches outputs array (${configs.length})`
|
|
1348
|
+
)
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
|
|
1215
1352
|
configs.forEach((cfg, index) => {
|
|
1216
|
-
let configType:
|
|
1353
|
+
let configType: string = "all"
|
|
1217
1354
|
|
|
1218
1355
|
// Use outputs from build config if available
|
|
1219
|
-
if (
|
|
1220
|
-
|
|
1221
|
-
index
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
const outputValue = buildOutputs[index]
|
|
1225
|
-
// Validate the output value is a valid config type
|
|
1226
|
-
if (
|
|
1227
|
-
outputValue === "client" ||
|
|
1228
|
-
outputValue === "server" ||
|
|
1229
|
-
outputValue === "all"
|
|
1230
|
-
) {
|
|
1231
|
-
configType = outputValue
|
|
1232
|
-
} else {
|
|
1233
|
-
throw new Error(
|
|
1234
|
-
`Invalid output type '${outputValue}' at index ${index} in build '${buildName}'. ` +
|
|
1235
|
-
`Allowed values are: client, server, all`
|
|
1356
|
+
if (buildOutputs.length > 0) {
|
|
1357
|
+
// If outputs are specified, skip configs beyond the outputs array
|
|
1358
|
+
if (index >= buildOutputs.length) {
|
|
1359
|
+
console.log(
|
|
1360
|
+
`[Config Exporter] Skipping config[${index}] - beyond outputs array`
|
|
1236
1361
|
)
|
|
1362
|
+
return // Skip this config
|
|
1237
1363
|
}
|
|
1364
|
+
|
|
1365
|
+
const outputValue = buildOutputs[index]
|
|
1366
|
+
if (!outputValue || outputValue.trim() === "") {
|
|
1367
|
+
return // Skip null/undefined/empty string entries
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
// Accept any string as a valid output name
|
|
1371
|
+
// Built-in types: client, server, all, client-hmr
|
|
1372
|
+
// Custom types: client-modern, client-legacy, server-bundle, etc.
|
|
1373
|
+
configType = outputValue
|
|
1238
1374
|
} else if (configs.length === 2) {
|
|
1239
1375
|
// Likely client and server configs
|
|
1240
1376
|
configType = index === 0 ? "client" : "server"
|
|
@@ -1285,7 +1421,8 @@ function formatConfig(
|
|
|
1285
1421
|
appRoot
|
|
1286
1422
|
})
|
|
1287
1423
|
return serializer.serialize(config, metadata)
|
|
1288
|
-
}
|
|
1424
|
+
}
|
|
1425
|
+
if (options.format === "json") {
|
|
1289
1426
|
const jsonReplacer = (key: string, value: any): any => {
|
|
1290
1427
|
if (typeof value === "function") {
|
|
1291
1428
|
return `[Function: ${value.name || "anonymous"}]`
|
|
@@ -1397,10 +1534,30 @@ function cleanConfig(obj: any, rootPath: string): any {
|
|
|
1397
1534
|
/**
|
|
1398
1535
|
* Loads and returns shakapacker.yml configuration
|
|
1399
1536
|
*/
|
|
1537
|
+
// Cache to avoid duplicate loading and logging
|
|
1538
|
+
let shakapackerConfigCache: {
|
|
1539
|
+
env: string
|
|
1540
|
+
result: { bundler: "webpack" | "rspack"; configPath: string }
|
|
1541
|
+
} | null = null
|
|
1542
|
+
|
|
1400
1543
|
function loadShakapackerConfig(
|
|
1401
1544
|
env: string,
|
|
1402
1545
|
appRoot: string
|
|
1403
1546
|
): { bundler: "webpack" | "rspack"; configPath: string } {
|
|
1547
|
+
// Return cached result if same environment
|
|
1548
|
+
if (shakapackerConfigCache && shakapackerConfigCache.env === env) {
|
|
1549
|
+
if (process.env.VERBOSE) {
|
|
1550
|
+
console.log(
|
|
1551
|
+
`[Config Exporter] Using cached bundler config for env: ${env}`
|
|
1552
|
+
)
|
|
1553
|
+
}
|
|
1554
|
+
return shakapackerConfigCache.result
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
if (process.env.VERBOSE) {
|
|
1558
|
+
console.log(`[Config Exporter] Loading shakapacker config for env: ${env}`)
|
|
1559
|
+
}
|
|
1560
|
+
|
|
1404
1561
|
try {
|
|
1405
1562
|
const configFilePath =
|
|
1406
1563
|
process.env.SHAKAPACKER_CONFIG ||
|
|
@@ -1416,10 +1573,12 @@ function loadShakapackerConfig(
|
|
|
1416
1573
|
console.warn(
|
|
1417
1574
|
`[Config Exporter] Invalid bundler '${bundler}' in shakapacker.yml, defaulting to webpack`
|
|
1418
1575
|
)
|
|
1419
|
-
|
|
1420
|
-
bundler: "webpack",
|
|
1576
|
+
const result = {
|
|
1577
|
+
bundler: "webpack" as const,
|
|
1421
1578
|
configPath: bundler === "rspack" ? "config/rspack" : "config/webpack"
|
|
1422
1579
|
}
|
|
1580
|
+
shakapackerConfigCache = { env, result }
|
|
1581
|
+
return result
|
|
1423
1582
|
}
|
|
1424
1583
|
|
|
1425
1584
|
// Get config path
|
|
@@ -1428,10 +1587,15 @@ function loadShakapackerConfig(
|
|
|
1428
1587
|
customConfigPath ||
|
|
1429
1588
|
(bundler === "rspack" ? "config/rspack" : "config/webpack")
|
|
1430
1589
|
|
|
1590
|
+
const result = { bundler, configPath }
|
|
1591
|
+
shakapackerConfigCache = { env, result }
|
|
1592
|
+
|
|
1593
|
+
// Only log on first call (when cache was empty)
|
|
1431
1594
|
console.log(
|
|
1432
1595
|
`[Config Exporter] Auto-detected bundler: ${bundler}, config path: ${configPath}`
|
|
1433
1596
|
)
|
|
1434
|
-
|
|
1597
|
+
|
|
1598
|
+
return result
|
|
1435
1599
|
}
|
|
1436
1600
|
} catch (error: unknown) {
|
|
1437
1601
|
console.warn(
|
|
@@ -1439,7 +1603,9 @@ function loadShakapackerConfig(
|
|
|
1439
1603
|
)
|
|
1440
1604
|
}
|
|
1441
1605
|
|
|
1442
|
-
|
|
1606
|
+
const result = { bundler: "webpack" as const, configPath: "config/webpack" }
|
|
1607
|
+
shakapackerConfigCache = { env, result }
|
|
1608
|
+
return result
|
|
1443
1609
|
}
|
|
1444
1610
|
|
|
1445
1611
|
/**
|
|
@@ -46,18 +46,27 @@ export class FileWriter {
|
|
|
46
46
|
* Generate filename for a config export
|
|
47
47
|
* Format without build: {bundler}-{env}-{type}.{ext}
|
|
48
48
|
* Format with build: {bundler}-{build}-{type}.{ext}
|
|
49
|
-
*
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
49
|
+
*
|
|
50
|
+
* @param bundler - The bundler type (webpack, rspack)
|
|
51
|
+
* @param env - The environment (development, production, test)
|
|
52
|
+
* @param configType - Type of config. Built-in: "client", "server", "all", "client-hmr". Custom: any string from outputs array
|
|
53
|
+
* @param format - Output format (yaml, json, inspect)
|
|
54
|
+
* @param buildName - Optional build name that overrides env in filename
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* // Built-in types
|
|
58
|
+
* generateFilename("webpack", "development", "client", "yaml")
|
|
59
|
+
* // => "webpack-development-client.yaml"
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* // Custom output names
|
|
63
|
+
* generateFilename("webpack", "development", "client-modern", "yaml", "dev-hmr")
|
|
64
|
+
* // => "webpack-dev-hmr-client-modern.yaml"
|
|
56
65
|
*/
|
|
57
66
|
static generateFilename(
|
|
58
67
|
bundler: string,
|
|
59
68
|
env: string,
|
|
60
|
-
configType:
|
|
69
|
+
configType: string,
|
|
61
70
|
format: "yaml" | "json" | "inspect",
|
|
62
71
|
buildName?: string
|
|
63
72
|
): string {
|
|
@@ -29,7 +29,12 @@ export interface ConfigMetadata {
|
|
|
29
29
|
bundler: string
|
|
30
30
|
environment: string
|
|
31
31
|
configFile: string
|
|
32
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Type of webpack/rspack config output.
|
|
34
|
+
* Built-in types: "client", "server", "all", "client-hmr"
|
|
35
|
+
* Custom types: Any string matching your outputs array (e.g., "client-modern", "client-legacy", "server-bundle")
|
|
36
|
+
*/
|
|
37
|
+
configType: string
|
|
33
38
|
configCount: number
|
|
34
39
|
buildName?: string // New: name of the build from config file
|
|
35
40
|
environmentVariables: {
|
data/package/utils/errorCodes.ts
CHANGED
|
@@ -36,12 +36,14 @@ export function createFileOperationError(
|
|
|
36
36
|
filePath: string,
|
|
37
37
|
details?: string
|
|
38
38
|
): ShakapackerError {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
39
|
+
let errorCode: ErrorCode
|
|
40
|
+
if (operation === "read") {
|
|
41
|
+
errorCode = ErrorCode.FILE_READ_ERROR
|
|
42
|
+
} else if (operation === "write") {
|
|
43
|
+
errorCode = ErrorCode.FILE_WRITE_ERROR
|
|
44
|
+
} else {
|
|
45
|
+
errorCode = ErrorCode.FILE_NOT_FOUND
|
|
46
|
+
}
|
|
45
47
|
|
|
46
48
|
return new ShakapackerError(errorCode, {
|
|
47
49
|
path: filePath,
|
|
@@ -60,12 +62,14 @@ export function createFileOperationErrorLegacy(
|
|
|
60
62
|
): Error {
|
|
61
63
|
const baseMessage = `Failed to ${operation} file at path '${filePath}'`
|
|
62
64
|
const errorDetails = details ? ` - ${details}` : ""
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
65
|
+
let suggestion: string
|
|
66
|
+
if (operation === "read") {
|
|
67
|
+
suggestion = " (check if file exists and permissions are correct)"
|
|
68
|
+
} else if (operation === "write") {
|
|
69
|
+
suggestion = " (check write permissions and disk space)"
|
|
70
|
+
} else {
|
|
71
|
+
suggestion = " (check permissions)"
|
|
72
|
+
}
|
|
69
73
|
return new Error(`${baseMessage}${errorDetails}${suggestion}`)
|
|
70
74
|
}
|
|
71
75
|
|
data/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shakapacker",
|
|
3
|
-
"version": "9.3.0-beta.
|
|
3
|
+
"version": "9.3.0-beta.6",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "shakapacker",
|
|
9
|
-
"version": "9.3.0-beta.
|
|
9
|
+
"version": "9.3.0-beta.6",
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"js-yaml": "^4.1.0",
|
data/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shakapacker",
|
|
3
|
-
"version": "9.3.0-beta.
|
|
3
|
+
"version": "9.3.0-beta.6",
|
|
4
4
|
"description": "Use webpack to manage app-like JavaScript modules in Rails",
|
|
5
5
|
"homepage": "https://github.com/shakacode/shakapacker",
|
|
6
6
|
"bugs": {
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
],
|
|
33
33
|
"scripts": {
|
|
34
34
|
"clean:ts": "find package -name '*.ts' -not -name '*.d.ts' | sed 's/\\.ts$//' | xargs -I {} rm -f {}.js {}.d.ts {}.d.ts.map {}.js.map",
|
|
35
|
-
"build": "tsc && cp package/index.d.ts.template package/index.d.ts && node scripts/remove-use-strict.js && yarn prettier --write 'package/**/*.js'",
|
|
35
|
+
"build": "tsc && cp package/index.d.ts.template package/index.d.ts && node scripts/remove-use-strict.js && yarn prettier --write 'package/**/*.js' 'package/**/*.ts'",
|
|
36
36
|
"build:types": "tsc",
|
|
37
37
|
"knip": "knip",
|
|
38
38
|
"knip:production": "knip --production",
|
|
@@ -58,6 +58,51 @@ describe("configExporter", () => {
|
|
|
58
58
|
)
|
|
59
59
|
expect(filename).toBe("rspack-production-client.json")
|
|
60
60
|
})
|
|
61
|
+
|
|
62
|
+
test("generates correct filename for custom output name client-modern", () => {
|
|
63
|
+
const { FileWriter } = require("../../package/configExporter/fileWriter")
|
|
64
|
+
const filename = FileWriter.generateFilename(
|
|
65
|
+
"webpack",
|
|
66
|
+
"development",
|
|
67
|
+
"client-modern",
|
|
68
|
+
"yaml"
|
|
69
|
+
)
|
|
70
|
+
expect(filename).toBe("webpack-development-client-modern.yaml")
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test("generates correct filename for custom output name client-legacy", () => {
|
|
74
|
+
const { FileWriter } = require("../../package/configExporter/fileWriter")
|
|
75
|
+
const filename = FileWriter.generateFilename(
|
|
76
|
+
"webpack",
|
|
77
|
+
"production",
|
|
78
|
+
"client-legacy",
|
|
79
|
+
"yaml"
|
|
80
|
+
)
|
|
81
|
+
expect(filename).toBe("webpack-production-client-legacy.yaml")
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
test("generates correct filename for custom output name server-bundle", () => {
|
|
85
|
+
const { FileWriter } = require("../../package/configExporter/fileWriter")
|
|
86
|
+
const filename = FileWriter.generateFilename(
|
|
87
|
+
"rspack",
|
|
88
|
+
"development",
|
|
89
|
+
"server-bundle",
|
|
90
|
+
"yaml"
|
|
91
|
+
)
|
|
92
|
+
expect(filename).toBe("rspack-development-server-bundle.yaml")
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test("generates correct filename with buildName override", () => {
|
|
96
|
+
const { FileWriter } = require("../../package/configExporter/fileWriter")
|
|
97
|
+
const filename = FileWriter.generateFilename(
|
|
98
|
+
"webpack",
|
|
99
|
+
"development",
|
|
100
|
+
"client-modern",
|
|
101
|
+
"yaml",
|
|
102
|
+
"dev-hmr"
|
|
103
|
+
)
|
|
104
|
+
expect(filename).toBe("webpack-dev-hmr-client-modern.yaml")
|
|
105
|
+
})
|
|
61
106
|
})
|
|
62
107
|
|
|
63
108
|
describe("environment variable preservation in runDoctorMode", () => {
|
|
@@ -19,6 +19,7 @@ const babelConfig = require("../../../package/rules/babel")
|
|
|
19
19
|
|
|
20
20
|
// Skip tests if babel config is not available (not the active transpiler)
|
|
21
21
|
if (!babelConfig) {
|
|
22
|
+
// eslint-disable-next-line jest/no-disabled-tests
|
|
22
23
|
describe.skip("babel - skipped", () => {
|
|
23
24
|
test.todo("skipped because babel is not the active transpiler")
|
|
24
25
|
})
|
|
@@ -19,6 +19,7 @@ const swcConfig = require("../../../package/rules/swc")
|
|
|
19
19
|
|
|
20
20
|
// Skip tests if swc config is not available (not the active transpiler)
|
|
21
21
|
if (!swcConfig) {
|
|
22
|
+
// eslint-disable-next-line jest/no-disabled-tests
|
|
22
23
|
describe.skip("swc - skipped", () => {
|
|
23
24
|
test.todo("skipped because swc is not the active transpiler")
|
|
24
25
|
})
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: shakapacker
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 9.3.0.beta.
|
|
4
|
+
version: 9.3.0.beta.6
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
@@ -180,6 +180,9 @@ files:
|
|
|
180
180
|
- docs/customizing_babel_config.md
|
|
181
181
|
- docs/deployment.md
|
|
182
182
|
- docs/developing_shakapacker.md
|
|
183
|
+
- docs/early_hints.md
|
|
184
|
+
- docs/early_hints_manual_api.md
|
|
185
|
+
- docs/feature_testing.md
|
|
183
186
|
- docs/optional-peer-dependencies.md
|
|
184
187
|
- docs/peer-dependencies.md
|
|
185
188
|
- docs/precompile_hook.md
|
|
@@ -382,7 +385,7 @@ homepage: https://github.com/shakacode/shakapacker
|
|
|
382
385
|
licenses:
|
|
383
386
|
- MIT
|
|
384
387
|
metadata:
|
|
385
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.3.0.beta.
|
|
388
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.3.0.beta.6
|
|
386
389
|
rdoc_options: []
|
|
387
390
|
require_paths:
|
|
388
391
|
- lib
|