shakapacker 8.0.1 → 8.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11198f6552ef8050f8946a58ebdf5ff5cffa7a79a9dd8aec3932afd1b7befdc3
4
- data.tar.gz: 7b50eca8202c5f2bcadabd61d5f9dfb15c48a91d5b4c45125beb58c5e1943ce1
3
+ metadata.gz: db9b65b6bcad3c69564cc6e9a1c81ef86586b551cceac4426ff4648388943063
4
+ data.tar.gz: 764219a7ff3a435f16bf8554f538f56b5d32f29e1849cdf06241504098b5f9c9
5
5
  SHA512:
6
- metadata.gz: 82d676202bfbd8d99d0192e91f1215715094122f32e3776c9ab394cb9f35c7e0bbc67f31aacc88b07c4081b059c46011be883c7bf4f48988f82d3f18a9b99024
7
- data.tar.gz: dac55e80ee92fa06ba53580b0555a677788dfb0d061148db7fef18bd34b9ad11cbe3350b4ee84609b3207d0f2dc45a9e6a454f21eb2dbf3688e17eaf7861bf44
6
+ metadata.gz: 1b45a4a37953a95d40eeaa8382350991058e074157594a8eeb977eace38db31d0c2507db9aec61eb8eea20485e135d68e9e9d688fc8fe094f4672532715ecc01
7
+ data.tar.gz: b053d207e3e1d56ab2e92987d216212f75e4b6d41d49d6b5bed1ccfdb29d917b94ac4d17220f607253ffc9d335de733089deb1e5aca44dc389a6177168e244da
data/CHANGELOG.md CHANGED
@@ -10,6 +10,12 @@ _next_ branch is for v8 changes
10
10
  ## [Unreleased]
11
11
  Changes since the last non-beta release.
12
12
 
13
+ ### Changed
14
+
15
+ - Fix wrong instruction in esbuild loader documentation [PR 504](https://github.com/shakacode/shakapacker/pull/504) by [adriangohjw](https://github.com/adriangohjw)
16
+
17
+ ## [v8.0.1] - July 10, 2024
18
+
13
19
  ### Changed
14
20
  - Update outdated GitHub Actions to use Node.js 20.0 versions instead [PR 497](https://github.com/shakacode/shakapacker/pull/497) by [adriangohjw](https://github.com/adriangohjw).
15
21
  - Allow `webpack-merge` v6 to be used [PR 502](https://github.com/shakacode/shakapacker/pull/502) by [G-Rath](https://github.com/g-rath).
@@ -380,7 +386,8 @@ Note: [Rubygem is 6.3.0.pre.rc.1](https://rubygems.org/gems/shakapacker/versions
380
386
  ## v5.4.3 and prior changes from rails/webpacker
381
387
  See [CHANGELOG.md in rails/webpacker (up to v5.4.3)](https://github.com/rails/webpacker/blob/master/CHANGELOG.md)
382
388
 
383
- [Unreleased]: https://github.com/shakacode/shakapacker/compare/v8.0.0...main
389
+ [Unreleased]: https://github.com/shakacode/shakapacker/compare/v8.0.1...main
390
+ [v8.0.1]: https://github.com/shakacode/shakapacker/compare/v8.0.0...v8.0.1
384
391
  [v8.0.0]: https://github.com/shakacode/shakapacker/compare/v7.2.3...v8.0.0
385
392
  [v7.2.3]: https://github.com/shakacode/shakapacker/compare/v7.2.2...v7.2.3
386
393
  [v7.2.2]: https://github.com/shakacode/shakapacker/compare/v7.2.1...v7.2.2
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shakapacker (8.0.1)
4
+ shakapacker (8.0.2)
5
5
  activesupport (>= 5.2)
6
6
  package_json
7
7
  rack-proxy (>= 0.6.1)
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "./wat",
3
+ "version": "12.0.0"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "main": "./lib/api.js",
3
+ "version": "16.56.81"
4
+ }
@@ -27,7 +27,7 @@ To use esbuild as your transpiler today. You need to do two things:
27
27
  npm install esbuild esbuild-loader
28
28
  ```
29
29
 
30
- 2. Add or change `shakapacker_loader` value in your default `shakapacker.yml` config to `esbuild`
30
+ 2. Add or change `webpack_loader` value in your default `shakapacker.yml` config to `esbuild`
31
31
  The default configuration of babel is done by using `package.json` to use the file within the `shakapacker` package.
32
32
 
33
33
  ```yml
data/jest.config.js CHANGED
@@ -1,4 +1,5 @@
1
1
  module.exports = {
2
2
  roots: ["<rootDir>/test"],
3
- testPathIgnorePatterns: ["/__fixtures__/", "/__utils__/"]
3
+ testPathIgnorePatterns: ["/__fixtures__/", "/__utils__/"],
4
+ resolver: "<rootDir>/test/resolver"
4
5
  }
@@ -1,4 +1,4 @@
1
1
  module Shakapacker
2
2
  # Change the version in package.json too, please!
3
- VERSION = "8.0.1".freeze
3
+ VERSION = "8.0.2".freeze
4
4
  end
@@ -1,16 +1,18 @@
1
1
  /* eslint global-require: 0 */
2
2
 
3
3
  const getStyleRule = require("../utils/getStyleRule")
4
- const { canProcess } = require("../utils/helpers")
5
- const { additional_paths: includePaths } = require("../config")
4
+ const { canProcess, packageMajorVersion } = require("../utils/helpers")
5
+ const { additional_paths: extraPaths } = require("../config")
6
6
 
7
- module.exports = canProcess("sass-loader", (resolvedPath) =>
8
- getStyleRule(/\.(scss|sass)(\.erb)?$/i, [
7
+ module.exports = canProcess("sass-loader", (resolvedPath) => {
8
+ const optionKey =
9
+ packageMajorVersion("sass-loader") > 15 ? "loadPaths" : "includePaths"
10
+ return getStyleRule(/\.(scss|sass)(\.erb)?$/i, [
9
11
  {
10
12
  loader: resolvedPath,
11
13
  options: {
12
- sassOptions: { includePaths }
14
+ sassOptions: { [optionKey]: extraPaths }
13
15
  }
14
16
  }
15
17
  ])
16
- )
18
+ })
@@ -41,10 +41,18 @@ const loaderMatches = (configLoader, loaderToCheck, fn) => {
41
41
  return fn()
42
42
  }
43
43
 
44
+ const packageMajorVersion = (packageName) => {
45
+ // eslint-disable-next-line import/no-dynamic-require
46
+ const packageJsonPath = require.resolve(`${packageName}/package.json`)
47
+ // eslint-disable-next-line import/no-dynamic-require, global-require
48
+ return require(packageJsonPath).version.match(/^\d+/)[0]
49
+ }
50
+
44
51
  module.exports = {
45
52
  isBoolean,
46
53
  ensureTrailingSlash,
47
54
  canProcess,
48
55
  moduleExists,
49
- loaderMatches
56
+ loaderMatches,
57
+ packageMajorVersion
50
58
  }
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shakapacker",
3
- "version": "8.0.1",
3
+ "version": "8.0.2",
4
4
  "description": "Use webpack to manage app-like JavaScript modules in Rails",
5
5
  "homepage": "https://github.com/shakacode/shakapacker",
6
6
  "bugs": {
@@ -4,6 +4,15 @@ const { chdirTestApp, resetEnv } = require("../helpers")
4
4
  const rootPath = process.cwd()
5
5
  chdirTestApp()
6
6
 
7
+ jest.mock("../../package/utils/helpers", () => {
8
+ const original = jest.requireActual("../../package/utils/helpers")
9
+ const moduleExists = () => false
10
+ return {
11
+ ...original,
12
+ moduleExists
13
+ }
14
+ })
15
+
7
16
  describe("Development environment", () => {
8
17
  beforeEach(() => jest.resetModules() && resetEnv())
9
18
  afterAll(() => process.chdir(rootPath))
@@ -10,6 +10,15 @@ chdirTestApp()
10
10
  const baseConfig = require("../../../package/environments/base")
11
11
  const config = require("../../../package/config")
12
12
 
13
+ jest.mock("../../../package/utils/helpers", () => {
14
+ const original = jest.requireActual("../../../package/utils/helpers")
15
+ const moduleExists = () => false
16
+ return {
17
+ ...original,
18
+ moduleExists
19
+ }
20
+ })
21
+
13
22
  describe("Base config", () => {
14
23
  beforeEach(() => jest.resetModules() && resetEnv())
15
24
  afterAll(() => process.chdir(rootPath))
@@ -3,6 +3,15 @@ const { chdirTestApp, resetEnv } = require("../../helpers")
3
3
  const rootPath = process.cwd()
4
4
  chdirTestApp()
5
5
 
6
+ jest.mock("../../../package/utils/helpers", () => {
7
+ const original = jest.requireActual("../../../package/utils/helpers")
8
+ const moduleExists = () => false
9
+ return {
10
+ ...original,
11
+ moduleExists
12
+ }
13
+ })
14
+
6
15
  describe("Development specific config", () => {
7
16
  beforeEach(() => {
8
17
  jest.resetModules()
@@ -3,6 +3,15 @@ const { chdirTestApp, resetEnv } = require("../../helpers")
3
3
  const rootPath = process.cwd()
4
4
  chdirTestApp()
5
5
 
6
+ jest.mock("../../../package/utils/helpers", () => {
7
+ const original = jest.requireActual("../../../package/utils/helpers")
8
+ const moduleExists = () => false
9
+ return {
10
+ ...original,
11
+ moduleExists
12
+ }
13
+ })
14
+
6
15
  describe("Production specific config", () => {
7
16
  beforeEach(() => {
8
17
  jest.resetModules()
@@ -0,0 +1,11 @@
1
+ const { packageMajorVersion } = require("../../package/utils/helpers")
2
+
3
+ describe("packageMajorVersion", () => {
4
+ test("should find that sass-loader is v16", () => {
5
+ expect(packageMajorVersion("sass-loader")).toBe("16")
6
+ })
7
+
8
+ test("should find that nonexistent is v12", () => {
9
+ expect(packageMajorVersion("nonexistent")).toBe("12")
10
+ })
11
+ })
@@ -1,5 +1,14 @@
1
1
  const index = require("../../package/index")
2
2
 
3
+ jest.mock("../../package/utils/helpers", () => {
4
+ const original = jest.requireActual("../../package/utils/helpers")
5
+ const moduleExists = () => false
6
+ return {
7
+ ...original,
8
+ moduleExists
9
+ }
10
+ })
11
+
3
12
  describe("index", () => {
4
13
  test("exports webpack-merge v5 functions", () => {
5
14
  expect(index.merge).toBeInstanceOf(Function)
@@ -4,6 +4,15 @@ const { chdirTestApp } = require("../helpers")
4
4
  const rootPath = process.cwd()
5
5
  chdirTestApp()
6
6
 
7
+ jest.mock("../../package/utils/helpers", () => {
8
+ const original = jest.requireActual("../../package/utils/helpers")
9
+ const moduleExists = () => false
10
+ return {
11
+ ...original,
12
+ moduleExists
13
+ }
14
+ })
15
+
7
16
  describe("Production environment", () => {
8
17
  afterAll(() => process.chdir(rootPath))
9
18
 
@@ -1,5 +1,14 @@
1
1
  const rules = require("../../../package/rules/index")
2
2
 
3
+ jest.mock("../../../package/utils/helpers", () => {
4
+ const original = jest.requireActual("../../../package/utils/helpers")
5
+ const moduleExists = () => false
6
+ return {
7
+ ...original,
8
+ moduleExists
9
+ }
10
+ })
11
+
3
12
  describe("index", () => {
4
13
  test("rule tests are regexes", () => {
5
14
  rules.forEach((rule) => expect(rule.test instanceof RegExp).toBe(true))
@@ -0,0 +1,23 @@
1
+ const sass = require("../../../package/rules/sass")
2
+
3
+ jest.mock("../../../package/utils/helpers", () => {
4
+ const original = jest.requireActual("../../../package/utils/helpers")
5
+ const canProcess = (rule, fn) => {
6
+ return fn("This path was mocked")
7
+ }
8
+ const packageMajorVersion = () => "15"
9
+ return {
10
+ ...original,
11
+ canProcess,
12
+ packageMajorVersion
13
+ }
14
+ })
15
+
16
+ jest.mock("../../../package/utils/inliningCss", () => true)
17
+
18
+ describe("sass rule", () => {
19
+ test("contains loadPaths as the sassOptions key if sass-loader is v15 or earlier", () => {
20
+ expect(typeof sass.use[3].options.sassOptions.includePaths).toBe("object")
21
+ expect(typeof sass.use[3].options.sassOptions.loadPaths).toBe("undefined")
22
+ })
23
+ })
@@ -0,0 +1,23 @@
1
+ const sass = require("../../../package/rules/sass")
2
+
3
+ jest.mock("../../../package/utils/helpers", () => {
4
+ const original = jest.requireActual("../../../package/utils/helpers")
5
+ const canProcess = (rule, fn) => {
6
+ return fn("This path was mocked")
7
+ }
8
+ return {
9
+ ...original,
10
+ canProcess
11
+ }
12
+ })
13
+
14
+ jest.mock("../../../package/utils/inliningCss", () => true)
15
+
16
+ describe("sass rule", () => {
17
+ test("contains loadPaths as the sassOptions key if sass-loader is v15 or earlier", () => {
18
+ expect(typeof sass.use[3].options.sassOptions.includePaths).toBe(
19
+ "undefined"
20
+ )
21
+ expect(typeof sass.use[3].options.sassOptions.loadPaths).toBe("object")
22
+ })
23
+ })
@@ -4,6 +4,15 @@ const { chdirTestApp } = require("../helpers")
4
4
  const rootPath = process.cwd()
5
5
  chdirTestApp()
6
6
 
7
+ jest.mock("../../package/utils/helpers", () => {
8
+ const original = jest.requireActual("../../package/utils/helpers")
9
+ const moduleExists = () => false
10
+ return {
11
+ ...original,
12
+ moduleExists
13
+ }
14
+ })
15
+
7
16
  describe("Custom environment", () => {
8
17
  afterAll(() => process.chdir(rootPath))
9
18
 
@@ -4,6 +4,15 @@ const { chdirTestApp } = require("../helpers")
4
4
  const rootPath = process.cwd()
5
5
  chdirTestApp()
6
6
 
7
+ jest.mock("../../package/utils/helpers", () => {
8
+ const original = jest.requireActual("../../package/utils/helpers")
9
+ const moduleExists = () => false
10
+ return {
11
+ ...original,
12
+ moduleExists
13
+ }
14
+ })
15
+
7
16
  describe("Test environment", () => {
8
17
  afterAll(() => process.chdir(rootPath))
9
18
 
data/test/resolver.js ADDED
@@ -0,0 +1,13 @@
1
+ const mapping = {
2
+ "css-loader": "this path was mocked",
3
+ "sass-loader/package.json": "../../__mocks__/sass-loader/package.json",
4
+ "nonexistent/package.json": "../../__mocks__/nonexistent/package.json"
5
+ }
6
+
7
+ function resolver(module, options) {
8
+ // If the path corresponds to a key in the mapping object, returns the fakely resolved path
9
+ // otherwise it calls the Jest's default resolver
10
+ return mapping[module] || options.defaultResolver(module, options)
11
+ }
12
+
13
+ module.exports = resolver
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: 8.0.1
4
+ version: 8.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-07-10 00:00:00.000000000 Z
13
+ date: 2024-08-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -155,6 +155,8 @@ files:
155
155
  - MIT-LICENSE
156
156
  - README.md
157
157
  - Rakefile
158
+ - __mocks__/nonexistent/package.json
159
+ - __mocks__/sass-loader/package.json
158
160
  - config/README.md
159
161
  - config/shakapacker.yml
160
162
  - docs/customizing_babel_config.md
@@ -261,6 +263,7 @@ files:
261
263
  - test/package/environments/base.test.js
262
264
  - test/package/environments/development.test.js
263
265
  - test/package/environments/production.test.js
266
+ - test/package/helpers.test.js
264
267
  - test/package/index.test.js
265
268
  - test/package/production.test.js
266
269
  - test/package/rules/babel.test.js
@@ -268,15 +271,18 @@ files:
268
271
  - test/package/rules/file.test.js
269
272
  - test/package/rules/index.test.js
270
273
  - test/package/rules/raw.test.js
274
+ - test/package/rules/sass.test.js
275
+ - test/package/rules/sass1.test.js
271
276
  - test/package/rules/swc.test.js
272
277
  - test/package/staging.test.js
273
278
  - test/package/test.test.js
279
+ - test/resolver.js
274
280
  - yarn.lock
275
281
  homepage: https://github.com/shakacode/shakapacker
276
282
  licenses:
277
283
  - MIT
278
284
  metadata:
279
- source_code_uri: https://github.com/shakacode/shakapacker/tree/v8.0.1
285
+ source_code_uri: https://github.com/shakacode/shakapacker/tree/v8.0.2
280
286
  post_install_message:
281
287
  rdoc_options: []
282
288
  require_paths:
@@ -305,6 +311,7 @@ test_files:
305
311
  - test/package/environments/base.test.js
306
312
  - test/package/environments/development.test.js
307
313
  - test/package/environments/production.test.js
314
+ - test/package/helpers.test.js
308
315
  - test/package/index.test.js
309
316
  - test/package/production.test.js
310
317
  - test/package/rules/babel.test.js
@@ -312,6 +319,9 @@ test_files:
312
319
  - test/package/rules/file.test.js
313
320
  - test/package/rules/index.test.js
314
321
  - test/package/rules/raw.test.js
322
+ - test/package/rules/sass.test.js
323
+ - test/package/rules/sass1.test.js
315
324
  - test/package/rules/swc.test.js
316
325
  - test/package/staging.test.js
317
326
  - test/package/test.test.js
327
+ - test/resolver.js