shakapacker 9.0.0.beta.9 → 9.0.0.beta.11
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 +98 -16
- data/Gemfile.lock +1 -1
- data/docs/transpiler-migration.md +33 -36
- data/docs/v9_upgrade.md +80 -26
- data/lib/shakapacker/doctor.rb +10 -11
- data/lib/shakapacker/swc_migrator.rb +64 -38
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker.rb +1 -1
- data/package/env.ts +25 -13
- data/package.json +1 -1
- data/test/package/config.test.js +3 -0
- data/test/package/env.test.js +42 -7
- data/test/package/environments/base.test.js +4 -0
- data/test/package/staging.test.js +4 -3
- metadata +2 -2
data/test/package/env.test.js
CHANGED
|
@@ -24,6 +24,18 @@ describe("Env", () => {
|
|
|
24
24
|
delete process.env.NODE_ENV
|
|
25
25
|
expect(require("../../package/env")).toStrictEqual({
|
|
26
26
|
railsEnv: "development",
|
|
27
|
+
nodeEnv: "development",
|
|
28
|
+
isProduction: false,
|
|
29
|
+
isDevelopment: true,
|
|
30
|
+
runningWebpackDevServer: false
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test("with undefined NODE_ENV and RAILS_ENV set to production", () => {
|
|
35
|
+
process.env.RAILS_ENV = "production"
|
|
36
|
+
delete process.env.NODE_ENV
|
|
37
|
+
expect(require("../../package/env")).toStrictEqual({
|
|
38
|
+
railsEnv: "production",
|
|
27
39
|
nodeEnv: "production",
|
|
28
40
|
isProduction: true,
|
|
29
41
|
isDevelopment: false,
|
|
@@ -35,10 +47,10 @@ describe("Env", () => {
|
|
|
35
47
|
delete process.env.NODE_ENV
|
|
36
48
|
delete process.env.RAILS_ENV
|
|
37
49
|
expect(require("../../package/env")).toStrictEqual({
|
|
38
|
-
railsEnv: "
|
|
39
|
-
nodeEnv: "
|
|
40
|
-
isProduction:
|
|
41
|
-
isDevelopment:
|
|
50
|
+
railsEnv: "development",
|
|
51
|
+
nodeEnv: "development",
|
|
52
|
+
isProduction: false,
|
|
53
|
+
isDevelopment: true,
|
|
42
54
|
runningWebpackDevServer: false
|
|
43
55
|
})
|
|
44
56
|
})
|
|
@@ -48,10 +60,33 @@ describe("Env", () => {
|
|
|
48
60
|
process.env.NODE_ENV = "staging"
|
|
49
61
|
expect(require("../../package/env")).toStrictEqual({
|
|
50
62
|
railsEnv: "staging",
|
|
51
|
-
nodeEnv: "
|
|
52
|
-
isProduction:
|
|
53
|
-
isDevelopment:
|
|
63
|
+
nodeEnv: "development",
|
|
64
|
+
isProduction: false,
|
|
65
|
+
isDevelopment: true,
|
|
66
|
+
runningWebpackDevServer: false
|
|
67
|
+
})
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
test("rejects malicious NODE_ENV values and uses default", () => {
|
|
71
|
+
process.env.RAILS_ENV = "development"
|
|
72
|
+
process.env.NODE_ENV = "../../../etc/passwd"
|
|
73
|
+
expect(require("../../package/env")).toStrictEqual({
|
|
74
|
+
railsEnv: "development",
|
|
75
|
+
nodeEnv: "development",
|
|
76
|
+
isProduction: false,
|
|
77
|
+
isDevelopment: true,
|
|
54
78
|
runningWebpackDevServer: false
|
|
55
79
|
})
|
|
56
80
|
})
|
|
81
|
+
|
|
82
|
+
test("warns when NODE_ENV is invalid", () => {
|
|
83
|
+
const consoleSpy = jest.spyOn(console, "warn").mockImplementation()
|
|
84
|
+
process.env.NODE_ENV = "invalid"
|
|
85
|
+
delete process.env.RAILS_ENV
|
|
86
|
+
require("../../package/env")
|
|
87
|
+
expect(consoleSpy).toHaveBeenCalledWith(
|
|
88
|
+
expect.stringContaining("Invalid NODE_ENV value: invalid")
|
|
89
|
+
)
|
|
90
|
+
consoleSpy.mockRestore()
|
|
91
|
+
})
|
|
57
92
|
})
|
|
@@ -7,6 +7,10 @@ const { chdirTestApp, resetEnv } = require("../../helpers")
|
|
|
7
7
|
const rootPath = process.cwd()
|
|
8
8
|
chdirTestApp()
|
|
9
9
|
|
|
10
|
+
// Set NODE_ENV before requiring modules to ensure contenthash is enabled
|
|
11
|
+
// Base config tests expect production-like behavior with contenthash
|
|
12
|
+
process.env.NODE_ENV = "production"
|
|
13
|
+
|
|
10
14
|
const baseConfig = require("../../../package/environments/base")
|
|
11
15
|
const config = require("../../../package/config")
|
|
12
16
|
|
|
@@ -19,7 +19,7 @@ describe("Custom environment", () => {
|
|
|
19
19
|
describe("generateWebpackConfig", () => {
|
|
20
20
|
beforeEach(() => jest.resetModules())
|
|
21
21
|
|
|
22
|
-
test("should use staging config and default
|
|
22
|
+
test("should use staging config and default development environment", () => {
|
|
23
23
|
process.env.RAILS_ENV = "staging"
|
|
24
24
|
delete process.env.NODE_ENV
|
|
25
25
|
|
|
@@ -31,9 +31,10 @@ describe("Custom environment", () => {
|
|
|
31
31
|
resolve("public", "packs-staging")
|
|
32
32
|
)
|
|
33
33
|
expect(webpackConfig.output.publicPath).toBe("/packs-staging/")
|
|
34
|
+
// With the NODE_ENV fix, staging now defaults to development environment
|
|
35
|
+
// instead of production, providing better DX for staging environments
|
|
34
36
|
expect(webpackConfig).toMatchObject({
|
|
35
|
-
devtool: "source-map"
|
|
36
|
-
stats: "normal"
|
|
37
|
+
devtool: "cheap-module-source-map"
|
|
37
38
|
})
|
|
38
39
|
})
|
|
39
40
|
})
|
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.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- David Heinemeier Hansson
|
|
@@ -347,7 +347,7 @@ homepage: https://github.com/shakacode/shakapacker
|
|
|
347
347
|
licenses:
|
|
348
348
|
- MIT
|
|
349
349
|
metadata:
|
|
350
|
-
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.0.0.beta.
|
|
350
|
+
source_code_uri: https://github.com/shakacode/shakapacker/tree/v9.0.0.beta.11
|
|
351
351
|
rdoc_options: []
|
|
352
352
|
require_paths:
|
|
353
353
|
- lib
|