shakapacker 7.3.0.beta.1 → 8.0.0.rc.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 +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,53 +0,0 @@
|
|
|
1
|
-
/* test expect, describe, afterAll, beforeEach */
|
|
2
|
-
|
|
3
|
-
const { resolve } = require('path')
|
|
4
|
-
const { chdirTestApp } = require('../utils/helpers')
|
|
5
|
-
|
|
6
|
-
const rootPath = process.cwd()
|
|
7
|
-
chdirTestApp()
|
|
8
|
-
|
|
9
|
-
describe('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
|
-
})
|
|
@@ -1,43 +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 - Test environment', () => {
|
|
10
|
-
afterAll(() => process.chdir(rootPath))
|
|
11
|
-
|
|
12
|
-
describe('toWebpackConfig', () => {
|
|
13
|
-
beforeEach(() => jest.resetModules())
|
|
14
|
-
|
|
15
|
-
test('should use test config and production environment', () => {
|
|
16
|
-
process.env.RAILS_ENV = 'test'
|
|
17
|
-
process.env.NODE_ENV = 'test'
|
|
18
|
-
|
|
19
|
-
const { generateWebpackConfig } = require('../index')
|
|
20
|
-
|
|
21
|
-
const webpackConfig = generateWebpackConfig()
|
|
22
|
-
|
|
23
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs-test'))
|
|
24
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs-test/')
|
|
25
|
-
expect(webpackConfig.devServer).toEqual(undefined)
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
describe('globalMutableWebpackConfig', () => {
|
|
30
|
-
beforeEach(() => jest.resetModules())
|
|
31
|
-
|
|
32
|
-
test('should use test config and production environment', () => {
|
|
33
|
-
process.env.RAILS_ENV = 'test'
|
|
34
|
-
process.env.NODE_ENV = 'test'
|
|
35
|
-
|
|
36
|
-
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
|
37
|
-
|
|
38
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs-test'))
|
|
39
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs-test/')
|
|
40
|
-
expect(webpackConfig.devServer).toEqual(undefined)
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
})
|
data/package/__tests__/test.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/* test expect, describe, afterAll, beforeEach */
|
|
2
|
-
|
|
3
|
-
const { resolve } = require('path')
|
|
4
|
-
const { chdirTestApp } = require('../utils/helpers')
|
|
5
|
-
|
|
6
|
-
const rootPath = process.cwd()
|
|
7
|
-
chdirTestApp()
|
|
8
|
-
|
|
9
|
-
describe('Test environment', () => {
|
|
10
|
-
afterAll(() => process.chdir(rootPath))
|
|
11
|
-
|
|
12
|
-
describe('generateWebpackConfig', () => {
|
|
13
|
-
beforeEach(() => jest.resetModules())
|
|
14
|
-
|
|
15
|
-
test('should use test config and production environment', () => {
|
|
16
|
-
process.env.RAILS_ENV = 'test'
|
|
17
|
-
process.env.NODE_ENV = 'test'
|
|
18
|
-
|
|
19
|
-
const { generateWebpackConfig } = require('../index')
|
|
20
|
-
|
|
21
|
-
const webpackConfig = generateWebpackConfig()
|
|
22
|
-
|
|
23
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs-test'))
|
|
24
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs-test/')
|
|
25
|
-
expect(webpackConfig.devServer).toEqual(undefined)
|
|
26
|
-
})
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
describe('globalMutableWebpackConfig', () => {
|
|
30
|
-
beforeEach(() => jest.resetModules())
|
|
31
|
-
|
|
32
|
-
test('should use test config and production environment', () => {
|
|
33
|
-
process.env.RAILS_ENV = 'test'
|
|
34
|
-
process.env.NODE_ENV = 'test'
|
|
35
|
-
|
|
36
|
-
const { globalMutableWebpackConfig: webpackConfig } = require('../index')
|
|
37
|
-
|
|
38
|
-
expect(webpackConfig.output.path).toEqual(resolve('public', 'packs-test'))
|
|
39
|
-
expect(webpackConfig.output.publicPath).toEqual('/packs-test/')
|
|
40
|
-
expect(webpackConfig.devServer).toEqual(undefined)
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
})
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/* global test expect, describe, afterAll, beforeEach */
|
|
2
|
-
|
|
3
|
-
// environment.js expects to find config/webpacker.yml and resolved modules from
|
|
4
|
-
// the root of a Rails project
|
|
5
|
-
|
|
6
|
-
const { resetEnv, chdirWebpackerTestApp } = require('../../utils/helpers')
|
|
7
|
-
|
|
8
|
-
const rootPath = process.cwd()
|
|
9
|
-
chdirWebpackerTestApp()
|
|
10
|
-
|
|
11
|
-
const { resolve } = require('path')
|
|
12
|
-
|
|
13
|
-
const baseConfig = require('../base')
|
|
14
|
-
const config = require("../../config");
|
|
15
|
-
|
|
16
|
-
describe('Base config', () => {
|
|
17
|
-
beforeEach(() => jest.resetModules() && resetEnv())
|
|
18
|
-
afterAll(() => process.chdir(rootPath))
|
|
19
|
-
|
|
20
|
-
describe('config', () => {
|
|
21
|
-
test('should return entry', () => {
|
|
22
|
-
expect(baseConfig.entry.application).toEqual(
|
|
23
|
-
resolve('app', 'packs', 'entrypoints', 'application.js')
|
|
24
|
-
)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test('should return false for css_extract_ignore_order_warnings when using default config', () => {
|
|
28
|
-
expect(config.css_extract_ignore_order_warnings).toEqual(false)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('should return true for css_extract_ignore_order_warnings when configured', () => {
|
|
32
|
-
process.env.WEBPACKER_CONFIG = 'config/webpacker_css_extract_ignore_order_warnings.yml'
|
|
33
|
-
const config = require("../../config");
|
|
34
|
-
|
|
35
|
-
expect(config.css_extract_ignore_order_warnings).toEqual(true)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test('should return only 2 entry points with config.nested_entries == false', () => {
|
|
39
|
-
expect(config.nested_entries).toEqual(false)
|
|
40
|
-
|
|
41
|
-
expect(baseConfig.entry.multi_entry.sort()).toEqual([
|
|
42
|
-
resolve('app', 'packs', 'entrypoints', 'multi_entry.css'),
|
|
43
|
-
resolve('app', 'packs', 'entrypoints', 'multi_entry.js')
|
|
44
|
-
])
|
|
45
|
-
expect(baseConfig.entry['generated/something']).toEqual(undefined)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
test('should returns top level and nested entry points with config.nested_entries == true', () => {
|
|
49
|
-
process.env.WEBPACKER_CONFIG = 'config/webpacker_nested_entries.yml'
|
|
50
|
-
const config = require("../../config");
|
|
51
|
-
const baseConfig = require('../base')
|
|
52
|
-
|
|
53
|
-
expect(config.nested_entries).toEqual(true)
|
|
54
|
-
|
|
55
|
-
expect(baseConfig.entry.application).toEqual(
|
|
56
|
-
resolve('app', 'packs', 'entrypoints', 'application.js')
|
|
57
|
-
)
|
|
58
|
-
expect(baseConfig.entry.multi_entry.sort()).toEqual([
|
|
59
|
-
resolve('app', 'packs', 'entrypoints', 'multi_entry.css'),
|
|
60
|
-
resolve('app', 'packs', 'entrypoints', 'multi_entry.js')
|
|
61
|
-
])
|
|
62
|
-
expect(baseConfig.entry['generated/something']).toEqual(
|
|
63
|
-
resolve('app', 'packs', 'entrypoints', 'generated', 'something.js')
|
|
64
|
-
)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test('should return output', () => {
|
|
68
|
-
expect(baseConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
|
69
|
-
expect(baseConfig.output.chunkFilename).toEqual(
|
|
70
|
-
'js/[name]-[contenthash].chunk.js'
|
|
71
|
-
)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
test('should return default loader rules for each file in config/loaders', () => {
|
|
75
|
-
const rules = require('../../rules')
|
|
76
|
-
|
|
77
|
-
const defaultRules = Object.keys(rules)
|
|
78
|
-
const configRules = baseConfig.module.rules
|
|
79
|
-
|
|
80
|
-
expect(defaultRules.length).toEqual(3)
|
|
81
|
-
expect(configRules.length).toEqual(3)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
test('should return default plugins', () => {
|
|
85
|
-
expect(baseConfig.plugins.length).toEqual(2)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test('should return default resolveLoader', () => {
|
|
89
|
-
expect(baseConfig.resolveLoader.modules).toEqual(['node_modules'])
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
test('should return default resolve.modules with additions', () => {
|
|
93
|
-
expect(baseConfig.resolve.modules).toEqual([
|
|
94
|
-
resolve('app', 'packs'),
|
|
95
|
-
resolve('app/assets'),
|
|
96
|
-
resolve('/etc/yarn'),
|
|
97
|
-
resolve('some.config.js'),
|
|
98
|
-
resolve('app/elm'),
|
|
99
|
-
'node_modules'
|
|
100
|
-
])
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
test('returns plugins property as Array', () => {
|
|
104
|
-
expect(baseConfig.plugins).toBeInstanceOf(Array)
|
|
105
|
-
})
|
|
106
|
-
})
|
|
107
|
-
})
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/* global test expect, describe, afterAll, beforeEach */
|
|
2
|
-
|
|
3
|
-
// environment.js expects to find config/shakapacker.yml and resolved modules from
|
|
4
|
-
// the root of a Rails project
|
|
5
|
-
|
|
6
|
-
const { chdirTestApp, chdirCwd, resetEnv } = require('../../utils/helpers')
|
|
7
|
-
|
|
8
|
-
const rootPath = process.cwd()
|
|
9
|
-
chdirTestApp()
|
|
10
|
-
|
|
11
|
-
const { resolve } = require('path')
|
|
12
|
-
|
|
13
|
-
const baseConfig = require('../base')
|
|
14
|
-
const config = require("../../config");
|
|
15
|
-
|
|
16
|
-
describe('Base config', () => {
|
|
17
|
-
beforeEach(() => jest.resetModules() && resetEnv())
|
|
18
|
-
afterAll(() => process.chdir(rootPath))
|
|
19
|
-
|
|
20
|
-
describe('config', () => {
|
|
21
|
-
test('should return entry', () => {
|
|
22
|
-
expect(baseConfig.entry.application).toEqual(
|
|
23
|
-
resolve('app', 'javascript', 'entrypoints', 'application.js')
|
|
24
|
-
)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test('should return false for css_extract_ignore_order_warnings when using default config', () => {
|
|
28
|
-
expect(config.css_extract_ignore_order_warnings).toEqual(false)
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
test('should return true for css_extract_ignore_order_warnings when configured', () => {
|
|
32
|
-
process.env.SHAKAPACKER_CONFIG = 'config/shakapacker_css_extract_ignore_order_warnings.yml'
|
|
33
|
-
const config = require("../../config");
|
|
34
|
-
|
|
35
|
-
expect(config.css_extract_ignore_order_warnings).toEqual(true)
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test('should return only 2 entry points with config.nested_entries == false', () => {
|
|
39
|
-
expect(config.nested_entries).toEqual(false)
|
|
40
|
-
|
|
41
|
-
expect(baseConfig.entry.multi_entry.sort()).toEqual([
|
|
42
|
-
resolve('app', 'javascript', 'entrypoints', 'multi_entry.css'),
|
|
43
|
-
resolve('app', 'javascript', 'entrypoints', 'multi_entry.js')
|
|
44
|
-
])
|
|
45
|
-
expect(baseConfig.entry['generated/something']).toEqual(undefined)
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
test('should returns top level and nested entry points with config.nested_entries == true', () => {
|
|
49
|
-
process.env.SHAKAPACKER_CONFIG = 'config/shakapacker_nested_entries.yml'
|
|
50
|
-
const config = require("../../config");
|
|
51
|
-
const baseConfig = require('../base')
|
|
52
|
-
|
|
53
|
-
expect(config.nested_entries).toEqual(true)
|
|
54
|
-
|
|
55
|
-
expect(baseConfig.entry.application).toEqual(
|
|
56
|
-
resolve('app', 'javascript', 'entrypoints', 'application.js')
|
|
57
|
-
)
|
|
58
|
-
expect(baseConfig.entry.multi_entry.sort()).toEqual([
|
|
59
|
-
resolve('app', 'javascript', 'entrypoints', 'multi_entry.css'),
|
|
60
|
-
resolve('app', 'javascript', 'entrypoints', 'multi_entry.js')
|
|
61
|
-
])
|
|
62
|
-
expect(baseConfig.entry['generated/something']).toEqual(
|
|
63
|
-
resolve('app', 'javascript', 'entrypoints', 'generated', 'something.js')
|
|
64
|
-
)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test('should return output', () => {
|
|
68
|
-
expect(baseConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
|
69
|
-
expect(baseConfig.output.chunkFilename).toEqual(
|
|
70
|
-
'js/[name]-[contenthash].chunk.js'
|
|
71
|
-
)
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
test('should return default loader rules for each file in config/loaders', () => {
|
|
75
|
-
const rules = require('../../rules')
|
|
76
|
-
|
|
77
|
-
const defaultRules = Object.keys(rules)
|
|
78
|
-
const configRules = baseConfig.module.rules
|
|
79
|
-
|
|
80
|
-
expect(defaultRules.length).toEqual(3)
|
|
81
|
-
expect(configRules.length).toEqual(3)
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
test('should return default plugins', () => {
|
|
85
|
-
expect(baseConfig.plugins.length).toEqual(2)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test('should return default resolveLoader', () => {
|
|
89
|
-
expect(baseConfig.resolveLoader.modules).toEqual(['node_modules'])
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
test('should return default resolve.modules with additions', () => {
|
|
93
|
-
expect(baseConfig.resolve.modules).toEqual([
|
|
94
|
-
resolve('app', 'javascript'),
|
|
95
|
-
resolve('app/assets'),
|
|
96
|
-
resolve('/etc/yarn'),
|
|
97
|
-
resolve('some.config.js'),
|
|
98
|
-
resolve('app/elm'),
|
|
99
|
-
'node_modules'
|
|
100
|
-
])
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
test('returns plugins property as Array', () => {
|
|
104
|
-
expect(baseConfig.plugins).toBeInstanceOf(Array)
|
|
105
|
-
})
|
|
106
|
-
})
|
|
107
|
-
})
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/* global test expect, describe, afterAll, beforeEach */
|
|
2
|
-
|
|
3
|
-
const { chdirTestApp, resetEnv } = require('../../utils/helpers')
|
|
4
|
-
const rootPath = process.cwd()
|
|
5
|
-
chdirTestApp()
|
|
6
|
-
|
|
7
|
-
describe('Development specific config', () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
jest.resetModules()
|
|
10
|
-
resetEnv()
|
|
11
|
-
process.env['NODE_ENV'] = 'development'
|
|
12
|
-
})
|
|
13
|
-
afterAll(() => process.chdir(rootPath))
|
|
14
|
-
|
|
15
|
-
describe('with config.useContentHash = true', () => {
|
|
16
|
-
test('sets filename to use contentHash', () => {
|
|
17
|
-
const config = require("../../config");
|
|
18
|
-
config.useContentHash = true
|
|
19
|
-
const environmentConfig = require('../development')
|
|
20
|
-
|
|
21
|
-
expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
|
22
|
-
expect(environmentConfig.output.chunkFilename).toEqual(
|
|
23
|
-
'js/[name]-[contenthash].chunk.js'
|
|
24
|
-
)
|
|
25
|
-
})
|
|
26
|
-
})
|
|
27
|
-
|
|
28
|
-
describe('with config.useContentHash = false', () => {
|
|
29
|
-
test('sets filename without using contentHash', () => {
|
|
30
|
-
const config = require("../../config");
|
|
31
|
-
config.useContentHash = false
|
|
32
|
-
const environmentConfig = require('../development')
|
|
33
|
-
|
|
34
|
-
expect(environmentConfig.output.filename).toEqual('js/[name].js')
|
|
35
|
-
expect(environmentConfig.output.chunkFilename).toEqual(
|
|
36
|
-
'js/[name].chunk.js'
|
|
37
|
-
)
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
describe('with unset config.useContentHash', () => {
|
|
42
|
-
test('sets filename without using contentHash', () => {
|
|
43
|
-
const config = require("../../config");
|
|
44
|
-
delete config.useContentHash
|
|
45
|
-
const environmentConfig = require('../development')
|
|
46
|
-
|
|
47
|
-
expect(environmentConfig.output.filename).toEqual('js/[name].js')
|
|
48
|
-
expect(environmentConfig.output.chunkFilename).toEqual(
|
|
49
|
-
'js/[name].chunk.js'
|
|
50
|
-
)
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
})
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
/* global test expect, describe, afterAll, beforeEach */
|
|
2
|
-
|
|
3
|
-
const { chdirTestApp, resetEnv } = require('../../utils/helpers')
|
|
4
|
-
const rootPath = process.cwd()
|
|
5
|
-
chdirTestApp()
|
|
6
|
-
|
|
7
|
-
describe('Production specific config', () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
jest.resetModules()
|
|
10
|
-
resetEnv()
|
|
11
|
-
process.env['NODE_ENV'] = 'production'
|
|
12
|
-
})
|
|
13
|
-
afterAll(() => process.chdir(rootPath))
|
|
14
|
-
|
|
15
|
-
describe('with config.useContentHash = true', () => {
|
|
16
|
-
test('sets filename to use contentHash', () => {
|
|
17
|
-
const config = require("../../config");
|
|
18
|
-
config.useContentHash = true
|
|
19
|
-
const environmentConfig = require('../production')
|
|
20
|
-
|
|
21
|
-
expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
|
22
|
-
expect(environmentConfig.output.chunkFilename).toEqual(
|
|
23
|
-
'js/[name]-[contenthash].chunk.js'
|
|
24
|
-
)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test("doesn't shows any warning message", () => {
|
|
28
|
-
const consoleWarnSpy = jest.spyOn(console, 'warn');
|
|
29
|
-
const config = require("../../config");
|
|
30
|
-
config.useContentHash = true
|
|
31
|
-
const environmentConfig = require('../production')
|
|
32
|
-
|
|
33
|
-
expect(consoleWarnSpy).not.toHaveBeenCalledWith(
|
|
34
|
-
expect.stringMatching(/Setting 'useContentHash' to 'false' in the production environment/)
|
|
35
|
-
)
|
|
36
|
-
|
|
37
|
-
consoleWarnSpy.mockRestore()
|
|
38
|
-
})
|
|
39
|
-
})
|
|
40
|
-
|
|
41
|
-
describe('with config.useContentHash = false', () => {
|
|
42
|
-
test('sets filename to use contentHash', () => {
|
|
43
|
-
const config = require("../../config");
|
|
44
|
-
config.useContentHash = false
|
|
45
|
-
const environmentConfig = require('../production')
|
|
46
|
-
|
|
47
|
-
expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
|
48
|
-
expect(environmentConfig.output.chunkFilename).toEqual(
|
|
49
|
-
'js/[name]-[contenthash].chunk.js'
|
|
50
|
-
)
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
test('shows a warning message', () => {
|
|
54
|
-
const consoleWarnSpy = jest.spyOn(console, 'warn');
|
|
55
|
-
const config = require("../../config");
|
|
56
|
-
config.useContentHash = false
|
|
57
|
-
const environmentConfig = require('../production')
|
|
58
|
-
|
|
59
|
-
expect(consoleWarnSpy).toHaveBeenCalledWith(
|
|
60
|
-
expect.stringMatching(/Setting 'useContentHash' to 'false' in the production environment/)
|
|
61
|
-
)
|
|
62
|
-
|
|
63
|
-
consoleWarnSpy.mockRestore()
|
|
64
|
-
})
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
describe('with unset config.useContentHash', () => {
|
|
68
|
-
test('sets filename to use contentHash', () => {
|
|
69
|
-
const config = require("../../config");
|
|
70
|
-
delete config.useContentHash
|
|
71
|
-
const environmentConfig = require('../production')
|
|
72
|
-
|
|
73
|
-
expect(environmentConfig.output.filename).toEqual('js/[name]-[contenthash].js')
|
|
74
|
-
expect(environmentConfig.output.chunkFilename).toEqual(
|
|
75
|
-
'js/[name]-[contenthash].chunk.js'
|
|
76
|
-
)
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
test("doesn't shows any warning message", () => {
|
|
80
|
-
const consoleWarnSpy = jest.spyOn(console, 'warn');
|
|
81
|
-
const config = require("../../config");
|
|
82
|
-
delete config.useContentHash
|
|
83
|
-
const environmentConfig = require('../production')
|
|
84
|
-
|
|
85
|
-
expect(consoleWarnSpy).not.toHaveBeenCalledWith(
|
|
86
|
-
expect.stringMatching(/Setting 'useContentHash' to 'false' in the production environment/)
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
consoleWarnSpy.mockRestore()
|
|
90
|
-
})
|
|
91
|
-
})
|
|
92
|
-
})
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
const webpack = require("webpack");
|
|
2
|
-
const MemoryFS = require("memory-fs");
|
|
3
|
-
const thenify = require("thenify");
|
|
4
|
-
const path = require("path");
|
|
5
|
-
|
|
6
|
-
const createTrackLoader = () => {
|
|
7
|
-
const filesTracked = {};
|
|
8
|
-
return [
|
|
9
|
-
filesTracked,
|
|
10
|
-
(source) => {
|
|
11
|
-
filesTracked[source.resource] = true;
|
|
12
|
-
return source;
|
|
13
|
-
},
|
|
14
|
-
];
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const node_modules = path.resolve("node_modules");
|
|
18
|
-
const node_modules_included = path.resolve("node_modules/included");
|
|
19
|
-
const app_javascript = path.resolve("app/javascript");
|
|
20
|
-
|
|
21
|
-
const createInMemoryFs = () => {
|
|
22
|
-
const fs = new MemoryFS();
|
|
23
|
-
|
|
24
|
-
fs.mkdirpSync(node_modules);
|
|
25
|
-
fs.mkdirpSync(node_modules_included);
|
|
26
|
-
fs.mkdirpSync(app_javascript);
|
|
27
|
-
|
|
28
|
-
return fs;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const createTestCompiler = (config, fs = createInMemoryFs()) => {
|
|
32
|
-
Object.values(config.entry).forEach((file) => {
|
|
33
|
-
fs.writeFileSync(file, "console.log(1);");
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const compiler = webpack(config);
|
|
37
|
-
compiler.run = thenify(compiler.run);
|
|
38
|
-
compiler.inputFileSystem = fs;
|
|
39
|
-
compiler.outputFileSystem = fs;
|
|
40
|
-
return compiler;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
module.exports = {
|
|
44
|
-
createTrackLoader,
|
|
45
|
-
node_modules,
|
|
46
|
-
node_modules_included,
|
|
47
|
-
app_javascript,
|
|
48
|
-
createInMemoryFs,
|
|
49
|
-
createTestCompiler,
|
|
50
|
-
};
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const {
|
|
3
|
-
app_javascript,
|
|
4
|
-
node_modules,
|
|
5
|
-
node_modules_included,
|
|
6
|
-
createTestCompiler,
|
|
7
|
-
createTrackLoader,
|
|
8
|
-
} = require("./__utils__/webpack");
|
|
9
|
-
const babelConfig = require("../babel");
|
|
10
|
-
|
|
11
|
-
jest.mock("../../config", () => {
|
|
12
|
-
const original = jest.requireActual("../../config");
|
|
13
|
-
return {
|
|
14
|
-
...original,
|
|
15
|
-
includePaths: [...original.includePaths, "node_modules/included"]
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const createWebpackConfig = (file, use) => {
|
|
20
|
-
return {
|
|
21
|
-
entry: { file },
|
|
22
|
-
module: {
|
|
23
|
-
rules: [
|
|
24
|
-
{
|
|
25
|
-
...babelConfig,
|
|
26
|
-
use,
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
output: {
|
|
31
|
-
path: "/",
|
|
32
|
-
filename: "scripts-bundled.js",
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
describe("babel", () => {
|
|
38
|
-
test("process source path", async () => {
|
|
39
|
-
const normalPath = `${app_javascript}/a.js`;
|
|
40
|
-
const [tracked, loader] = createTrackLoader();
|
|
41
|
-
const compiler = createTestCompiler(
|
|
42
|
-
createWebpackConfig(normalPath, loader)
|
|
43
|
-
);
|
|
44
|
-
await compiler.run();
|
|
45
|
-
expect(tracked[normalPath]).toBeTruthy();
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
test("exclude node_modules", async () => {
|
|
49
|
-
const ignored = `${node_modules}/a.js`;
|
|
50
|
-
const [tracked, loader] = createTrackLoader();
|
|
51
|
-
const compiler = createTestCompiler(createWebpackConfig(ignored, loader));
|
|
52
|
-
await compiler.run();
|
|
53
|
-
expect(tracked[ignored]).toBeUndefined();
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
test("explicitly included node_modules should be transpiled", async () => {
|
|
57
|
-
const included = `${node_modules_included}/a.js`;
|
|
58
|
-
const [tracked, loader] = createTrackLoader();
|
|
59
|
-
const compiler = createTestCompiler(createWebpackConfig(included, loader));
|
|
60
|
-
await compiler.run();
|
|
61
|
-
expect(tracked[included]).toBeTruthy();
|
|
62
|
-
});
|
|
63
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
const path = require("path");
|
|
2
|
-
const {
|
|
3
|
-
app_javascript,
|
|
4
|
-
node_modules,
|
|
5
|
-
node_modules_included,
|
|
6
|
-
createTestCompiler,
|
|
7
|
-
createTrackLoader,
|
|
8
|
-
} = require("./__utils__/webpack");
|
|
9
|
-
const esbuildConfig = require("../esbuild");
|
|
10
|
-
|
|
11
|
-
jest.mock("../../config", () => {
|
|
12
|
-
const original = jest.requireActual("../../config");
|
|
13
|
-
return {
|
|
14
|
-
...original,
|
|
15
|
-
webpack_loader: "esbuild",
|
|
16
|
-
includePaths: [...original.includePaths, "node_modules/included"]
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const createWebpackConfig = (file, use) => {
|
|
21
|
-
return {
|
|
22
|
-
entry: { file },
|
|
23
|
-
module: {
|
|
24
|
-
rules: [
|
|
25
|
-
{
|
|
26
|
-
...esbuildConfig,
|
|
27
|
-
use,
|
|
28
|
-
},
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
output: {
|
|
32
|
-
path: "/",
|
|
33
|
-
filename: "scripts-bundled.js",
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
describe("swc", () => {
|
|
39
|
-
test("process source path", async () => {
|
|
40
|
-
const normalPath = `${app_javascript}/a.js`;
|
|
41
|
-
const [tracked, loader] = createTrackLoader();
|
|
42
|
-
const compiler = createTestCompiler(
|
|
43
|
-
createWebpackConfig(normalPath, loader)
|
|
44
|
-
);
|
|
45
|
-
await compiler.run();
|
|
46
|
-
expect(tracked[normalPath]).toBeTruthy();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test("exclude node_modules", async () => {
|
|
50
|
-
const ignored = `${node_modules}/a.js`;
|
|
51
|
-
const [tracked, loader] = createTrackLoader();
|
|
52
|
-
const compiler = createTestCompiler(createWebpackConfig(ignored, loader));
|
|
53
|
-
await compiler.run();
|
|
54
|
-
expect(tracked[ignored]).toBeUndefined();
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
test("explicitly included node_modules should be transpiled", async () => {
|
|
58
|
-
const included = `${node_modules_included}/a.js`;
|
|
59
|
-
const [tracked, loader] = createTrackLoader();
|
|
60
|
-
const compiler = createTestCompiler(createWebpackConfig(included, loader));
|
|
61
|
-
await compiler.run();
|
|
62
|
-
expect(tracked[included]).toBeTruthy();
|
|
63
|
-
});
|
|
64
|
-
});
|