shakapacker 9.2.0 → 9.3.0.beta.0
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/.github/ISSUE_TEMPLATE/bug_report.md +6 -9
- data/.github/ISSUE_TEMPLATE/feature_request.md +6 -8
- data/.github/workflows/claude-code-review.yml +4 -5
- data/.github/workflows/claude.yml +1 -2
- data/.github/workflows/dummy.yml +4 -4
- data/.github/workflows/generator.yml +9 -9
- data/.github/workflows/node.yml +11 -2
- data/.github/workflows/ruby.yml +16 -16
- data/.github/workflows/test-bundlers.yml +9 -9
- data/.gitignore +4 -0
- data/CHANGELOG.md +19 -4
- data/CLAUDE.md +6 -1
- data/CONTRIBUTING.md +0 -1
- data/Gemfile.lock +1 -1
- data/README.md +14 -14
- data/TODO.md +10 -2
- data/TODO_v9.md +13 -3
- data/bin/export-bundler-config +1 -1
- data/conductor-setup.sh +1 -1
- data/conductor.json +1 -1
- data/docs/cdn_setup.md +13 -8
- data/docs/common-upgrades.md +2 -1
- data/docs/configuration.md +630 -0
- data/docs/css-modules-export-mode.md +120 -100
- data/docs/customizing_babel_config.md +16 -16
- data/docs/deployment.md +18 -0
- data/docs/developing_shakapacker.md +6 -0
- data/docs/optional-peer-dependencies.md +9 -4
- data/docs/peer-dependencies.md +17 -6
- data/docs/precompile_hook.md +342 -0
- data/docs/react.md +57 -47
- data/docs/releasing.md +0 -2
- data/docs/rspack.md +25 -21
- data/docs/rspack_migration_guide.md +335 -8
- data/docs/sprockets.md +1 -0
- data/docs/style_loader_vs_mini_css.md +12 -12
- data/docs/subresource_integrity.md +13 -7
- data/docs/transpiler-performance.md +40 -19
- data/docs/troubleshooting.md +0 -2
- data/docs/typescript-migration.md +48 -39
- data/docs/typescript.md +12 -8
- data/docs/using_esbuild_loader.md +10 -10
- data/docs/v6_upgrade.md +33 -20
- data/docs/v7_upgrade.md +8 -6
- data/docs/v8_upgrade.md +13 -12
- data/docs/v9_upgrade.md +2 -1
- data/eslint.config.fast.js +134 -0
- data/eslint.config.js +140 -0
- data/knip.ts +54 -0
- data/lib/install/bin/export-bundler-config +1 -1
- data/lib/install/config/shakapacker.yml +16 -5
- data/lib/shakapacker/compiler.rb +80 -0
- data/lib/shakapacker/configuration.rb +33 -5
- data/lib/shakapacker/dev_server_runner.rb +140 -1
- data/lib/shakapacker/doctor.rb +294 -65
- data/lib/shakapacker/instance.rb +8 -3
- data/lib/shakapacker/runner.rb +244 -8
- data/lib/shakapacker/version.rb +1 -1
- data/lib/tasks/shakapacker/doctor.rake +42 -2
- data/package/babel/preset.ts +7 -4
- data/package/config.ts +42 -30
- data/package/configExporter/cli.ts +799 -208
- data/package/configExporter/configFile.ts +520 -0
- data/package/configExporter/fileWriter.ts +12 -8
- data/package/configExporter/index.ts +9 -1
- data/package/configExporter/types.ts +36 -2
- data/package/configExporter/yamlSerializer.ts +22 -8
- data/package/dev_server.ts +1 -1
- data/package/environments/__type-tests__/rspack-plugin-compatibility.ts +11 -5
- data/package/environments/base.ts +18 -13
- data/package/environments/development.ts +1 -1
- data/package/environments/production.ts +4 -1
- data/package/index.d.ts +50 -3
- data/package/index.d.ts.template +50 -0
- data/package/index.ts +7 -7
- data/package/loaders.d.ts +2 -2
- data/package/optimization/rspack.ts +1 -1
- data/package/plugins/rspack.ts +15 -4
- data/package/plugins/webpack.ts +7 -3
- data/package/rspack/index.ts +10 -2
- data/package/rules/raw.ts +3 -2
- data/package/rules/sass.ts +1 -1
- data/package/types/README.md +15 -13
- data/package/types/index.ts +5 -5
- data/package/types.ts +0 -1
- data/package/utils/defaultConfigPath.ts +4 -1
- data/package/utils/errorCodes.ts +129 -100
- data/package/utils/errorHelpers.ts +34 -29
- data/package/utils/getStyleRule.ts +5 -2
- data/package/utils/helpers.ts +21 -11
- data/package/utils/pathValidation.ts +43 -35
- data/package/utils/requireOrError.ts +1 -1
- data/package/utils/snakeToCamelCase.ts +1 -1
- data/package/utils/typeGuards.ts +132 -83
- data/package/utils/validateDependencies.ts +1 -1
- data/package/webpack-types.d.ts +3 -3
- data/package/webpackDevServerConfig.ts +22 -10
- data/package-lock.json +2 -2
- data/package.json +36 -28
- data/scripts/type-check-no-emit.js +1 -1
- data/test/configExporter/configFile.test.js +392 -0
- data/test/configExporter/integration.test.js +275 -0
- data/test/helpers.js +1 -1
- data/test/package/configExporter.test.js +154 -0
- data/test/package/helpers.test.js +2 -2
- data/test/package/rules/sass-version-parsing.test.js +71 -0
- data/test/package/rules/sass.test.js +2 -4
- data/test/package/rules/sass1.test.js +1 -3
- data/test/package/rules/sass16.test.js +23 -0
- data/tools/README.md +15 -5
- data/tsconfig.eslint.json +2 -9
- data/yarn.lock +1894 -1492
- metadata +19 -3
- data/.eslintignore +0 -5
@@ -6,22 +6,28 @@
|
|
6
6
|
* These tests will fail at compile time if the types are not compatible.
|
7
7
|
*/
|
8
8
|
|
9
|
-
import type { RspackPlugin, RspackPluginInstance } from
|
9
|
+
import type { RspackPlugin, RspackPluginInstance } from "../types"
|
10
10
|
|
11
11
|
// Test 1: RspackPlugin should be assignable to RspackPluginInstance
|
12
|
-
const testPluginToInstance = (plugin: RspackPlugin): RspackPluginInstance =>
|
12
|
+
const testPluginToInstance = (plugin: RspackPlugin): RspackPluginInstance =>
|
13
|
+
plugin
|
13
14
|
|
14
15
|
// Test 2: RspackPluginInstance should be assignable to RspackPlugin
|
15
|
-
const testInstanceToPlugin = (instance: RspackPluginInstance): RspackPlugin =>
|
16
|
+
const testInstanceToPlugin = (instance: RspackPluginInstance): RspackPlugin =>
|
17
|
+
instance
|
16
18
|
|
17
19
|
// Test 3: Array compatibility
|
18
|
-
const testArrayCompatibility = (
|
20
|
+
const testArrayCompatibility = (
|
21
|
+
plugins: RspackPlugin[]
|
22
|
+
): RspackPluginInstance[] => plugins
|
19
23
|
const testArrayCompatibilityReverse = (
|
20
24
|
instances: RspackPluginInstance[]
|
21
25
|
): RspackPlugin[] => instances
|
22
26
|
|
23
27
|
// Test 4: Optional parameter compatibility
|
24
|
-
const testOptionalParam = (
|
28
|
+
const testOptionalParam = (
|
29
|
+
plugin?: RspackPlugin
|
30
|
+
): RspackPluginInstance | undefined => plugin
|
25
31
|
const testOptionalParamReverse = (
|
26
32
|
instance?: RspackPluginInstance
|
27
33
|
): RspackPlugin | undefined => instance
|
@@ -53,13 +53,13 @@ const getEntryObject = (): Entry => {
|
|
53
53
|
if (config.source_entry_path === "/" && config.nested_entries) {
|
54
54
|
throw new Error(
|
55
55
|
`Invalid Shakapacker configuration detected!\n\n` +
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
56
|
+
`You have set source_entry_path to '/' with nested_entries enabled.\n` +
|
57
|
+
`This would create webpack entry points for EVERY file in your source directory,\n` +
|
58
|
+
`which would severely impact build performance.\n\n` +
|
59
|
+
`To fix this issue, either:\n` +
|
60
|
+
`1. Set 'nested_entries: false' in your shakapacker.yml\n` +
|
61
|
+
`2. Change 'source_entry_path' to a specific subdirectory (e.g., 'packs')\n` +
|
62
|
+
`3. Or use both options for better organization of your entry points`
|
63
63
|
)
|
64
64
|
}
|
65
65
|
|
@@ -73,7 +73,7 @@ const getEntryObject = (): Entry => {
|
|
73
73
|
const previousPaths = entries[name]
|
74
74
|
if (previousPaths) {
|
75
75
|
const pathArray = Array.isArray(previousPaths)
|
76
|
-
? previousPaths as string[]
|
76
|
+
? (previousPaths as string[])
|
77
77
|
: [previousPaths as string]
|
78
78
|
pathArray.push(assetPath)
|
79
79
|
entries[name] = pathArray
|
@@ -89,7 +89,9 @@ const getModulePaths = (): string[] => {
|
|
89
89
|
const result = [resolve(config.source_path)]
|
90
90
|
|
91
91
|
if (config.additional_paths) {
|
92
|
-
config.additional_paths.forEach((path: string) =>
|
92
|
+
config.additional_paths.forEach((path: string) =>
|
93
|
+
result.push(resolve(path))
|
94
|
+
)
|
93
95
|
}
|
94
96
|
result.push("node_modules")
|
95
97
|
|
@@ -108,9 +110,13 @@ const baseConfig: Configuration = {
|
|
108
110
|
publicPath: config.publicPath,
|
109
111
|
|
110
112
|
// This is required for SRI to work.
|
111
|
-
crossOriginLoading:
|
112
|
-
|
113
|
-
|
113
|
+
crossOriginLoading:
|
114
|
+
config.integrity && config.integrity.enabled
|
115
|
+
? (config.integrity.cross_origin as
|
116
|
+
| "anonymous"
|
117
|
+
| "use-credentials"
|
118
|
+
| false)
|
119
|
+
: false
|
114
120
|
},
|
115
121
|
entry: getEntryObject(),
|
116
122
|
resolve: {
|
@@ -135,4 +141,3 @@ const baseConfig: Configuration = {
|
|
135
141
|
}
|
136
142
|
|
137
143
|
export = baseConfig
|
138
|
-
|
@@ -9,7 +9,7 @@ const baseConfig = require("./base")
|
|
9
9
|
const webpackDevServerConfig = require("../webpackDevServerConfig")
|
10
10
|
const { runningWebpackDevServer } = require("../env")
|
11
11
|
const { moduleExists } = require("../utils/helpers")
|
12
|
-
import type {
|
12
|
+
import type {
|
13
13
|
WebpackConfigWithDevServer,
|
14
14
|
RspackConfigWithDevServer,
|
15
15
|
ReactRefreshWebpackPlugin,
|
@@ -11,7 +11,10 @@ const { merge } = require("webpack-merge")
|
|
11
11
|
const baseConfig = require("./base")
|
12
12
|
const { moduleExists } = require("../utils/helpers")
|
13
13
|
const config = require("../config")
|
14
|
-
import type {
|
14
|
+
import type {
|
15
|
+
Configuration as WebpackConfiguration,
|
16
|
+
WebpackPluginInstance
|
17
|
+
} from "webpack"
|
15
18
|
import type { CompressionPluginConstructor } from "./types"
|
16
19
|
|
17
20
|
const optimizationPath = resolve(
|
data/package/index.d.ts
CHANGED
@@ -1,3 +1,50 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
/**
|
2
|
+
* Manual type definitions for Shakapacker package exports.
|
3
|
+
*
|
4
|
+
* This file is manually maintained because TypeScript cannot infer types
|
5
|
+
* from the `export =` syntax with dynamic require() calls in index.ts.
|
6
|
+
*
|
7
|
+
* When adding/modifying exports in index.ts, update this file accordingly.
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { Configuration, RuleSetRule } from "webpack"
|
11
|
+
import type { Config, DevServerConfig, Env } from "./types"
|
12
|
+
|
13
|
+
/**
|
14
|
+
* The shape of the Shakapacker module exports.
|
15
|
+
* This interface represents the object exported via CommonJS `export =`.
|
16
|
+
*/
|
17
|
+
interface ShakapackerExports {
|
18
|
+
/** Shakapacker configuration from shakapacker.yml */
|
19
|
+
config: Config
|
20
|
+
/** Development server configuration */
|
21
|
+
devServer: DevServerConfig
|
22
|
+
/** Base webpack/rspack configuration */
|
23
|
+
baseConfig: Configuration
|
24
|
+
/** Environment configuration (railsEnv, nodeEnv, etc.) */
|
25
|
+
env: Env
|
26
|
+
/** Array of webpack/rspack loader rules */
|
27
|
+
rules: RuleSetRule[]
|
28
|
+
/** Check if a module exists in node_modules */
|
29
|
+
moduleExists: (packageName: string) => boolean
|
30
|
+
/** Process a file if a specific loader is available */
|
31
|
+
canProcess: <T = unknown>(
|
32
|
+
rule: string,
|
33
|
+
fn: (modulePath: string) => T
|
34
|
+
) => T | null
|
35
|
+
/** Whether CSS should be inlined (dev server with HMR) */
|
36
|
+
inliningCss: boolean
|
37
|
+
/** Generate webpack configuration with optional custom config */
|
38
|
+
generateWebpackConfig: (extraConfig?: Configuration) => Configuration
|
39
|
+
/** webpack-merge's merge function */
|
40
|
+
merge: typeof import("webpack-merge").merge
|
41
|
+
/** webpack-merge's mergeWithCustomize function */
|
42
|
+
mergeWithCustomize: typeof import("webpack-merge").mergeWithCustomize
|
43
|
+
/** webpack-merge's mergeWithRules function */
|
44
|
+
mergeWithRules: typeof import("webpack-merge").mergeWithRules
|
45
|
+
/** webpack-merge's unique function */
|
46
|
+
unique: typeof import("webpack-merge").unique
|
47
|
+
}
|
48
|
+
|
49
|
+
declare const shakapacker: ShakapackerExports
|
50
|
+
export = shakapacker
|
@@ -0,0 +1,50 @@
|
|
1
|
+
/**
|
2
|
+
* Manual type definitions for Shakapacker package exports.
|
3
|
+
*
|
4
|
+
* This file is manually maintained because TypeScript cannot infer types
|
5
|
+
* from the `export =` syntax with dynamic require() calls in index.ts.
|
6
|
+
*
|
7
|
+
* When adding/modifying exports in index.ts, update this file accordingly.
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { Configuration, RuleSetRule } from "webpack"
|
11
|
+
import type { Config, DevServerConfig, Env } from "./types"
|
12
|
+
|
13
|
+
/**
|
14
|
+
* The shape of the Shakapacker module exports.
|
15
|
+
* This interface represents the object exported via CommonJS `export =`.
|
16
|
+
*/
|
17
|
+
interface ShakapackerExports {
|
18
|
+
/** Shakapacker configuration from shakapacker.yml */
|
19
|
+
config: Config
|
20
|
+
/** Development server configuration */
|
21
|
+
devServer: DevServerConfig
|
22
|
+
/** Base webpack/rspack configuration */
|
23
|
+
baseConfig: Configuration
|
24
|
+
/** Environment configuration (railsEnv, nodeEnv, etc.) */
|
25
|
+
env: Env
|
26
|
+
/** Array of webpack/rspack loader rules */
|
27
|
+
rules: RuleSetRule[]
|
28
|
+
/** Check if a module exists in node_modules */
|
29
|
+
moduleExists: (packageName: string) => boolean
|
30
|
+
/** Process a file if a specific loader is available */
|
31
|
+
canProcess: <T = unknown>(
|
32
|
+
rule: string,
|
33
|
+
fn: (modulePath: string) => T
|
34
|
+
) => T | null
|
35
|
+
/** Whether CSS should be inlined (dev server with HMR) */
|
36
|
+
inliningCss: boolean
|
37
|
+
/** Generate webpack configuration with optional custom config */
|
38
|
+
generateWebpackConfig: (extraConfig?: Configuration) => Configuration
|
39
|
+
/** webpack-merge's merge function */
|
40
|
+
merge: typeof import("webpack-merge").merge
|
41
|
+
/** webpack-merge's mergeWithCustomize function */
|
42
|
+
mergeWithCustomize: typeof import("webpack-merge").mergeWithCustomize
|
43
|
+
/** webpack-merge's mergeWithRules function */
|
44
|
+
mergeWithRules: typeof import("webpack-merge").mergeWithRules
|
45
|
+
/** webpack-merge's unique function */
|
46
|
+
unique: typeof import("webpack-merge").unique
|
47
|
+
}
|
48
|
+
|
49
|
+
declare const shakapacker: ShakapackerExports
|
50
|
+
export = shakapacker
|
data/package/index.ts
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
/* eslint global-require: 0 */
|
2
2
|
/* eslint import/no-dynamic-require: 0 */
|
3
3
|
|
4
|
-
|
4
|
+
import * as webpackMerge from "webpack-merge"
|
5
5
|
import { resolve } from "path"
|
6
6
|
import { existsSync } from "fs"
|
7
7
|
// @ts-ignore: webpack is an optional peer dependency (using type-only import)
|
8
8
|
import type { Configuration } from "webpack"
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
import config from "./config"
|
10
|
+
import baseConfig from "./environments/base"
|
11
|
+
import devServer from "./dev_server"
|
12
|
+
import env from "./env"
|
13
|
+
import { moduleExists, canProcess } from "./utils/helpers"
|
14
|
+
import inliningCss from "./utils/inliningCss"
|
15
15
|
|
16
16
|
const rulesPath = resolve(__dirname, "rules", `${config.assets_bundler}.js`)
|
17
17
|
const rules = require(rulesPath)
|
data/package/loaders.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
// @ts-ignore: webpack is an optional peer dependency (using type-only import)
|
2
|
-
import type { LoaderDefinitionFunction } from
|
2
|
+
import type { LoaderDefinitionFunction } from "webpack"
|
3
3
|
|
4
4
|
export interface ShakapackerLoaderOptions {
|
5
5
|
[key: string]: any
|
@@ -25,4 +25,4 @@ export interface LoaderConfig {
|
|
25
25
|
}
|
26
26
|
|
27
27
|
export function resolveLoader(name: string): string
|
28
|
-
export function createLoader(config: LoaderConfig): LoaderConfig
|
28
|
+
export function createLoader(config: LoaderConfig): LoaderConfig
|
@@ -18,7 +18,7 @@ const getOptimization = (): OptimizationConfig => {
|
|
18
18
|
]
|
19
19
|
} catch (error: unknown) {
|
20
20
|
const errorMessage = error instanceof Error ? error.message : String(error)
|
21
|
-
const errorStack = error instanceof Error ? error.stack :
|
21
|
+
const errorStack = error instanceof Error ? error.stack : ""
|
22
22
|
// Log full error with stack trace
|
23
23
|
logError(
|
24
24
|
`Failed to configure Rspack minimizers: ${errorMessage}\n${errorStack}`
|
data/package/plugins/rspack.ts
CHANGED
@@ -18,7 +18,11 @@ interface EntrypointAssets {
|
|
18
18
|
|
19
19
|
interface Manifest {
|
20
20
|
entrypoints?: Record<string, { assets: EntrypointAssets }>
|
21
|
-
[key: string]:
|
21
|
+
[key: string]:
|
22
|
+
| string
|
23
|
+
| { assets: EntrypointAssets }
|
24
|
+
| Record<string, { assets: EntrypointAssets }>
|
25
|
+
| undefined
|
22
26
|
}
|
23
27
|
|
24
28
|
const getPlugins = (): unknown[] => {
|
@@ -29,7 +33,11 @@ const getPlugins = (): unknown[] => {
|
|
29
33
|
publicPath: config.publicPathWithoutCDN,
|
30
34
|
writeToFileEmit: true,
|
31
35
|
// rspack-manifest-plugin uses different option names than webpack-assets-manifest
|
32
|
-
generate: (
|
36
|
+
generate: (
|
37
|
+
seed: Manifest | null,
|
38
|
+
files: ManifestFile[],
|
39
|
+
entrypoints: Record<string, string[]>
|
40
|
+
) => {
|
33
41
|
const manifest: Manifest = seed || {}
|
34
42
|
|
35
43
|
// Add files mapping first
|
@@ -38,7 +46,10 @@ const getPlugins = (): unknown[] => {
|
|
38
46
|
})
|
39
47
|
|
40
48
|
// Add entrypoints information compatible with Shakapacker expectations
|
41
|
-
const entrypointsManifest: Record<
|
49
|
+
const entrypointsManifest: Record<
|
50
|
+
string,
|
51
|
+
{ assets: EntrypointAssets }
|
52
|
+
> = {}
|
42
53
|
Object.entries(entrypoints).forEach(
|
43
54
|
([entrypointName, entrypointFiles]) => {
|
44
55
|
const jsFiles = entrypointFiles
|
@@ -86,7 +97,7 @@ const getPlugins = (): unknown[] => {
|
|
86
97
|
}
|
87
98
|
|
88
99
|
// Use Rspack's built-in SubresourceIntegrityPlugin
|
89
|
-
if (config.integrity
|
100
|
+
if (config.integrity?.enabled) {
|
90
101
|
plugins.push(
|
91
102
|
new rspack.SubresourceIntegrityPlugin({
|
92
103
|
hashFuncNames: config.integrity.hash_functions,
|
data/package/plugins/webpack.ts
CHANGED
@@ -20,8 +20,12 @@ const getPlugins = (): unknown[] => {
|
|
20
20
|
output: config.manifestPath,
|
21
21
|
entrypointsUseAssets: true,
|
22
22
|
publicPath: config.publicPathWithoutCDN,
|
23
|
-
|
24
|
-
|
23
|
+
...(config.integrity
|
24
|
+
? {
|
25
|
+
integrity: config.integrity.enabled,
|
26
|
+
integrityHashes: config.integrity.hash_functions
|
27
|
+
}
|
28
|
+
: {})
|
25
29
|
})
|
26
30
|
]
|
27
31
|
|
@@ -40,7 +44,7 @@ const getPlugins = (): unknown[] => {
|
|
40
44
|
}
|
41
45
|
|
42
46
|
if (
|
43
|
-
config.integrity
|
47
|
+
config.integrity?.enabled &&
|
44
48
|
moduleExists("webpack-subresource-integrity")
|
45
49
|
) {
|
46
50
|
const SubresourceIntegrityPlugin = requireOrError(
|
data/package/rspack/index.ts
CHANGED
@@ -21,7 +21,10 @@ const { validateRspackDependencies } = require("../utils/validateDependencies")
|
|
21
21
|
const rulesPath = resolve(__dirname, "../rules", "rspack.js")
|
22
22
|
const rules = require(rulesPath)
|
23
23
|
|
24
|
-
const generateRspackConfig = (
|
24
|
+
const generateRspackConfig = (
|
25
|
+
extraConfig: RspackConfigWithDevServer = {},
|
26
|
+
...extraArgs: unknown[]
|
27
|
+
): RspackConfigWithDevServer => {
|
25
28
|
// Validate required dependencies first
|
26
29
|
validateRspackDependencies()
|
27
30
|
if (extraArgs.length > 0) {
|
@@ -49,7 +52,12 @@ const generateRspackConfig = (extraConfig: RspackConfigWithDevServer = {}, ...ex
|
|
49
52
|
}
|
50
53
|
|
51
54
|
// Re-export webpack-merge utilities for backward compatibility
|
52
|
-
export {
|
55
|
+
export {
|
56
|
+
merge,
|
57
|
+
mergeWithCustomize,
|
58
|
+
mergeWithRules,
|
59
|
+
unique
|
60
|
+
} from "webpack-merge"
|
53
61
|
|
54
62
|
export {
|
55
63
|
config, // shakapacker.yml
|
data/package/rules/raw.ts
CHANGED
data/package/rules/sass.ts
CHANGED
@@ -6,7 +6,7 @@ const { additional_paths: extraPaths } = require("../config")
|
|
6
6
|
|
7
7
|
export = canProcess("sass-loader", (resolvedPath: string) => {
|
8
8
|
const optionKey =
|
9
|
-
packageMajorVersion("sass-loader")
|
9
|
+
packageMajorVersion("sass-loader") >= 16 ? "loadPaths" : "includePaths"
|
10
10
|
return getStyleRule(/\.(scss|sass)(\.erb)?$/i, [
|
11
11
|
{
|
12
12
|
loader: resolvedPath,
|
data/package/types/README.md
CHANGED
@@ -8,8 +8,8 @@ Instead of importing types from deep paths:
|
|
8
8
|
|
9
9
|
```typescript
|
10
10
|
// ❌ Old way - importing from multiple deep paths
|
11
|
-
import type { Config } from
|
12
|
-
import type { WebpackConfigWithDevServer } from
|
11
|
+
import type { Config } from "shakapacker/package/types"
|
12
|
+
import type { WebpackConfigWithDevServer } from "shakapacker/package/environments/types"
|
13
13
|
```
|
14
14
|
|
15
15
|
You can now import all types from a single location:
|
@@ -20,12 +20,13 @@ import type {
|
|
20
20
|
Config,
|
21
21
|
WebpackConfigWithDevServer,
|
22
22
|
RspackConfigWithDevServer
|
23
|
-
} from
|
23
|
+
} from "shakapacker/types"
|
24
24
|
```
|
25
25
|
|
26
26
|
## Available Types
|
27
27
|
|
28
28
|
### Core Configuration Types
|
29
|
+
|
29
30
|
- `Config` - Main Shakapacker configuration interface
|
30
31
|
- `YamlConfig` - YAML configuration structure
|
31
32
|
- `LegacyConfig` - Legacy configuration with deprecated options
|
@@ -33,12 +34,14 @@ import type {
|
|
33
34
|
- `DevServerConfig` - Development server configuration
|
34
35
|
|
35
36
|
### Loader Types
|
37
|
+
|
36
38
|
- `ShakapackerLoader` - Loader interface
|
37
39
|
- `ShakapackerLoaderOptions` - Loader options interface
|
38
40
|
- `LoaderResolver` - Function type for resolving loaders
|
39
41
|
- `LoaderConfig` - Loader configuration interface
|
40
42
|
|
41
43
|
### Webpack/Rspack Types
|
44
|
+
|
42
45
|
- `WebpackConfigWithDevServer` - Webpack config with dev server
|
43
46
|
- `RspackConfigWithDevServer` - Rspack config with dev server
|
44
47
|
- `RspackPluginInstance` - Rspack plugin instance type
|
@@ -50,12 +53,14 @@ import type {
|
|
50
53
|
- `ReactRefreshRspackPlugin` - React refresh plugin for Rspack
|
51
54
|
|
52
55
|
### Webpack-Specific Types
|
56
|
+
|
53
57
|
- `ShakapackerWebpackConfig` - Extended Webpack configuration
|
54
58
|
- `ShakapackerRule` - Extended Webpack rule
|
55
59
|
- `LoaderType` - String or loader object type
|
56
60
|
- `LoaderUtils` - Loader utility functions
|
57
61
|
|
58
62
|
### Re-exported Types
|
63
|
+
|
59
64
|
- `WebpackConfiguration` - From 'webpack'
|
60
65
|
- `WebpackPluginInstance` - From 'webpack'
|
61
66
|
- `RuleSetRule` - From 'webpack'
|
@@ -64,25 +69,22 @@ import type {
|
|
64
69
|
## Example Usage
|
65
70
|
|
66
71
|
```typescript
|
67
|
-
import type {
|
68
|
-
Config,
|
69
|
-
WebpackConfigWithDevServer
|
70
|
-
} from 'shakapacker/types'
|
72
|
+
import type { Config, WebpackConfigWithDevServer } from "shakapacker/types"
|
71
73
|
|
72
74
|
const config: Config = {
|
73
|
-
source_path:
|
74
|
-
source_entry_path:
|
75
|
-
public_root_path:
|
76
|
-
public_output_path:
|
75
|
+
source_path: "app/javascript",
|
76
|
+
source_entry_path: "packs",
|
77
|
+
public_root_path: "public",
|
78
|
+
public_output_path: "packs"
|
77
79
|
// ... other config
|
78
80
|
}
|
79
81
|
|
80
82
|
const webpackConfig: WebpackConfigWithDevServer = {
|
81
|
-
mode:
|
83
|
+
mode: "development",
|
82
84
|
devServer: {
|
83
85
|
hot: true,
|
84
86
|
port: 3035
|
85
87
|
}
|
86
88
|
// ... other webpack config
|
87
89
|
}
|
88
|
-
```
|
90
|
+
```
|
data/package/types/index.ts
CHANGED
@@ -17,7 +17,7 @@ export type {
|
|
17
17
|
LegacyConfig,
|
18
18
|
Env,
|
19
19
|
DevServerConfig
|
20
|
-
} from
|
20
|
+
} from "../types"
|
21
21
|
|
22
22
|
// Loader types
|
23
23
|
export type {
|
@@ -25,7 +25,7 @@ export type {
|
|
25
25
|
ShakapackerLoaderOptions,
|
26
26
|
LoaderResolver,
|
27
27
|
LoaderConfig
|
28
|
-
} from
|
28
|
+
} from "../loaders"
|
29
29
|
|
30
30
|
// Webpack-specific types
|
31
31
|
export type {
|
@@ -35,7 +35,7 @@ export type {
|
|
35
35
|
ShakapackerLoader as WebpackLoader,
|
36
36
|
LoaderType,
|
37
37
|
LoaderUtils
|
38
|
-
} from
|
38
|
+
} from "../webpack-types"
|
39
39
|
|
40
40
|
// Environment configuration types
|
41
41
|
export type {
|
@@ -48,7 +48,7 @@ export type {
|
|
48
48
|
CompressionPluginConstructor,
|
49
49
|
ReactRefreshWebpackPlugin,
|
50
50
|
ReactRefreshRspackPlugin
|
51
|
-
} from
|
51
|
+
} from "../environments/types"
|
52
52
|
|
53
53
|
// Node.js error type (re-exported for convenience)
|
54
54
|
export type NodeJSError = NodeJS.ErrnoException
|
@@ -58,4 +58,4 @@ export type {
|
|
58
58
|
Configuration as WebpackConfiguration,
|
59
59
|
WebpackPluginInstance,
|
60
60
|
RuleSetRule
|
61
|
-
} from
|
61
|
+
} from "webpack"
|
data/package/types.ts
CHANGED