shakapacker 9.0.0.beta.4 → 9.0.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/.eslintignore +1 -0
- data/.github/workflows/claude-code-review.yml +1 -1
- data/.github/workflows/dummy.yml +4 -0
- data/.github/workflows/generator.yml +7 -0
- data/.github/workflows/node.yml +22 -0
- data/.github/workflows/ruby.yml +11 -0
- data/.github/workflows/test-bundlers.yml +27 -9
- data/.gitignore +20 -0
- data/.yalcignore +26 -0
- data/CHANGELOG.md +58 -40
- data/CONTRIBUTING.md +64 -0
- data/Gemfile.lock +1 -1
- data/README.md +80 -1
- data/docs/optional-peer-dependencies.md +198 -0
- data/docs/typescript.md +99 -0
- data/docs/v9_upgrade.md +79 -2
- data/lib/install/template.rb +8 -1
- data/lib/shakapacker/configuration.rb +58 -1
- data/lib/shakapacker/doctor.rb +751 -0
- data/lib/shakapacker/swc_migrator.rb +292 -0
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker.rb +1 -0
- data/lib/tasks/shakapacker/doctor.rake +8 -0
- data/lib/tasks/shakapacker/migrate_to_swc.rake +13 -0
- data/lib/tasks/shakapacker.rake +1 -0
- data/package/config.ts +162 -0
- data/package/{dev_server.js → dev_server.ts} +8 -5
- data/package/env.ts +67 -0
- data/package/environments/base.js +94 -117
- data/package/environments/base.ts +138 -0
- data/package/index.d.ts +3 -150
- data/package/{index.js → index.ts} +18 -8
- data/package/loaders.d.ts +28 -0
- data/package/types.ts +108 -0
- data/package/utils/configPath.ts +6 -0
- data/package/utils/{debug.js → debug.ts} +7 -7
- data/package/utils/defaultConfigPath.ts +4 -0
- data/package/utils/errorHelpers.ts +77 -0
- data/package/utils/{getStyleRule.js → getStyleRule.ts} +17 -20
- data/package/utils/helpers.ts +85 -0
- data/package/utils/{inliningCss.js → inliningCss.ts} +3 -3
- data/package/utils/{requireOrError.js → requireOrError.ts} +2 -2
- data/package/utils/snakeToCamelCase.ts +5 -0
- data/package/utils/typeGuards.ts +228 -0
- data/package/utils/{validateDependencies.js → validateDependencies.ts} +4 -4
- data/package/webpack-types.d.ts +33 -0
- data/package/webpackDevServerConfig.ts +117 -0
- data/package.json +112 -4
- data/test/peer-dependencies.sh +85 -0
- data/test/typescript/build.test.js +117 -0
- data/tsconfig.json +39 -0
- data/yarn.lock +1 -1
- metadata +34 -17
- data/package/config.js +0 -80
- data/package/env.js +0 -48
- data/package/utils/configPath.js +0 -4
- data/package/utils/defaultConfigPath.js +0 -2
- data/package/utils/helpers.js +0 -127
- data/package/utils/snakeToCamelCase.js +0 -5
- data/package/utils/validateCssModulesConfig.js +0 -91
- data/package/webpackDevServerConfig.js +0 -73
@@ -0,0 +1,33 @@
|
|
1
|
+
// @ts-ignore: webpack is an optional peer dependency (using type-only import)
|
2
|
+
import type { Configuration, RuleSetRule, RuleSetUseItem } from 'webpack'
|
3
|
+
|
4
|
+
export interface ShakapackerWebpackConfig extends Configuration {
|
5
|
+
module?: Configuration['module'] & {
|
6
|
+
rules?: RuleSetRule[]
|
7
|
+
}
|
8
|
+
}
|
9
|
+
|
10
|
+
export interface ShakapackerRule extends RuleSetRule {
|
11
|
+
test: RegExp
|
12
|
+
use: RuleSetUseItem[]
|
13
|
+
}
|
14
|
+
|
15
|
+
export interface ShakapackerLoaderOptions {
|
16
|
+
[key: string]: any
|
17
|
+
}
|
18
|
+
|
19
|
+
export interface ShakapackerLoader {
|
20
|
+
loader: string
|
21
|
+
options?: ShakapackerLoaderOptions
|
22
|
+
}
|
23
|
+
|
24
|
+
export type LoaderType = string | ShakapackerLoader
|
25
|
+
|
26
|
+
export interface LoaderUtils {
|
27
|
+
resolveLoader(name: string): string
|
28
|
+
createRule(test: RegExp, loaders: LoaderType[]): ShakapackerRule
|
29
|
+
getStyleLoader(extract?: boolean): LoaderType
|
30
|
+
getCssLoader(modules?: boolean): LoaderType
|
31
|
+
getPostCssLoader(): LoaderType
|
32
|
+
getSassLoader(): LoaderType
|
33
|
+
}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
import { DevServerConfig } from "./types"
|
2
|
+
const snakeToCamelCase = require("./utils/snakeToCamelCase")
|
3
|
+
|
4
|
+
const shakapackerDevServerYamlConfig = require("./dev_server") as DevServerConfig
|
5
|
+
const { outputPath: contentBase, publicPath } = require("./config") as {
|
6
|
+
outputPath: string
|
7
|
+
publicPath: string
|
8
|
+
}
|
9
|
+
|
10
|
+
interface WebpackDevServerConfig {
|
11
|
+
devMiddleware?: {
|
12
|
+
publicPath?: string
|
13
|
+
}
|
14
|
+
hot?: boolean | string
|
15
|
+
liveReload?: boolean
|
16
|
+
historyApiFallback?: boolean | {
|
17
|
+
disableDotRule?: boolean
|
18
|
+
}
|
19
|
+
static?: {
|
20
|
+
publicPath?: string
|
21
|
+
[key: string]: unknown
|
22
|
+
}
|
23
|
+
client?: Record<string, unknown>
|
24
|
+
allowedHosts?: "all" | "auto" | string | string[]
|
25
|
+
bonjour?: boolean | Record<string, unknown>
|
26
|
+
compress?: boolean
|
27
|
+
headers?: Record<string, unknown> | (() => Record<string, unknown>)
|
28
|
+
host?: "local-ip" | "local-ipv4" | "local-ipv6" | string
|
29
|
+
http2?: boolean
|
30
|
+
https?: boolean | Record<string, unknown>
|
31
|
+
ipc?: boolean | string
|
32
|
+
magicHtml?: boolean
|
33
|
+
onAfterSetupMiddleware?: (devServer: unknown) => void
|
34
|
+
onBeforeSetupMiddleware?: (devServer: unknown) => void
|
35
|
+
open?: boolean | string | string[] | Record<string, unknown> | Record<string, unknown>[]
|
36
|
+
port?: "auto" | string | number
|
37
|
+
proxy?: unknown
|
38
|
+
server?: string | boolean | Record<string, unknown>
|
39
|
+
setupExitSignals?: boolean
|
40
|
+
setupMiddlewares?: (middlewares: unknown[], devServer: unknown) => unknown[]
|
41
|
+
watchFiles?: string | string[] | unknown
|
42
|
+
webSocketServer?: string | boolean | Record<string, unknown>
|
43
|
+
[key: string]: unknown
|
44
|
+
}
|
45
|
+
|
46
|
+
const webpackDevServerMappedKeys = new Set([
|
47
|
+
// client, server, liveReload, devMiddleware are handled separately
|
48
|
+
"allowedHosts",
|
49
|
+
"bonjour",
|
50
|
+
"compress",
|
51
|
+
"headers",
|
52
|
+
"historyApiFallback",
|
53
|
+
"host",
|
54
|
+
"hot",
|
55
|
+
"http2",
|
56
|
+
"https",
|
57
|
+
"ipc",
|
58
|
+
"magicHtml",
|
59
|
+
"onAfterSetupMiddleware",
|
60
|
+
"onBeforeSetupMiddleware",
|
61
|
+
"open",
|
62
|
+
"port",
|
63
|
+
"proxy",
|
64
|
+
"server",
|
65
|
+
"setupExitSignals",
|
66
|
+
"setupMiddlewares",
|
67
|
+
"watchFiles",
|
68
|
+
"webSocketServer"
|
69
|
+
])
|
70
|
+
|
71
|
+
function createDevServerConfig(): WebpackDevServerConfig {
|
72
|
+
const devServerYamlConfig = { ...shakapackerDevServerYamlConfig } as DevServerConfig & Record<string, unknown>
|
73
|
+
const liveReload =
|
74
|
+
devServerYamlConfig.live_reload !== undefined
|
75
|
+
? devServerYamlConfig.live_reload
|
76
|
+
: !devServerYamlConfig.hmr
|
77
|
+
delete devServerYamlConfig.live_reload
|
78
|
+
|
79
|
+
const config: WebpackDevServerConfig = {
|
80
|
+
devMiddleware: {
|
81
|
+
publicPath
|
82
|
+
},
|
83
|
+
hot: devServerYamlConfig.hmr,
|
84
|
+
liveReload,
|
85
|
+
historyApiFallback: {
|
86
|
+
disableDotRule: true
|
87
|
+
},
|
88
|
+
static: {
|
89
|
+
publicPath: contentBase
|
90
|
+
}
|
91
|
+
}
|
92
|
+
delete devServerYamlConfig.hmr
|
93
|
+
|
94
|
+
if (devServerYamlConfig.static) {
|
95
|
+
config.static = {
|
96
|
+
...config.static,
|
97
|
+
...(typeof devServerYamlConfig.static === 'object' ? devServerYamlConfig.static as Record<string, unknown> : {})
|
98
|
+
}
|
99
|
+
delete devServerYamlConfig.static
|
100
|
+
}
|
101
|
+
|
102
|
+
if (devServerYamlConfig.client) {
|
103
|
+
config.client = devServerYamlConfig.client
|
104
|
+
delete devServerYamlConfig.client
|
105
|
+
}
|
106
|
+
|
107
|
+
Object.keys(devServerYamlConfig).forEach((yamlKey) => {
|
108
|
+
const camelYamlKey = snakeToCamelCase(yamlKey)
|
109
|
+
if (webpackDevServerMappedKeys.has(camelYamlKey)) {
|
110
|
+
config[camelYamlKey] = devServerYamlConfig[yamlKey]
|
111
|
+
}
|
112
|
+
})
|
113
|
+
|
114
|
+
return config
|
115
|
+
}
|
116
|
+
|
117
|
+
export = createDevServerConfig
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "shakapacker",
|
3
|
-
"version": "9.0.0-beta.
|
3
|
+
"version": "9.0.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": {
|
@@ -29,12 +29,17 @@
|
|
29
29
|
"lib/install/config/shakapacker.yml"
|
30
30
|
],
|
31
31
|
"scripts": {
|
32
|
+
"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",
|
33
|
+
"build": "tsc",
|
34
|
+
"build:types": "tsc",
|
32
35
|
"lint": "eslint .",
|
33
|
-
"test": "jest"
|
36
|
+
"test": "jest",
|
37
|
+
"type-check": "tsc --noEmit"
|
34
38
|
},
|
35
39
|
"dependencies": {
|
36
40
|
"js-yaml": "^4.1.0",
|
37
|
-
"path-complete-extname": "^1.0.0"
|
41
|
+
"path-complete-extname": "^1.0.0",
|
42
|
+
"webpack-merge": "^5.8.0"
|
38
43
|
},
|
39
44
|
"devDependencies": {
|
40
45
|
"@rspack/cli": "^1.4.11",
|
@@ -69,9 +74,112 @@
|
|
69
74
|
"typescript": "^5.9.2",
|
70
75
|
"webpack": "5.93.0",
|
71
76
|
"webpack-assets-manifest": "^5.0.6",
|
72
|
-
"webpack-merge": "^5.8.0",
|
73
77
|
"webpack-subresource-integrity": "^5.1.0"
|
74
78
|
},
|
79
|
+
"peerDependencies": {
|
80
|
+
"@babel/core": "^7.17.9",
|
81
|
+
"@babel/plugin-transform-runtime": "^7.17.0",
|
82
|
+
"@babel/preset-env": "^7.16.11",
|
83
|
+
"@babel/runtime": "^7.17.9",
|
84
|
+
"@rspack/core": "^1.0.0",
|
85
|
+
"@rspack/cli": "^1.0.0",
|
86
|
+
"@rspack/plugin-react-refresh": "^1.0.0",
|
87
|
+
"@types/babel__core": "^7.0.0",
|
88
|
+
"@types/webpack": "^5.0.0",
|
89
|
+
"babel-loader": "^8.2.4 || ^9.0.0 || ^10.0.0",
|
90
|
+
"compression-webpack-plugin": "^9.0.0 || ^10.0.0 || ^11.0.0",
|
91
|
+
"css-loader": "^6.8.1 || ^7.0.0",
|
92
|
+
"esbuild": "^0.14.0 || ^0.15.0 || ^0.16.0 || ^0.17.0 || ^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0 || ^0.22.0 || ^0.23.0 || ^0.24.0",
|
93
|
+
"esbuild-loader": "^2.0.0 || ^3.0.0 || ^4.0.0",
|
94
|
+
"mini-css-extract-plugin": "^2.0.0",
|
95
|
+
"rspack-manifest-plugin": "^5.0.0",
|
96
|
+
"sass": "^1.50.0",
|
97
|
+
"sass-loader": "^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0",
|
98
|
+
"swc-loader": "^0.1.15 || ^0.2.0",
|
99
|
+
"terser-webpack-plugin": "^5.3.1",
|
100
|
+
"webpack": "^5.76.0",
|
101
|
+
"webpack-assets-manifest": "^5.0.6 || ^6.0.0",
|
102
|
+
"webpack-cli": "^4.9.2 || ^5.0.0 || ^6.0.0",
|
103
|
+
"webpack-dev-server": "^4.15.2 || ^5.2.2",
|
104
|
+
"webpack-subresource-integrity": "^5.1.0"
|
105
|
+
},
|
106
|
+
"peerDependenciesMeta": {
|
107
|
+
"@babel/core": {
|
108
|
+
"optional": true
|
109
|
+
},
|
110
|
+
"@babel/plugin-transform-runtime": {
|
111
|
+
"optional": true
|
112
|
+
},
|
113
|
+
"@babel/preset-env": {
|
114
|
+
"optional": true
|
115
|
+
},
|
116
|
+
"@babel/runtime": {
|
117
|
+
"optional": true
|
118
|
+
},
|
119
|
+
"@rspack/core": {
|
120
|
+
"optional": true
|
121
|
+
},
|
122
|
+
"@rspack/cli": {
|
123
|
+
"optional": true
|
124
|
+
},
|
125
|
+
"@rspack/plugin-react-refresh": {
|
126
|
+
"optional": true
|
127
|
+
},
|
128
|
+
"@types/babel__core": {
|
129
|
+
"optional": true
|
130
|
+
},
|
131
|
+
"@types/webpack": {
|
132
|
+
"optional": true
|
133
|
+
},
|
134
|
+
"babel-loader": {
|
135
|
+
"optional": true
|
136
|
+
},
|
137
|
+
"compression-webpack-plugin": {
|
138
|
+
"optional": true
|
139
|
+
},
|
140
|
+
"css-loader": {
|
141
|
+
"optional": true
|
142
|
+
},
|
143
|
+
"esbuild": {
|
144
|
+
"optional": true
|
145
|
+
},
|
146
|
+
"esbuild-loader": {
|
147
|
+
"optional": true
|
148
|
+
},
|
149
|
+
"mini-css-extract-plugin": {
|
150
|
+
"optional": true
|
151
|
+
},
|
152
|
+
"rspack-manifest-plugin": {
|
153
|
+
"optional": true
|
154
|
+
},
|
155
|
+
"sass": {
|
156
|
+
"optional": true
|
157
|
+
},
|
158
|
+
"sass-loader": {
|
159
|
+
"optional": true
|
160
|
+
},
|
161
|
+
"swc-loader": {
|
162
|
+
"optional": true
|
163
|
+
},
|
164
|
+
"terser-webpack-plugin": {
|
165
|
+
"optional": true
|
166
|
+
},
|
167
|
+
"webpack": {
|
168
|
+
"optional": true
|
169
|
+
},
|
170
|
+
"webpack-assets-manifest": {
|
171
|
+
"optional": true
|
172
|
+
},
|
173
|
+
"webpack-cli": {
|
174
|
+
"optional": true
|
175
|
+
},
|
176
|
+
"webpack-dev-server": {
|
177
|
+
"optional": true
|
178
|
+
},
|
179
|
+
"webpack-subresource-integrity": {
|
180
|
+
"optional": true
|
181
|
+
}
|
182
|
+
},
|
75
183
|
"packageManager": "yarn@1.22.22",
|
76
184
|
"engines": {
|
77
185
|
"node": ">= 14",
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# Test script for verifying optional peer dependencies work correctly
|
4
|
+
# This ensures no warnings are shown during installation with different package managers
|
5
|
+
|
6
|
+
set -e
|
7
|
+
|
8
|
+
echo "Testing optional peer dependencies installation..."
|
9
|
+
|
10
|
+
# Colors for output
|
11
|
+
RED='\033[0;31m'
|
12
|
+
GREEN='\033[0;32m'
|
13
|
+
NC='\033[0m' # No Color
|
14
|
+
|
15
|
+
# Get the current directory (shakapacker root)
|
16
|
+
SHAKAPACKER_PATH=$(pwd)
|
17
|
+
|
18
|
+
# Create a temporary directory for tests
|
19
|
+
TEST_DIR=$(mktemp -d)
|
20
|
+
echo "Testing in: $TEST_DIR"
|
21
|
+
|
22
|
+
# Function to check for peer dependency warnings
|
23
|
+
check_warnings() {
|
24
|
+
local output=$1
|
25
|
+
local pkg_manager=$2
|
26
|
+
|
27
|
+
# Check for common peer dependency warning patterns
|
28
|
+
if echo "$output" | grep -i "peer" | grep -i "warn" > /dev/null 2>&1; then
|
29
|
+
echo -e "${RED}✗ $pkg_manager shows peer dependency warnings${NC}"
|
30
|
+
return 1
|
31
|
+
else
|
32
|
+
echo -e "${GREEN}✓ $pkg_manager installation clean (no warnings)${NC}"
|
33
|
+
return 0
|
34
|
+
fi
|
35
|
+
}
|
36
|
+
|
37
|
+
# Test with npm
|
38
|
+
echo ""
|
39
|
+
echo "Testing with npm..."
|
40
|
+
mkdir -p "$TEST_DIR/npm-test"
|
41
|
+
cd "$TEST_DIR/npm-test"
|
42
|
+
npm init -y > /dev/null 2>&1
|
43
|
+
NPM_OUTPUT=$(npm install "$SHAKAPACKER_PATH" 2>&1)
|
44
|
+
check_warnings "$NPM_OUTPUT" "npm"
|
45
|
+
NPM_RESULT=$?
|
46
|
+
|
47
|
+
# Test with yarn
|
48
|
+
echo ""
|
49
|
+
echo "Testing with yarn..."
|
50
|
+
mkdir -p "$TEST_DIR/yarn-test"
|
51
|
+
cd "$TEST_DIR/yarn-test"
|
52
|
+
yarn init -y > /dev/null 2>&1
|
53
|
+
YARN_OUTPUT=$(yarn add "$SHAKAPACKER_PATH" 2>&1)
|
54
|
+
check_warnings "$YARN_OUTPUT" "yarn"
|
55
|
+
YARN_RESULT=$?
|
56
|
+
|
57
|
+
# Test with pnpm (if available)
|
58
|
+
if command -v pnpm &> /dev/null; then
|
59
|
+
echo ""
|
60
|
+
echo "Testing with pnpm..."
|
61
|
+
mkdir -p "$TEST_DIR/pnpm-test"
|
62
|
+
cd "$TEST_DIR/pnpm-test"
|
63
|
+
pnpm init > /dev/null 2>&1
|
64
|
+
PNPM_OUTPUT=$(pnpm add "$SHAKAPACKER_PATH" 2>&1)
|
65
|
+
check_warnings "$PNPM_OUTPUT" "pnpm"
|
66
|
+
PNPM_RESULT=$?
|
67
|
+
else
|
68
|
+
echo ""
|
69
|
+
echo "Skipping pnpm test (not installed)"
|
70
|
+
PNPM_RESULT=0
|
71
|
+
fi
|
72
|
+
|
73
|
+
# Cleanup
|
74
|
+
rm -rf "$TEST_DIR"
|
75
|
+
|
76
|
+
# Summary
|
77
|
+
echo ""
|
78
|
+
echo "===== Test Summary ====="
|
79
|
+
if [ $NPM_RESULT -eq 0 ] && [ $YARN_RESULT -eq 0 ] && [ $PNPM_RESULT -eq 0 ]; then
|
80
|
+
echo -e "${GREEN}All tests passed! No peer dependency warnings detected.${NC}"
|
81
|
+
exit 0
|
82
|
+
else
|
83
|
+
echo -e "${RED}Some tests failed. Peer dependency warnings were detected.${NC}"
|
84
|
+
exit 1
|
85
|
+
fi
|
@@ -0,0 +1,117 @@
|
|
1
|
+
/* eslint-env jest */
|
2
|
+
const { execSync } = require("child_process")
|
3
|
+
const { existsSync, readFileSync } = require("fs")
|
4
|
+
const { join } = require("path")
|
5
|
+
|
6
|
+
describe("typescript build", () => {
|
7
|
+
const rootPath = join(__dirname, "..", "..")
|
8
|
+
|
9
|
+
describe("typescript compilation", () => {
|
10
|
+
it("should compile TypeScript files without errors", () => {
|
11
|
+
expect(() => {
|
12
|
+
execSync("npx tsc --noEmit", { cwd: rootPath, stdio: "pipe" })
|
13
|
+
}).not.toThrow()
|
14
|
+
})
|
15
|
+
|
16
|
+
it("should generate JavaScript files from TypeScript", () => {
|
17
|
+
// Check that key TypeScript files compile to JavaScript
|
18
|
+
const tsFiles = ["config", "env", "index", "dev_server"]
|
19
|
+
|
20
|
+
tsFiles.forEach((file) => {
|
21
|
+
const jsPath = join(rootPath, "package", `${file}.js`)
|
22
|
+
const tsPath = join(rootPath, "package", `${file}.ts`)
|
23
|
+
|
24
|
+
expect(existsSync(tsPath)).toBe(true)
|
25
|
+
expect(existsSync(jsPath)).toBe(true)
|
26
|
+
|
27
|
+
// Verify JS file is newer than TS file (has been compiled)
|
28
|
+
const jsContent = readFileSync(jsPath, "utf8")
|
29
|
+
expect(jsContent).toContain("use strict")
|
30
|
+
})
|
31
|
+
})
|
32
|
+
|
33
|
+
it("should generate type definition files", () => {
|
34
|
+
const dtsFiles = ["config", "env", "index", "types", "dev_server"]
|
35
|
+
|
36
|
+
dtsFiles.forEach((file) => {
|
37
|
+
const dtsPath = join(rootPath, "package", `${file}.d.ts`)
|
38
|
+
expect(existsSync(dtsPath)).toBe(true)
|
39
|
+
})
|
40
|
+
})
|
41
|
+
})
|
42
|
+
|
43
|
+
describe("commonJS compatibility", () => {
|
44
|
+
it("should export modules using CommonJS format", () => {
|
45
|
+
const config = require("../../package/config")
|
46
|
+
const env = require("../../package/env")
|
47
|
+
const helpers = require("../../package/utils/helpers")
|
48
|
+
|
49
|
+
expect(config).toBeDefined()
|
50
|
+
expect(env.railsEnv).toBeDefined()
|
51
|
+
expect(helpers.moduleExists).toBeDefined()
|
52
|
+
})
|
53
|
+
|
54
|
+
it("should maintain backward compatibility", () => {
|
55
|
+
const index = require("../../package/index")
|
56
|
+
|
57
|
+
// Check all expected exports are present
|
58
|
+
expect(index.config).toBeDefined()
|
59
|
+
expect(index.env).toBeDefined()
|
60
|
+
expect(index.generateWebpackConfig).toBeInstanceOf(Function)
|
61
|
+
expect(index.moduleExists).toBeInstanceOf(Function)
|
62
|
+
expect(index.canProcess).toBeInstanceOf(Function)
|
63
|
+
})
|
64
|
+
})
|
65
|
+
|
66
|
+
describe("type guards", () => {
|
67
|
+
it("should have runtime type validation functions", () => {
|
68
|
+
const typeGuards = require("../../package/utils/typeGuards")
|
69
|
+
|
70
|
+
expect(typeGuards.isValidConfig).toBeInstanceOf(Function)
|
71
|
+
expect(typeGuards.isValidDevServerConfig).toBeInstanceOf(Function)
|
72
|
+
expect(typeGuards.isValidYamlConfig).toBeInstanceOf(Function)
|
73
|
+
expect(typeGuards.isPartialConfig).toBeInstanceOf(Function)
|
74
|
+
})
|
75
|
+
|
76
|
+
it("should validate config objects correctly", () => {
|
77
|
+
const { isPartialConfig } = require("../../package/utils/typeGuards")
|
78
|
+
|
79
|
+
const validPartial = {
|
80
|
+
source_path: "app/javascript",
|
81
|
+
nested_entries: true
|
82
|
+
}
|
83
|
+
|
84
|
+
const invalidPartial = {
|
85
|
+
source_path: 123, // Should be string
|
86
|
+
nested_entries: "yes" // Should be boolean
|
87
|
+
}
|
88
|
+
|
89
|
+
expect(isPartialConfig(validPartial)).toBe(true)
|
90
|
+
expect(isPartialConfig(invalidPartial)).toBe(false)
|
91
|
+
})
|
92
|
+
})
|
93
|
+
|
94
|
+
describe("error helpers", () => {
|
95
|
+
it("should have error handling utilities", () => {
|
96
|
+
const errorHelpers = require("../../package/utils/errorHelpers")
|
97
|
+
|
98
|
+
expect(errorHelpers.isFileNotFoundError).toBeInstanceOf(Function)
|
99
|
+
expect(errorHelpers.isModuleNotFoundError).toBeInstanceOf(Function)
|
100
|
+
expect(errorHelpers.getErrorMessage).toBeInstanceOf(Function)
|
101
|
+
})
|
102
|
+
|
103
|
+
it("should correctly identify ENOENT errors", () => {
|
104
|
+
const {
|
105
|
+
isFileNotFoundError
|
106
|
+
} = require("../../package/utils/errorHelpers")
|
107
|
+
|
108
|
+
const enoentError = new Error("File not found")
|
109
|
+
enoentError.code = "ENOENT"
|
110
|
+
|
111
|
+
const otherError = new Error("Other error")
|
112
|
+
|
113
|
+
expect(isFileNotFoundError(enoentError)).toBe(true)
|
114
|
+
expect(isFileNotFoundError(otherError)).toBe(false)
|
115
|
+
})
|
116
|
+
})
|
117
|
+
})
|
data/tsconfig.json
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"compilerOptions": {
|
3
|
+
"target": "ES2020",
|
4
|
+
"module": "commonjs",
|
5
|
+
"lib": ["ES2020"],
|
6
|
+
"typeRoots": ["./node_modules/@types", "node_modules/@types", "../node_modules/@types"],
|
7
|
+
"declaration": true,
|
8
|
+
"declarationMap": true,
|
9
|
+
"outDir": "./package",
|
10
|
+
"rootDir": "./package",
|
11
|
+
"strict": true,
|
12
|
+
"esModuleInterop": true,
|
13
|
+
"skipLibCheck": true,
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
15
|
+
"resolveJsonModule": true,
|
16
|
+
"moduleResolution": "node",
|
17
|
+
"allowJs": true,
|
18
|
+
"checkJs": false,
|
19
|
+
"noImplicitAny": true,
|
20
|
+
"strictNullChecks": true,
|
21
|
+
"strictFunctionTypes": true,
|
22
|
+
"strictBindCallApply": true,
|
23
|
+
"strictPropertyInitialization": false,
|
24
|
+
"noImplicitThis": true,
|
25
|
+
"alwaysStrict": false,
|
26
|
+
"allowSyntheticDefaultImports": true,
|
27
|
+
"preserveConstEnums": true,
|
28
|
+
"isolatedModules": true,
|
29
|
+
"removeComments": false
|
30
|
+
},
|
31
|
+
"include": [
|
32
|
+
"package/**/*.ts"
|
33
|
+
],
|
34
|
+
"exclude": [
|
35
|
+
"node_modules",
|
36
|
+
"package/**/*.test.ts",
|
37
|
+
"package/**/*.spec.ts"
|
38
|
+
]
|
39
|
+
}
|
data/yarn.lock
CHANGED
@@ -5997,7 +5997,7 @@ webpack-merge@*:
|
|
5997
5997
|
|
5998
5998
|
webpack-merge@^5.8.0:
|
5999
5999
|
version "5.10.0"
|
6000
|
-
resolved "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.10.0.tgz"
|
6000
|
+
resolved "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.10.0.tgz#a3ad5d773241e9c682803abf628d4cd62b8a4177"
|
6001
6001
|
integrity sha512-+4zXKdx7UnO+1jaN4l2lHVD+mFvnlZQP/6ljaJVb4SZiwIKeUnrT5l0gkT8z+n4hKpC+jpOv6O9R+gLtag7pSA==
|
6002
6002
|
dependencies:
|
6003
6003
|
clone-deep "^4.0.1"
|
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.0.0.beta.
|
4
|
+
version: 9.0.0.beta.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -149,6 +149,7 @@ files:
|
|
149
149
|
- ".node-version"
|
150
150
|
- ".rspec"
|
151
151
|
- ".rubocop.yml"
|
152
|
+
- ".yalcignore"
|
152
153
|
- CHANGELOG.md
|
153
154
|
- CLAUDE.md
|
154
155
|
- CONTRIBUTING.md
|
@@ -171,6 +172,7 @@ files:
|
|
171
172
|
- docs/customizing_babel_config.md
|
172
173
|
- docs/deployment.md
|
173
174
|
- docs/developing_shakapacker.md
|
175
|
+
- docs/optional-peer-dependencies.md
|
174
176
|
- docs/peer-dependencies.md
|
175
177
|
- docs/react.md
|
176
178
|
- docs/rspack.md
|
@@ -180,6 +182,7 @@ files:
|
|
180
182
|
- docs/subresource_integrity.md
|
181
183
|
- docs/transpiler-performance.md
|
182
184
|
- docs/troubleshooting.md
|
185
|
+
- docs/typescript.md
|
183
186
|
- docs/using_esbuild_loader.md
|
184
187
|
- docs/using_swc_loader.md
|
185
188
|
- docs/v6_upgrade.md
|
@@ -214,6 +217,7 @@ files:
|
|
214
217
|
- lib/shakapacker/dev_server_proxy.rb
|
215
218
|
- lib/shakapacker/dev_server_runner.rb
|
216
219
|
- lib/shakapacker/digest_strategy.rb
|
220
|
+
- lib/shakapacker/doctor.rb
|
217
221
|
- lib/shakapacker/env.rb
|
218
222
|
- lib/shakapacker/helper.rb
|
219
223
|
- lib/shakapacker/instance.rb
|
@@ -222,6 +226,7 @@ files:
|
|
222
226
|
- lib/shakapacker/railtie.rb
|
223
227
|
- lib/shakapacker/rspack_runner.rb
|
224
228
|
- lib/shakapacker/runner.rb
|
229
|
+
- lib/shakapacker/swc_migrator.rb
|
225
230
|
- lib/shakapacker/utils/manager.rb
|
226
231
|
- lib/shakapacker/utils/misc.rb
|
227
232
|
- lib/shakapacker/utils/version_syntax_converter.rb
|
@@ -236,22 +241,26 @@ files:
|
|
236
241
|
- lib/tasks/shakapacker/clean.rake
|
237
242
|
- lib/tasks/shakapacker/clobber.rake
|
238
243
|
- lib/tasks/shakapacker/compile.rake
|
244
|
+
- lib/tasks/shakapacker/doctor.rake
|
239
245
|
- lib/tasks/shakapacker/info.rake
|
240
246
|
- lib/tasks/shakapacker/install.rake
|
247
|
+
- lib/tasks/shakapacker/migrate_to_swc.rake
|
241
248
|
- lib/tasks/shakapacker/verify_config.rake
|
242
249
|
- lib/tasks/shakapacker/verify_install.rake
|
243
250
|
- package.json
|
244
251
|
- package/babel/preset.js
|
245
|
-
- package/config.
|
246
|
-
- package/dev_server.
|
247
|
-
- package/env.
|
252
|
+
- package/config.ts
|
253
|
+
- package/dev_server.ts
|
254
|
+
- package/env.ts
|
248
255
|
- package/environments/base.js
|
256
|
+
- package/environments/base.ts
|
249
257
|
- package/environments/development.js
|
250
258
|
- package/environments/production.js
|
251
259
|
- package/environments/test.js
|
252
260
|
- package/esbuild/index.js
|
253
261
|
- package/index.d.ts
|
254
|
-
- package/index.
|
262
|
+
- package/index.ts
|
263
|
+
- package/loaders.d.ts
|
255
264
|
- package/optimization/rspack.js
|
256
265
|
- package/optimization/webpack.js
|
257
266
|
- package/plugins/rspack.js
|
@@ -272,17 +281,20 @@ files:
|
|
272
281
|
- package/rules/swc.js
|
273
282
|
- package/rules/webpack.js
|
274
283
|
- package/swc/index.js
|
275
|
-
- package/
|
276
|
-
- package/utils/
|
277
|
-
- package/utils/
|
278
|
-
- package/utils/
|
279
|
-
- package/utils/
|
280
|
-
- package/utils/
|
281
|
-
- package/utils/
|
282
|
-
- package/utils/
|
283
|
-
- package/utils/
|
284
|
-
- package/utils/
|
285
|
-
- package/
|
284
|
+
- package/types.ts
|
285
|
+
- package/utils/configPath.ts
|
286
|
+
- package/utils/debug.ts
|
287
|
+
- package/utils/defaultConfigPath.ts
|
288
|
+
- package/utils/errorHelpers.ts
|
289
|
+
- package/utils/getStyleRule.ts
|
290
|
+
- package/utils/helpers.ts
|
291
|
+
- package/utils/inliningCss.ts
|
292
|
+
- package/utils/requireOrError.ts
|
293
|
+
- package/utils/snakeToCamelCase.ts
|
294
|
+
- package/utils/typeGuards.ts
|
295
|
+
- package/utils/validateDependencies.ts
|
296
|
+
- package/webpack-types.d.ts
|
297
|
+
- package/webpackDevServerConfig.ts
|
286
298
|
- prettier.config.js
|
287
299
|
- shakapacker.gemspec
|
288
300
|
- test/helpers.js
|
@@ -306,15 +318,18 @@ files:
|
|
306
318
|
- test/package/rules/webpack.test.js
|
307
319
|
- test/package/staging.test.js
|
308
320
|
- test/package/test.test.js
|
321
|
+
- test/peer-dependencies.sh
|
309
322
|
- test/resolver.js
|
323
|
+
- test/typescript/build.test.js
|
310
324
|
- tools/README.md
|
311
325
|
- tools/css-modules-v9-codemod.js
|
326
|
+
- tsconfig.json
|
312
327
|
- yarn.lock
|
313
328
|
homepage: https://github.com/shakacode/shakapacker
|
314
329
|
licenses:
|
315
330
|
- MIT
|
316
331
|
metadata:
|
317
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.0.0.beta.
|
332
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.0.0.beta.6
|
318
333
|
rdoc_options: []
|
319
334
|
require_paths:
|
320
335
|
- lib
|
@@ -354,4 +369,6 @@ test_files:
|
|
354
369
|
- test/package/rules/webpack.test.js
|
355
370
|
- test/package/staging.test.js
|
356
371
|
- test/package/test.test.js
|
372
|
+
- test/peer-dependencies.sh
|
357
373
|
- test/resolver.js
|
374
|
+
- test/typescript/build.test.js
|