shakapacker 7.3.0.beta.1 → 8.0.0.rc.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.eslintignore +1 -1
- data/.eslintrc.js +29 -8
- data/.github/PULL_REQUEST_TEMPLATE.md +10 -3
- data/.github/workflows/dummy.yml +6 -1
- data/.github/workflows/generator.yml +14 -18
- data/.github/workflows/node.yml +56 -0
- data/.github/workflows/ruby.yml +29 -17
- data/.node-version +1 -1
- data/.rubocop.yml +1 -0
- data/CHANGELOG.md +56 -5
- data/README.md +101 -48
- data/Rakefile +1 -7
- data/docs/customizing_babel_config.md +2 -2
- data/docs/deployment.md +13 -6
- data/docs/react.md +7 -13
- data/docs/troubleshooting.md +4 -4
- data/docs/using_esbuild_loader.md +1 -1
- data/docs/using_swc_loader.md +1 -1
- data/docs/v6_upgrade.md +1 -1
- data/docs/v8_upgrade.md +148 -0
- data/gemfiles/Gemfile-rails.7.1.x +12 -0
- data/jest.config.js +4 -0
- data/lib/install/config/shakapacker.yml +2 -2
- data/lib/install/template.rb +36 -30
- data/lib/shakapacker/base_strategy.rb +2 -1
- data/lib/shakapacker/compiler.rb +6 -21
- data/lib/shakapacker/configuration.rb +2 -46
- data/lib/shakapacker/deprecation_helper.rb +0 -78
- data/lib/shakapacker/dev_server.rb +1 -16
- data/lib/shakapacker/dev_server_runner.rb +2 -21
- data/lib/shakapacker/env.rb +1 -1
- data/lib/shakapacker/helper.rb +3 -3
- data/lib/shakapacker/instance.rb +1 -3
- data/lib/shakapacker/manifest.rb +1 -1
- data/lib/shakapacker/railtie.rb +7 -0
- data/lib/shakapacker/runner.rb +4 -18
- data/lib/shakapacker/utils/manager.rb +58 -0
- data/lib/shakapacker/utils/misc.rb +0 -12
- data/lib/shakapacker/version.rb +1 -1
- data/lib/shakapacker/version_checker.rb +9 -30
- data/lib/shakapacker/webpack_runner.rb +2 -21
- data/lib/shakapacker.rb +0 -2
- data/lib/tasks/shakapacker/check_binstubs.rake +12 -26
- data/lib/tasks/shakapacker/check_manager.rake +3 -8
- data/lib/tasks/shakapacker/info.rake +6 -15
- data/package/babel/preset.js +15 -15
- data/package/config.js +15 -19
- data/package/dev_server.js +4 -4
- data/package/env.js +19 -17
- data/package/environments/base.js +41 -24
- data/package/environments/development.js +6 -6
- data/package/environments/production.js +16 -16
- data/package/environments/test.js +1 -1
- data/package/esbuild/index.js +6 -6
- data/package/index.d.ts +0 -2
- data/package/index.js +17 -46
- data/package/rules/babel.js +6 -8
- data/package/rules/coffee.js +2 -2
- data/package/rules/css.js +1 -1
- data/package/rules/erb.js +4 -4
- data/package/rules/esbuild.js +5 -7
- data/package/rules/file.js +14 -7
- data/package/rules/index.js +11 -11
- data/package/rules/jscommon.js +8 -5
- data/package/rules/less.js +10 -9
- data/package/rules/raw.js +1 -1
- data/package/rules/sass.js +4 -4
- data/package/rules/stylus.js +12 -7
- data/package/rules/swc.js +5 -7
- data/package/swc/index.js +10 -10
- data/package/utils/configPath.js +3 -18
- data/package/utils/defaultConfigPath.js +1 -1
- data/package/utils/{get_style_rule.js → getStyleRule.js} +6 -6
- data/package/utils/helpers.js +2 -43
- data/package/utils/inliningCss.js +4 -3
- data/package/utils/snakeToCamelCase.js +5 -0
- data/package/webpackDevServerConfig.js +28 -25
- data/package.json +12 -18
- data/prettier.config.js +4 -0
- data/shakapacker.gemspec +1 -1
- data/spec/dummy/app/javascript/packs/application.js +1 -1
- data/spec/dummy/config/application.rb +3 -0
- data/spec/dummy/config/initializers/react_on_rails.rb +2 -2
- data/spec/dummy/config/shakapacker.yml +3 -4
- data/spec/dummy/config/webpack/commonWebpackConfig.js +0 -1
- data/spec/dummy/config/webpack/webpack.config.js +1 -1
- data/spec/dummy/package.json +2 -1
- data/spec/dummy/yarn.lock +2 -3
- data/spec/fixtures/github_url_package-lock.v1.json +1 -1
- data/spec/fixtures/github_url_package-lock.v2.json +2 -2
- data/spec/fixtures/github_url_package.json +1 -1
- data/spec/fixtures/github_url_pnpm-lock.v7.yaml +1 -1
- data/spec/fixtures/github_url_pnpm-lock.v8.yaml +1 -1
- data/spec/fixtures/github_url_yarn.v1.lock +1 -1
- data/spec/fixtures/github_url_yarn.v2.lock +2 -2
- data/spec/generator_specs/e2e_template/template.rb +15 -28
- data/spec/generator_specs/generator_spec.rb +6 -136
- data/spec/mounted_app/test/dummy/config/webpacker.yml +0 -1
- data/spec/shakapacker/compiler_spec.rb +1 -3
- data/spec/shakapacker/configuration_spec.rb +4 -56
- data/spec/shakapacker/dev_server_runner_spec.rb +19 -102
- data/spec/shakapacker/dev_server_spec.rb +1 -16
- data/spec/shakapacker/engine_rake_tasks_spec.rb +1 -16
- data/spec/shakapacker/helper_spec.rb +3 -3
- data/spec/shakapacker/instance_spec.rb +1 -3
- data/spec/shakapacker/rake_tasks_spec.rb +2 -14
- data/spec/shakapacker/shakapacker_spec.rb +0 -1
- data/spec/shakapacker/test_app/config/shakapacker_css_extract_ignore_order_warnings.yml +0 -1
- data/spec/shakapacker/test_app/config/shakapacker_manifest_path.yml +0 -1
- data/spec/shakapacker/test_app/config/shakapacker_nested_entries.yml +0 -1
- data/spec/shakapacker/test_app/config/shakapacker_other_location.yml +0 -1
- data/spec/shakapacker/test_app/package.json +2 -1
- data/spec/shakapacker/utils_manager_spec.rb +125 -0
- data/spec/shakapacker/version_checker_spec.rb +5 -5
- data/spec/shakapacker/webpack_runner_spec.rb +19 -28
- data/spec/support/package_json_helpers.rb +7 -4
- data/test/helpers.js +67 -0
- data/test/package/config.test.js +50 -0
- data/test/package/dev_server.test.js +44 -0
- data/test/package/development.test.js +43 -0
- data/test/package/env.test.js +57 -0
- data/test/package/environments/base.test.js +105 -0
- data/test/package/environments/development.test.js +50 -0
- data/test/package/environments/production.test.js +106 -0
- data/test/package/index.test.js +45 -0
- data/test/package/production.test.js +32 -0
- data/test/package/rules/babel.test.js +58 -0
- data/test/package/rules/esbuild.test.js +59 -0
- data/test/package/rules/file.test.js +81 -0
- data/test/package/rules/index.test.js +7 -0
- data/test/package/rules/raw.test.js +12 -0
- data/test/package/rules/swc.test.js +59 -0
- data/test/package/staging.test.js +31 -0
- data/test/package/test.test.js +28 -0
- data/yarn.lock +1278 -421
- metadata +50 -100
- data/.github/workflows/jest.yml +0 -33
- data/.github/workflows/js-lint.yml +0 -33
- data/.github/workflows/rubocop.yml +0 -28
- data/.github/workflows/ruby-backward-compatibility.yml +0 -51
- data/lib/install/package.json +0 -15
- data/lib/tasks/shakapacker/check_yarn.rake +0 -34
- data/lib/tasks/shakapacker/yarn_install.rake +0 -24
- data/lib/tasks/webpacker/binstubs.rake +0 -9
- data/lib/tasks/webpacker/check_binstubs.rake +0 -9
- data/lib/tasks/webpacker/check_node.rake +0 -9
- data/lib/tasks/webpacker/check_yarn.rake +0 -9
- data/lib/tasks/webpacker/clean.rake +0 -9
- data/lib/tasks/webpacker/clobber.rake +0 -11
- data/lib/tasks/webpacker/compile.rake +0 -9
- data/lib/tasks/webpacker/info.rake +0 -9
- data/lib/tasks/webpacker/install.rake +0 -9
- data/lib/tasks/webpacker/verify_config.rake +0 -9
- data/lib/tasks/webpacker/verify_install.rake +0 -9
- data/lib/tasks/webpacker/yarn_install.rake +0 -9
- data/lib/tasks/webpacker.rake +0 -20
- data/lib/webpacker/dev_server_runner.rb +0 -9
- data/lib/webpacker/webpack_runner.rb +0 -9
- data/lib/webpacker.rb +0 -4
- data/package/__tests__/config-bc.js +0 -27
- data/package/__tests__/config.js +0 -46
- data/package/__tests__/dev_server-bc.js +0 -46
- data/package/__tests__/dev_server.js +0 -46
- data/package/__tests__/development-bc.js +0 -66
- data/package/__tests__/development.js +0 -66
- data/package/__tests__/env-bc.js +0 -59
- data/package/__tests__/env.js +0 -59
- data/package/__tests__/index-bc.js +0 -22
- data/package/__tests__/index.js +0 -46
- data/package/__tests__/production-bc.js +0 -51
- data/package/__tests__/production.js +0 -51
- data/package/__tests__/staging-bc.js +0 -53
- data/package/__tests__/staging.js +0 -53
- data/package/__tests__/test-bc.js +0 -43
- data/package/__tests__/test.js +0 -43
- data/package/environments/__tests__/base-bc.js +0 -107
- data/package/environments/__tests__/base.js +0 -107
- data/package/environments/__tests__/development.js +0 -53
- data/package/environments/__tests__/production.js +0 -92
- data/package/rules/__tests__/__utils__/webpack.js +0 -50
- data/package/rules/__tests__/babel.js +0 -63
- data/package/rules/__tests__/esbuild.js +0 -64
- data/package/rules/__tests__/file.js +0 -79
- data/package/rules/__tests__/index.js +0 -7
- data/package/rules/__tests__/raw.js +0 -18
- data/package/rules/__tests__/swc.js +0 -63
- data/package/utils/snakeToCamelCase +0 -7
- data/spec/backward_compatibility_specs/command_spec.rb +0 -116
- data/spec/backward_compatibility_specs/compiler_spec.rb +0 -59
- data/spec/backward_compatibility_specs/compiler_strategy_spec.rb +0 -24
- data/spec/backward_compatibility_specs/configuration_spec.rb +0 -294
- data/spec/backward_compatibility_specs/dev_server_runner_spec.rb +0 -206
- data/spec/backward_compatibility_specs/dev_server_spec.rb +0 -47
- data/spec/backward_compatibility_specs/digest_strategy_spec.rb +0 -38
- data/spec/backward_compatibility_specs/engine_rake_tasks_spec.rb +0 -67
- data/spec/backward_compatibility_specs/env_spec.rb +0 -23
- data/spec/backward_compatibility_specs/helper_spec.rb +0 -243
- data/spec/backward_compatibility_specs/instance_spec.rb +0 -31
- data/spec/backward_compatibility_specs/manifest_spec.rb +0 -100
- data/spec/backward_compatibility_specs/mtime_strategy_spec.rb +0 -55
- data/spec/backward_compatibility_specs/rake_tasks_spec.rb +0 -41
- data/spec/backward_compatibility_specs/spec_helper_initializer.rb +0 -24
- data/spec/backward_compatibility_specs/webpack_runner_spec.rb +0 -86
- data/spec/backward_compatibility_specs/webpacker_spec.rb +0 -41
- data/spec/backward_compatibility_specs/webpacker_test_app/.gitignore +0 -2
- data/spec/backward_compatibility_specs/webpacker_test_app/Rakefile +0 -3
- data/spec/backward_compatibility_specs/webpacker_test_app/app/packs/entrypoints/application.js +0 -10
- data/spec/backward_compatibility_specs/webpacker_test_app/app/packs/entrypoints/generated/something.js +0 -2
- data/spec/backward_compatibility_specs/webpacker_test_app/app/packs/entrypoints/multi_entry.css +0 -4
- data/spec/backward_compatibility_specs/webpacker_test_app/app/packs/entrypoints/multi_entry.js +0 -4
- data/spec/backward_compatibility_specs/webpacker_test_app/bin/webpacker +0 -13
- data/spec/backward_compatibility_specs/webpacker_test_app/bin/webpacker-dev-server +0 -13
- data/spec/backward_compatibility_specs/webpacker_test_app/config/application.rb +0 -11
- data/spec/backward_compatibility_specs/webpacker_test_app/config/environment.rb +0 -4
- data/spec/backward_compatibility_specs/webpacker_test_app/config/initializers/inspect_autoload_paths.rb +0 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpack/webpack.config.js +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker.yml +0 -83
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_css_extract_ignore_order_warnings.yml +0 -84
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_defaults_fallback.yml +0 -11
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_manifest_path.yml +0 -80
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_nested_entries.yml +0 -83
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_no_precompile.yml +0 -7
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_other_location.yml +0 -85
- data/spec/backward_compatibility_specs/webpacker_test_app/config/webpacker_public_root.yml +0 -18
- data/spec/backward_compatibility_specs/webpacker_test_app/config.ru +0 -5
- data/spec/backward_compatibility_specs/webpacker_test_app/package.json +0 -13
- data/spec/backward_compatibility_specs/webpacker_test_app/public/packs/manifest.json +0 -58
- data/spec/backward_compatibility_specs/webpacker_test_app/some.config.js +0 -0
- data/spec/backward_compatibility_specs/webpacker_test_app/tmp/shakapacker/last-compilation-digest-production +0 -1
- data/spec/backward_compatibility_specs/webpacker_test_app/yarn.lock +0 -11
@@ -1,27 +0,0 @@
|
|
1
|
-
/* global test expect, describe */
|
2
|
-
const { resolve } = require('path')
|
3
|
-
const { chdirWebpackerTestApp, resetEnv } = require('../utils/helpers')
|
4
|
-
|
5
|
-
const rootPath = process.cwd()
|
6
|
-
chdirWebpackerTestApp()
|
7
|
-
|
8
|
-
const config = require('../config')
|
9
|
-
|
10
|
-
describe('Backward Compatibility - Config', () => {
|
11
|
-
beforeEach(() => jest.resetModules() && resetEnv())
|
12
|
-
afterAll(() => process.chdir(rootPath))
|
13
|
-
|
14
|
-
test('x public path with asset host', () => {
|
15
|
-
process.env.RAILS_ENV = 'development'
|
16
|
-
process.env.WEBPACKER_ASSET_HOST = 'http://foo.com/'
|
17
|
-
const config = require('../config')
|
18
|
-
|
19
|
-
expect(config.publicPath).toEqual('http://foo.com/packs/')
|
20
|
-
})
|
21
|
-
|
22
|
-
test('x should allow overriding manifestPath', () => {
|
23
|
-
process.env.WEBPACKER_CONFIG = 'config/webpacker_manifest_path.yml'
|
24
|
-
const config = require('../config')
|
25
|
-
expect(config.manifestPath).toEqual(resolve('app/packs/manifest.json'))
|
26
|
-
})
|
27
|
-
})
|
data/package/__tests__/config.js
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
/* global test expect, describe */
|
2
|
-
|
3
|
-
const { chdirTestApp, resetEnv } = require('../utils/helpers')
|
4
|
-
const { resolve } = require('path')
|
5
|
-
|
6
|
-
const rootPath = process.cwd()
|
7
|
-
chdirTestApp()
|
8
|
-
|
9
|
-
const config = require('../config')
|
10
|
-
|
11
|
-
describe('Config', () => {
|
12
|
-
beforeEach(() => jest.resetModules() && resetEnv())
|
13
|
-
afterAll(() => process.chdir(rootPath))
|
14
|
-
|
15
|
-
test('public path', () => {
|
16
|
-
process.env.RAILS_ENV = 'development'
|
17
|
-
const config = require('../config')
|
18
|
-
expect(config.publicPath).toEqual('/packs/')
|
19
|
-
})
|
20
|
-
|
21
|
-
test('public path with asset host', () => {
|
22
|
-
process.env.RAILS_ENV = 'development'
|
23
|
-
process.env.SHAKAPACKER_ASSET_HOST = 'http://foo.com/'
|
24
|
-
const config = require('../config')
|
25
|
-
expect(config.publicPath).toEqual('http://foo.com/packs/')
|
26
|
-
})
|
27
|
-
|
28
|
-
test('should return additional paths as listed in app config, with resolved paths', () => {
|
29
|
-
expect(config.additional_paths).toEqual([
|
30
|
-
'app/assets',
|
31
|
-
'/etc/yarn',
|
32
|
-
'some.config.js',
|
33
|
-
'app/elm'
|
34
|
-
])
|
35
|
-
})
|
36
|
-
|
37
|
-
test('should default manifestPath to the public dir', () => {
|
38
|
-
expect(config.manifestPath).toEqual(resolve('public/packs/manifest.json'))
|
39
|
-
})
|
40
|
-
|
41
|
-
test('should allow overriding manifestPath', () => {
|
42
|
-
process.env.SHAKAPACKER_CONFIG = 'config/shakapacker_manifest_path.yml'
|
43
|
-
const config = require('../config')
|
44
|
-
expect(config.manifestPath).toEqual(resolve('app/javascript/manifest.json'))
|
45
|
-
})
|
46
|
-
})
|
@@ -1,46 +0,0 @@
|
|
1
|
-
/* global test expect, describe */
|
2
|
-
|
3
|
-
const { chdirWebpackerTestApp } = require('../utils/helpers')
|
4
|
-
|
5
|
-
const rootPath = process.cwd()
|
6
|
-
chdirWebpackerTestApp()
|
7
|
-
|
8
|
-
describe('Backward Compatibility - DevServer', () => {
|
9
|
-
beforeEach(() => jest.resetModules())
|
10
|
-
afterAll(() => process.chdir(rootPath))
|
11
|
-
|
12
|
-
test('with NODE_ENV and RAILS_ENV set to development', () => {
|
13
|
-
process.env.NODE_ENV = 'development'
|
14
|
-
process.env.RAILS_ENV = 'development'
|
15
|
-
process.env.WEBPACKER_DEV_SERVER_HOST = '0.0.0.0'
|
16
|
-
process.env.WEBPACKER_DEV_SERVER_PORT = 5000
|
17
|
-
process.env.WEBPACKER_DEV_SERVER_DISABLE_HOST_CHECK = false
|
18
|
-
|
19
|
-
const devServer = require('../dev_server')
|
20
|
-
expect(devServer).toBeDefined()
|
21
|
-
expect(devServer.host).toEqual('0.0.0.0')
|
22
|
-
expect(devServer.port).toEqual('5000')
|
23
|
-
expect(devServer.disable_host_check).toBe(false)
|
24
|
-
})
|
25
|
-
|
26
|
-
test('with custom env prefix', () => {
|
27
|
-
const config = require('../config')
|
28
|
-
config.dev_server.env_prefix = 'TEST_WEBPACKER_DEV_SERVER'
|
29
|
-
|
30
|
-
process.env.NODE_ENV = 'development'
|
31
|
-
process.env.RAILS_ENV = 'development'
|
32
|
-
process.env.TEST_WEBPACKER_DEV_SERVER_HOST = '0.0.0.0'
|
33
|
-
process.env.TEST_WEBPACKER_DEV_SERVER_PORT = 5000
|
34
|
-
|
35
|
-
const devServer = require('../dev_server')
|
36
|
-
expect(devServer).toBeDefined()
|
37
|
-
expect(devServer.host).toEqual('0.0.0.0')
|
38
|
-
expect(devServer.port).toEqual('5000')
|
39
|
-
})
|
40
|
-
|
41
|
-
test('with NODE_ENV and RAILS_ENV set to production', () => {
|
42
|
-
process.env.RAILS_ENV = 'production'
|
43
|
-
process.env.NODE_ENV = 'production'
|
44
|
-
expect(require('../dev_server')).toEqual({})
|
45
|
-
})
|
46
|
-
})
|
@@ -1,46 +0,0 @@
|
|
1
|
-
/* global test expect, describe */
|
2
|
-
|
3
|
-
const { chdirTestApp } = require('../utils/helpers')
|
4
|
-
|
5
|
-
const rootPath = process.cwd()
|
6
|
-
chdirTestApp()
|
7
|
-
|
8
|
-
describe('DevServer', () => {
|
9
|
-
beforeEach(() => jest.resetModules())
|
10
|
-
afterAll(() => process.chdir(rootPath))
|
11
|
-
|
12
|
-
test('with NODE_ENV and RAILS_ENV set to development', () => {
|
13
|
-
process.env.NODE_ENV = 'development'
|
14
|
-
process.env.RAILS_ENV = 'development'
|
15
|
-
process.env.SHAKAPACKER_DEV_SERVER_HOST = '0.0.0.0'
|
16
|
-
process.env.SHAKAPACKER_DEV_SERVER_PORT = 5000
|
17
|
-
process.env.SHAKAPACKER_DEV_SERVER_DISABLE_HOST_CHECK = false
|
18
|
-
|
19
|
-
const devServer = require('../dev_server')
|
20
|
-
expect(devServer).toBeDefined()
|
21
|
-
expect(devServer.host).toEqual('0.0.0.0')
|
22
|
-
expect(devServer.port).toEqual('5000')
|
23
|
-
expect(devServer.disable_host_check).toBe(false)
|
24
|
-
})
|
25
|
-
|
26
|
-
test('with custom env prefix', () => {
|
27
|
-
const config = require('../config')
|
28
|
-
config.dev_server.env_prefix = 'TEST_SHAKAPACKER_DEV_SERVER'
|
29
|
-
|
30
|
-
process.env.NODE_ENV = 'development'
|
31
|
-
process.env.RAILS_ENV = 'development'
|
32
|
-
process.env.TEST_SHAKAPACKER_DEV_SERVER_HOST = '0.0.0.0'
|
33
|
-
process.env.TEST_SHAKAPACKER_DEV_SERVER_PORT = 5000
|
34
|
-
|
35
|
-
const devServer = require('../dev_server')
|
36
|
-
expect(devServer).toBeDefined()
|
37
|
-
expect(devServer.host).toEqual('0.0.0.0')
|
38
|
-
expect(devServer.port).toEqual('5000')
|
39
|
-
})
|
40
|
-
|
41
|
-
test('with NODE_ENV and RAILS_ENV set to production', () => {
|
42
|
-
process.env.RAILS_ENV = 'production'
|
43
|
-
process.env.NODE_ENV = 'production'
|
44
|
-
expect(require('../dev_server')).toEqual({})
|
45
|
-
})
|
46
|
-
})
|
@@ -1,66 +0,0 @@
|
|
1
|
-
/* test expect, describe, afterAll, beforeEach */
|
2
|
-
|
3
|
-
const { resolve } = require('path')
|
4
|
-
const { chdirWebpackerTestApp, resetEnv } = require('../utils/helpers')
|
5
|
-
|
6
|
-
const rootPath = process.cwd()
|
7
|
-
chdirWebpackerTestApp()
|
8
|
-
|
9
|
-
describe('Backward Compatibility - Development environment', () => {
|
10
|
-
beforeEach(() => jest.resetModules() && resetEnv())
|
11
|
-
afterAll(() => process.chdir(rootPath))
|
12
|
-
|
13
|
-
describe('generateWebpackConfig', () => {
|
14
|
-
beforeEach(() => jest.resetModules())
|
15
|
-
|
16
|
-
test('should use development config and environment including devServer if WEBPACK_SERVE', () => {
|
17
|
-
process.env.RAILS_ENV = 'development'
|
18
|
-
process.env.NODE_ENV = 'development'
|
19
|
-
process.env.WEBPACK_SERVE = 'true'
|
20
|
-
const { generateWebpackConfig } = require('../index')
|
21
|
-
|
22
|
-
const webpackConfig = generateWebpackConfig()
|
23
|
-
|
24
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
25
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
26
|
-
})
|
27
|
-
|
28
|
-
test('should use development config and environment if WEBPACK_SERVE', () => {
|
29
|
-
process.env.RAILS_ENV = 'development'
|
30
|
-
process.env.NODE_ENV = 'development'
|
31
|
-
process.env.WEBPACK_SERVE = undefined
|
32
|
-
const { generateWebpackConfig } = require('../index')
|
33
|
-
|
34
|
-
const webpackConfig = generateWebpackConfig()
|
35
|
-
|
36
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
37
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
38
|
-
expect(webpackConfig.devServer).toEqual(undefined)
|
39
|
-
})
|
40
|
-
})
|
41
|
-
|
42
|
-
describe('globalMutableWebpackConfig', () => {
|
43
|
-
beforeEach(() => jest.resetModules())
|
44
|
-
|
45
|
-
test('should use development config and environment including devServer if WEBPACK_SERVE', () => {
|
46
|
-
process.env.RAILS_ENV = 'development'
|
47
|
-
process.env.NODE_ENV = 'development'
|
48
|
-
process.env.WEBPACK_SERVE = 'true'
|
49
|
-
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
50
|
-
|
51
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
52
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
53
|
-
})
|
54
|
-
|
55
|
-
test('should use development config and environment if WEBPACK_SERVE', () => {
|
56
|
-
process.env.RAILS_ENV = 'development'
|
57
|
-
process.env.NODE_ENV = 'development'
|
58
|
-
process.env.WEBPACK_SERVE = undefined
|
59
|
-
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
60
|
-
|
61
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
62
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
63
|
-
expect(webpackConfig.devServer).toEqual(undefined)
|
64
|
-
})
|
65
|
-
})
|
66
|
-
})
|
@@ -1,66 +0,0 @@
|
|
1
|
-
/* test expect, describe, afterAll, beforeEach */
|
2
|
-
|
3
|
-
const { resolve } = require('path')
|
4
|
-
const { chdirTestApp, resetEnv } = require('../utils/helpers')
|
5
|
-
|
6
|
-
const rootPath = process.cwd()
|
7
|
-
chdirTestApp()
|
8
|
-
|
9
|
-
describe('Development environment', () => {
|
10
|
-
beforeEach(() => jest.resetModules() && resetEnv())
|
11
|
-
afterAll(() => process.chdir(rootPath))
|
12
|
-
|
13
|
-
describe('generateWebpackConfig', () => {
|
14
|
-
beforeEach(() => jest.resetModules())
|
15
|
-
|
16
|
-
test('should use development config and environment including devServer if WEBPACK_SERVE', () => {
|
17
|
-
process.env.RAILS_ENV = 'development'
|
18
|
-
process.env.NODE_ENV = 'development'
|
19
|
-
process.env.WEBPACK_SERVE = 'true'
|
20
|
-
const { generateWebpackConfig } = require('../index')
|
21
|
-
|
22
|
-
const webpackConfig = generateWebpackConfig()
|
23
|
-
|
24
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
25
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
26
|
-
})
|
27
|
-
|
28
|
-
test('should use development config and environment if WEBPACK_SERVE', () => {
|
29
|
-
process.env.RAILS_ENV = 'development'
|
30
|
-
process.env.NODE_ENV = 'development'
|
31
|
-
process.env.WEBPACK_SERVE = undefined
|
32
|
-
const { generateWebpackConfig } = require('../index')
|
33
|
-
|
34
|
-
const webpackConfig = generateWebpackConfig()
|
35
|
-
|
36
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
37
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
38
|
-
expect(webpackConfig.devServer).toEqual(undefined)
|
39
|
-
})
|
40
|
-
})
|
41
|
-
|
42
|
-
describe('globalMutableWebpackConfig', () => {
|
43
|
-
beforeEach(() => jest.resetModules())
|
44
|
-
|
45
|
-
test('should use development config and environment including devServer if WEBPACK_SERVE', () => {
|
46
|
-
process.env.RAILS_ENV = 'development'
|
47
|
-
process.env.NODE_ENV = 'development'
|
48
|
-
process.env.WEBPACK_SERVE = 'true'
|
49
|
-
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
50
|
-
|
51
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
52
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
53
|
-
})
|
54
|
-
|
55
|
-
test('should use development config and environment if WEBPACK_SERVE', () => {
|
56
|
-
process.env.RAILS_ENV = 'development'
|
57
|
-
process.env.NODE_ENV = 'development'
|
58
|
-
process.env.WEBPACK_SERVE = undefined
|
59
|
-
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
60
|
-
|
61
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
62
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
63
|
-
expect(webpackConfig.devServer).toEqual(undefined)
|
64
|
-
})
|
65
|
-
})
|
66
|
-
})
|
data/package/__tests__/env-bc.js
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
/* global test expect, describe */
|
2
|
-
|
3
|
-
const { chdirWebpackerTestApp, resetEnv } = require('../utils/helpers')
|
4
|
-
|
5
|
-
const rootPath = process.cwd()
|
6
|
-
chdirWebpackerTestApp()
|
7
|
-
|
8
|
-
describe('Backward Compatibility - Env', () => {
|
9
|
-
beforeEach(() => jest.resetModules() && resetEnv())
|
10
|
-
afterAll(() => process.chdir(rootPath))
|
11
|
-
|
12
|
-
test('with NODE_ENV and RAILS_ENV set to development', () => {
|
13
|
-
process.env.RAILS_ENV = 'development'
|
14
|
-
process.env.NODE_ENV = 'development'
|
15
|
-
expect(require('../env')).toEqual({
|
16
|
-
railsEnv: 'development',
|
17
|
-
nodeEnv: 'development',
|
18
|
-
isProduction: false,
|
19
|
-
isDevelopment: true,
|
20
|
-
runningWebpackDevServer: false
|
21
|
-
})
|
22
|
-
})
|
23
|
-
|
24
|
-
test('with undefined NODE_ENV and RAILS_ENV set to development', () => {
|
25
|
-
process.env.RAILS_ENV = 'development'
|
26
|
-
delete process.env.NODE_ENV
|
27
|
-
expect(require('../env')).toEqual({
|
28
|
-
railsEnv: 'development',
|
29
|
-
nodeEnv: 'production',
|
30
|
-
isProduction: true,
|
31
|
-
isDevelopment: false,
|
32
|
-
runningWebpackDevServer: false
|
33
|
-
})
|
34
|
-
})
|
35
|
-
|
36
|
-
test('with undefined NODE_ENV and RAILS_ENV', () => {
|
37
|
-
delete process.env.NODE_ENV
|
38
|
-
delete process.env.RAILS_ENV
|
39
|
-
expect(require('../env')).toEqual({
|
40
|
-
railsEnv: 'production',
|
41
|
-
nodeEnv: 'production',
|
42
|
-
isProduction: true,
|
43
|
-
isDevelopment: false,
|
44
|
-
runningWebpackDevServer: false
|
45
|
-
})
|
46
|
-
})
|
47
|
-
|
48
|
-
test('with a non-standard environment', () => {
|
49
|
-
process.env.RAILS_ENV = 'staging'
|
50
|
-
process.env.NODE_ENV = 'staging'
|
51
|
-
expect(require('../env')).toEqual({
|
52
|
-
railsEnv: 'staging',
|
53
|
-
nodeEnv: 'production',
|
54
|
-
isProduction: true,
|
55
|
-
isDevelopment: false,
|
56
|
-
runningWebpackDevServer: false
|
57
|
-
})
|
58
|
-
})
|
59
|
-
})
|
data/package/__tests__/env.js
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
/* global test expect, describe */
|
2
|
-
|
3
|
-
const { chdirTestApp } = require('../utils/helpers')
|
4
|
-
|
5
|
-
const rootPath = process.cwd()
|
6
|
-
chdirTestApp()
|
7
|
-
|
8
|
-
describe('Env', () => {
|
9
|
-
beforeEach(() => jest.resetModules())
|
10
|
-
afterAll(() => process.chdir(rootPath))
|
11
|
-
|
12
|
-
test('with NODE_ENV and RAILS_ENV set to development', () => {
|
13
|
-
process.env.RAILS_ENV = 'development'
|
14
|
-
process.env.NODE_ENV = 'development'
|
15
|
-
expect(require('../env')).toEqual({
|
16
|
-
railsEnv: 'development',
|
17
|
-
nodeEnv: 'development',
|
18
|
-
isProduction: false,
|
19
|
-
isDevelopment: true,
|
20
|
-
runningWebpackDevServer: false
|
21
|
-
})
|
22
|
-
})
|
23
|
-
|
24
|
-
test('with undefined NODE_ENV and RAILS_ENV set to development', () => {
|
25
|
-
process.env.RAILS_ENV = 'development'
|
26
|
-
delete process.env.NODE_ENV
|
27
|
-
expect(require('../env')).toEqual({
|
28
|
-
railsEnv: 'development',
|
29
|
-
nodeEnv: 'production',
|
30
|
-
isProduction: true,
|
31
|
-
isDevelopment: false,
|
32
|
-
runningWebpackDevServer: false
|
33
|
-
})
|
34
|
-
})
|
35
|
-
|
36
|
-
test('with undefined NODE_ENV and RAILS_ENV', () => {
|
37
|
-
delete process.env.NODE_ENV
|
38
|
-
delete process.env.RAILS_ENV
|
39
|
-
expect(require('../env')).toEqual({
|
40
|
-
railsEnv: 'production',
|
41
|
-
nodeEnv: 'production',
|
42
|
-
isProduction: true,
|
43
|
-
isDevelopment: false,
|
44
|
-
runningWebpackDevServer: false
|
45
|
-
})
|
46
|
-
})
|
47
|
-
|
48
|
-
test('with a non-standard environment', () => {
|
49
|
-
process.env.RAILS_ENV = 'staging'
|
50
|
-
process.env.NODE_ENV = 'staging'
|
51
|
-
expect(require('../env')).toEqual({
|
52
|
-
railsEnv: 'staging',
|
53
|
-
nodeEnv: 'production',
|
54
|
-
isProduction: true,
|
55
|
-
isDevelopment: false,
|
56
|
-
runningWebpackDevServer: false
|
57
|
-
})
|
58
|
-
})
|
59
|
-
})
|
@@ -1,22 +0,0 @@
|
|
1
|
-
const index = require('../index')
|
2
|
-
|
3
|
-
describe('index', () => {
|
4
|
-
describe('webpackConfig', () => {
|
5
|
-
test('is a global object', () => {
|
6
|
-
const { webpackConfig, globalMutableWebpackConfig } = require('../index')
|
7
|
-
|
8
|
-
expect(webpackConfig).toBe(globalMutableWebpackConfig)
|
9
|
-
})
|
10
|
-
|
11
|
-
test('Shows warning with deprecation message', () => {
|
12
|
-
const consoleSpy = jest.spyOn(console, "warn");
|
13
|
-
|
14
|
-
const { webpackConfig } = require('../index')
|
15
|
-
|
16
|
-
expect(consoleSpy).toHaveBeenCalledWith(
|
17
|
-
expect.stringMatching(/The 'webpackConfig' is deprecated/)
|
18
|
-
)
|
19
|
-
consoleSpy.mockRestore();
|
20
|
-
})
|
21
|
-
})
|
22
|
-
})
|
data/package/__tests__/index.js
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
const index = require('../index')
|
2
|
-
const { generateWebpackConfig } = require("../index");
|
3
|
-
|
4
|
-
describe('index', () => {
|
5
|
-
test('exports webpack-merge v5 functions', () => {
|
6
|
-
expect(index.merge).toBeInstanceOf(Function)
|
7
|
-
expect(index.mergeWithRules).toBeInstanceOf(Function)
|
8
|
-
expect(index.mergeWithCustomize).toBeInstanceOf(Function)
|
9
|
-
})
|
10
|
-
|
11
|
-
test('webpackConfig returns an immutable object', () => {
|
12
|
-
const { generateWebpackConfig } = require('../index')
|
13
|
-
|
14
|
-
const webpackConfig1 = generateWebpackConfig()
|
15
|
-
const webpackConfig2 = generateWebpackConfig()
|
16
|
-
|
17
|
-
webpackConfig1.newKey = 'new value'
|
18
|
-
webpackConfig1.output.path = 'new path'
|
19
|
-
|
20
|
-
expect(webpackConfig2).not.toHaveProperty('newKey')
|
21
|
-
expect(webpackConfig2.output.path).not.toEqual('new value')
|
22
|
-
})
|
23
|
-
|
24
|
-
test('webpackConfig merges extra config', () => {
|
25
|
-
const { generateWebpackConfig } = require('../index')
|
26
|
-
|
27
|
-
const webpackConfig = generateWebpackConfig({
|
28
|
-
newKey: 'new value',
|
29
|
-
output: {
|
30
|
-
path: 'new path'
|
31
|
-
}
|
32
|
-
})
|
33
|
-
|
34
|
-
expect(webpackConfig).toHaveProperty('newKey', 'new value')
|
35
|
-
expect(webpackConfig).toHaveProperty('output.path', 'new path')
|
36
|
-
expect(webpackConfig).toHaveProperty('output.publicPath', '/packs/')
|
37
|
-
})
|
38
|
-
|
39
|
-
test('webpackConfig errors if multiple configs are provided', () => {
|
40
|
-
const { generateWebpackConfig } = require('../index')
|
41
|
-
|
42
|
-
expect(() => generateWebpackConfig({}, {})).toThrow(
|
43
|
-
'use webpack-merge to merge configs before passing them to Shakapacker'
|
44
|
-
)
|
45
|
-
})
|
46
|
-
})
|
@@ -1,51 +0,0 @@
|
|
1
|
-
/* test expect, describe, afterAll, beforeEach */
|
2
|
-
|
3
|
-
const { resolve } = require('path')
|
4
|
-
const { chdirWebpackerTestApp } = require('../utils/helpers')
|
5
|
-
|
6
|
-
const rootPath = process.cwd()
|
7
|
-
chdirWebpackerTestApp()
|
8
|
-
|
9
|
-
describe('Backward Compatibility - Production environment', () => {
|
10
|
-
afterAll(() => process.chdir(rootPath))
|
11
|
-
|
12
|
-
describe('generateWebpackConfig', () => {
|
13
|
-
beforeEach(() => jest.resetModules())
|
14
|
-
|
15
|
-
test('should use production config and environment', () => {
|
16
|
-
process.env.RAILS_ENV = 'production'
|
17
|
-
process.env.NODE_ENV = 'production'
|
18
|
-
|
19
|
-
const { generateWebpackConfig } = require('../index')
|
20
|
-
|
21
|
-
const webpackConfig = generateWebpackConfig()
|
22
|
-
|
23
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
24
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
25
|
-
|
26
|
-
expect(webpackConfig).toMatchObject({
|
27
|
-
devtool: 'source-map',
|
28
|
-
stats: 'normal'
|
29
|
-
})
|
30
|
-
})
|
31
|
-
})
|
32
|
-
|
33
|
-
describe('globalMutableWebpackConfig', () => {
|
34
|
-
beforeEach(() => jest.resetModules())
|
35
|
-
|
36
|
-
test('should use production config and environment', () => {
|
37
|
-
process.env.RAILS_ENV = 'production'
|
38
|
-
process.env.NODE_ENV = 'production'
|
39
|
-
|
40
|
-
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
41
|
-
|
42
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
43
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
44
|
-
|
45
|
-
expect(webpackConfig).toMatchObject({
|
46
|
-
devtool: 'source-map',
|
47
|
-
stats: 'normal'
|
48
|
-
})
|
49
|
-
})
|
50
|
-
})
|
51
|
-
})
|
@@ -1,51 +0,0 @@
|
|
1
|
-
/* test expect, describe, afterAll, beforeEach */
|
2
|
-
|
3
|
-
const { resolve } = require('path')
|
4
|
-
const { chdirTestApp, chdirCwd } = require('../utils/helpers')
|
5
|
-
|
6
|
-
const rootPath = process.cwd()
|
7
|
-
chdirTestApp()
|
8
|
-
|
9
|
-
describe('Production environment', () => {
|
10
|
-
afterAll(() => process.chdir(rootPath))
|
11
|
-
|
12
|
-
describe('generateWebpackConfig', () => {
|
13
|
-
beforeEach(() => jest.resetModules())
|
14
|
-
|
15
|
-
test('should use production config and environment', () => {
|
16
|
-
process.env.RAILS_ENV = 'production'
|
17
|
-
process.env.NODE_ENV = 'production'
|
18
|
-
|
19
|
-
const { generateWebpackConfig } = require('../index')
|
20
|
-
|
21
|
-
const webpackConfig = generateWebpackConfig()
|
22
|
-
|
23
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
24
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
25
|
-
|
26
|
-
expect(webpackConfig).toMatchObject({
|
27
|
-
devtool: 'source-map',
|
28
|
-
stats: 'normal'
|
29
|
-
})
|
30
|
-
})
|
31
|
-
})
|
32
|
-
|
33
|
-
describe('globalMutableWebpackConfig', () => {
|
34
|
-
beforeEach(() => jest.resetModules())
|
35
|
-
|
36
|
-
test('should use production config and environment', () => {
|
37
|
-
process.env.RAILS_ENV = 'production'
|
38
|
-
process.env.NODE_ENV = 'production'
|
39
|
-
|
40
|
-
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
41
|
-
|
42
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs'))
|
43
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs/')
|
44
|
-
|
45
|
-
expect(webpackConfig).toMatchObject({
|
46
|
-
devtool: 'source-map',
|
47
|
-
stats: 'normal'
|
48
|
-
})
|
49
|
-
})
|
50
|
-
})
|
51
|
-
})
|
@@ -1,53 +0,0 @@
|
|
1
|
-
/* test expect, describe, afterAll, beforeEach */
|
2
|
-
|
3
|
-
const { resolve } = require('path')
|
4
|
-
const { chdirWebpackerTestApp } = require('../utils/helpers')
|
5
|
-
|
6
|
-
const rootPath = process.cwd()
|
7
|
-
chdirWebpackerTestApp()
|
8
|
-
|
9
|
-
describe('Backward Compatibility - Custom environment', () => {
|
10
|
-
afterAll(() => process.chdir(rootPath))
|
11
|
-
|
12
|
-
describe('generateWebpackConfig', () => {
|
13
|
-
beforeEach(() => jest.resetModules())
|
14
|
-
|
15
|
-
test('should use staging config and default production environment', () => {
|
16
|
-
process.env.RAILS_ENV = 'staging'
|
17
|
-
delete process.env.NODE_ENV
|
18
|
-
|
19
|
-
const { generateWebpackConfig } = require('../index')
|
20
|
-
|
21
|
-
const webpackConfig = generateWebpackConfig()
|
22
|
-
|
23
|
-
expect(webpackConfig.output.path).toEqual(
|
24
|
-
resolve('public', 'packs-staging')
|
25
|
-
)
|
26
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs-staging/')
|
27
|
-
expect(webpackConfig).toMatchObject({
|
28
|
-
devtool: 'source-map',
|
29
|
-
stats: 'normal'
|
30
|
-
})
|
31
|
-
})
|
32
|
-
})
|
33
|
-
|
34
|
-
describe('globalMutableWebpackConfig', () => {
|
35
|
-
beforeEach(() => jest.resetModules())
|
36
|
-
|
37
|
-
test('should use staging config and default production environment', () => {
|
38
|
-
process.env.RAILS_ENV = 'staging'
|
39
|
-
delete process.env.NODE_ENV
|
40
|
-
|
41
|
-
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
42
|
-
|
43
|
-
expect(webpackConfig.output.path).toEqual(
|
44
|
-
resolve('public', 'packs-staging')
|
45
|
-
)
|
46
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs-staging/')
|
47
|
-
expect(webpackConfig).toMatchObject({
|
48
|
-
devtool: 'source-map',
|
49
|
-
stats: 'normal'
|
50
|
-
})
|
51
|
-
})
|
52
|
-
})
|
53
|
-
})
|