webpacker 6.0.0.beta.6 → 6.0.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/jest.yml +1 -1
- data/.github/workflows/js-lint.yml +1 -1
- data/.github/workflows/ruby.yml +6 -9
- data/CHANGELOG.md +4 -20
- data/CONTRIBUTING.md +1 -1
- data/Gemfile.lock +5 -7
- data/README.md +109 -306
- data/docs/assets.md +135 -0
- data/docs/cloud9.md +310 -0
- data/docs/css.md +303 -0
- data/docs/deployment.md +148 -0
- data/docs/docker.md +68 -0
- data/docs/engines.md +213 -0
- data/docs/env.md +68 -0
- data/docs/es6.md +72 -0
- data/docs/folder-structure.md +66 -0
- data/docs/integrations.md +220 -0
- data/docs/misc.md +23 -0
- data/docs/props.md +187 -0
- data/docs/react.md +183 -0
- data/docs/target.md +22 -0
- data/docs/testing.md +147 -0
- data/docs/troubleshooting.md +3 -5
- data/docs/typescript.md +190 -0
- data/docs/v4-upgrade.md +142 -0
- data/docs/webpack-dev-server.md +94 -0
- data/docs/webpack.md +315 -0
- data/docs/yarn.md +23 -0
- data/lib/install/config/webpacker.yml +2 -4
- data/lib/install/examples/vue3/app.vue +27 -0
- data/lib/install/examples/vue3/hello_vue.js +15 -0
- data/lib/install/javascript/packs/application.css +9 -0
- data/lib/install/{packs/entrypoints → javascript/packs}/application.js +2 -4
- data/lib/install/template.rb +3 -3
- data/lib/webpacker/commands.rb +1 -2
- data/lib/webpacker/compiler.rb +3 -9
- data/lib/webpacker/dev_server_runner.rb +0 -2
- data/lib/webpacker/helper.rb +43 -13
- data/lib/webpacker/manifest.rb +1 -1
- data/lib/webpacker/version.rb +1 -1
- data/lib/webpacker/webpack_runner.rb +0 -1
- data/package.json +1 -1
- data/package/__tests__/development.js +1 -2
- data/package/babel/preset-react.js +62 -0
- data/package/babel/preset.js +13 -24
- data/package/environments/__tests__/base.js +5 -5
- data/package/environments/base.js +19 -19
- data/package/environments/development.js +0 -1
- data/package/environments/production.js +30 -28
- data/package/index.js +2 -7
- data/package/rules/babel.js +1 -1
- data/package/rules/coffee.js +5 -5
- data/package/rules/erb.js +3 -5
- data/package/rules/file.js +3 -5
- data/package/rules/index.js +17 -9
- data/package/rules/less.js +10 -14
- data/package/rules/sass.js +9 -13
- data/package/rules/svg.js +23 -0
- data/package/utils/get_style_rule.js +31 -27
- data/package/utils/helpers.js +0 -25
- data/test/configuration_test.rb +2 -2
- data/test/dev_server_runner_test.rb +2 -10
- data/test/helper_test.rb +39 -33
- data/test/manifest_test.rb +0 -8
- data/test/mounted_app/test/dummy/config/webpacker.yml +2 -2
- data/test/test_app/app/{packs/entrypoints → javascript/packs}/application.js +1 -1
- data/test/test_app/app/{packs/entrypoints → javascript/packs}/multi_entry.css +0 -0
- data/test/test_app/app/{packs/entrypoints → javascript/packs}/multi_entry.js +0 -0
- data/test/test_app/config/webpacker.yml +2 -2
- data/test/test_app/public/packs/manifest.json +0 -7
- metadata +36 -17
- data/6_0_upgrade.md +0 -62
- data/config/README.md +0 -3
- data/config/webpacker.yml +0 -1
- data/package/__tests__/index.js +0 -9
- data/package/rules/raw.js +0 -5
- data/package/rules/stylus.js +0 -26
data/docs/yarn.md
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Yarn
|
2
|
+
|
3
|
+
Webpacker by default uses `yarn` as a package manager for `node_modules`
|
4
|
+
|
5
|
+
|
6
|
+
## Add a new npm module
|
7
|
+
|
8
|
+
To add any new JS module you can use `yarn`:
|
9
|
+
|
10
|
+
```bash
|
11
|
+
yarn add bootstrap material-ui
|
12
|
+
```
|
13
|
+
|
14
|
+
## Add an npm module to `devDependencies`
|
15
|
+
To add a new JS module that will only be available to local development:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
yarn add --dev browser-sync
|
19
|
+
```
|
20
|
+
|
21
|
+
Be careful not to add any build or app related JS modules in this fashion. Adding JS modules to `devDependencies` [will block them from being installed in **any** production environment](https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-production-true-false).
|
22
|
+
|
23
|
+
Docs from JS modules may instruct you to use `--dev` or `devDependencies`, but this is generally under the assumption that you are using a `node.js` workflow.
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
2
2
|
|
3
3
|
default: &default
|
4
|
-
source_path: app/
|
5
|
-
source_entry_path:
|
4
|
+
source_path: app/javascript
|
5
|
+
source_entry_path: packs
|
6
6
|
public_root_path: public
|
7
7
|
public_output_path: packs
|
8
8
|
cache_path: tmp/cache/webpacker
|
@@ -25,8 +25,6 @@ development:
|
|
25
25
|
host: localhost
|
26
26
|
port: 3035
|
27
27
|
public: localhost:3035
|
28
|
-
# Inject browserside javascript that required by both HMR and Live(full) reload
|
29
|
-
inject_client: true
|
30
28
|
# Hot Module Replacement updates modules while the application is running without a full reload
|
31
29
|
hmr: false
|
32
30
|
# Inline should be set to true if using HMR; it inserts a script to take care of live reloading
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<template>
|
2
|
+
<p>
|
3
|
+
{{ message }}
|
4
|
+
</p>
|
5
|
+
</template>
|
6
|
+
|
7
|
+
<script>
|
8
|
+
import { ref } from 'vue'
|
9
|
+
|
10
|
+
export default {
|
11
|
+
name: 'HelloWorld',
|
12
|
+
setup() {
|
13
|
+
const message = ref('Hello World')
|
14
|
+
|
15
|
+
return {
|
16
|
+
message
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
</script>
|
21
|
+
|
22
|
+
<style scoped>
|
23
|
+
p {
|
24
|
+
font-size: 2em;
|
25
|
+
text-align: center;
|
26
|
+
}
|
27
|
+
</style>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* eslint no-console: 0 */
|
2
|
+
// Run this example by adding <%= javascript_pack_tag 'hello_vue' %> (and
|
3
|
+
// <%= stylesheet_pack_tag 'hello_vue' %> if you have styles in your component)
|
4
|
+
// to the head of your layout file,
|
5
|
+
// like app/views/layouts/application.html.erb.
|
6
|
+
// Create a div container with the id 'vue-app' <div id='vue-app'></div>
|
7
|
+
// It renders <p>Hello Vue</p> into it.
|
8
|
+
|
9
|
+
import { createApp } from "vue";
|
10
|
+
import App from "../app.vue";
|
11
|
+
|
12
|
+
document.addEventListener("DOMContentLoaded", () => {
|
13
|
+
const app = createApp(App);
|
14
|
+
app.mount("#vue-app");
|
15
|
+
});
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/*
|
2
|
+
Any CSS added to this file or imported from this file, e.g. `@import '../stylesheets/my-css.css'`,
|
3
|
+
will be included in the "application" pack. Any CSS imported from application.js or as part of the
|
4
|
+
application.js dependency graph, e.g. `import '../stylesheets/my-css.css'` will also be included
|
5
|
+
in the "application" pack.
|
6
|
+
|
7
|
+
To reference this file, add <%= stylesheet_pack_tag 'application' %> to the appropriate
|
8
|
+
layout file, like app/views/layouts/application.html.erb
|
9
|
+
*/
|
@@ -1,12 +1,13 @@
|
|
1
1
|
/* eslint no-console:0 */
|
2
2
|
// This file is automatically compiled by Webpack, along with any other files
|
3
3
|
// present in this directory. You're encouraged to place your actual application logic in
|
4
|
-
// a relevant structure within app/
|
4
|
+
// a relevant structure within app/javascript and only use these pack files to reference
|
5
5
|
// that code so it'll be compiled.
|
6
6
|
//
|
7
7
|
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
|
8
8
|
// layout file, like app/views/layouts/application.html.erb
|
9
9
|
|
10
|
+
|
10
11
|
// Uncomment to copy all static images under ../images to the output folder and reference
|
11
12
|
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
|
12
13
|
// or the `imagePath` JavaScript helper below.
|
@@ -14,7 +15,4 @@
|
|
14
15
|
// const images = require.context('../images', true)
|
15
16
|
// const imagePath = (name) => images(name, true)
|
16
17
|
|
17
|
-
import 'core-js/stable'
|
18
|
-
import 'regenerator-runtime/runtime'
|
19
|
-
|
20
18
|
console.log('Hello World from Webpacker')
|
data/lib/install/template.rb
CHANGED
@@ -5,10 +5,10 @@ say "Copying webpack core config"
|
|
5
5
|
directory "#{__dir__}/config/webpack", "config/webpack"
|
6
6
|
|
7
7
|
if Dir.exists?(Webpacker.config.source_path)
|
8
|
-
say "The
|
8
|
+
say "The JavaScript app source directory already exists"
|
9
9
|
else
|
10
|
-
say "Creating
|
11
|
-
directory "#{__dir__}/
|
10
|
+
say "Creating JavaScript app source directory"
|
11
|
+
directory "#{__dir__}/javascript", Webpacker.config.source_path
|
12
12
|
end
|
13
13
|
|
14
14
|
apply "#{__dir__}/binstubs.rb"
|
data/lib/webpacker/commands.rb
CHANGED
@@ -64,8 +64,7 @@ class Webpacker::Commands
|
|
64
64
|
|
65
65
|
def current_version
|
66
66
|
packs = manifest.refresh.values.map do |value|
|
67
|
-
|
68
|
-
next unless value.is_a?(String)
|
67
|
+
next if value.is_a?(Hash)
|
69
68
|
|
70
69
|
File.join(config.root_path, "public", "#{value}*")
|
71
70
|
end.compact
|
data/lib/webpacker/compiler.rb
CHANGED
@@ -28,14 +28,14 @@ class Webpacker::Compiler
|
|
28
28
|
record_compilation_digest
|
29
29
|
end
|
30
30
|
else
|
31
|
-
logger.
|
31
|
+
logger.info "Everything's up-to-date. Nothing to do"
|
32
32
|
true
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
# Returns true if all the compiled packs are up to date with the underlying asset files.
|
37
37
|
def fresh?
|
38
|
-
last_compilation_digest
|
38
|
+
watched_files_digest == last_compilation_digest
|
39
39
|
end
|
40
40
|
|
41
41
|
# Returns true if the compiled packs are out of date with the underlying asset files.
|
@@ -65,18 +65,12 @@ class Webpacker::Compiler
|
|
65
65
|
compilation_digest_path.write(watched_files_digest)
|
66
66
|
end
|
67
67
|
|
68
|
-
def optionalRubyRunner
|
69
|
-
bin_webpack_path = config.root_path.join("bin/webpack")
|
70
|
-
first_line = File.readlines(bin_webpack_path).first.chomp
|
71
|
-
/ruby/.match?(first_line) ? RbConfig.ruby : ""
|
72
|
-
end
|
73
|
-
|
74
68
|
def run_webpack
|
75
69
|
logger.info "Compiling..."
|
76
70
|
|
77
71
|
stdout, stderr, status = Open3.capture3(
|
78
72
|
webpack_env,
|
79
|
-
"#{
|
73
|
+
"#{RbConfig.ruby} ./bin/webpack",
|
80
74
|
chdir: File.expand_path(config.root_path)
|
81
75
|
)
|
82
76
|
|
@@ -64,7 +64,6 @@ module Webpacker
|
|
64
64
|
def execute_cmd
|
65
65
|
env = Webpacker::Compiler.env
|
66
66
|
env["WEBPACKER_CONFIG"] = @webpacker_config
|
67
|
-
env["WEBPACK_DEV_SERVER"] = "true"
|
68
67
|
|
69
68
|
cmd = if node_modules_bin_exist?
|
70
69
|
["#{@node_modules_bin_path}/webpack", "serve"]
|
@@ -74,7 +73,6 @@ module Webpacker
|
|
74
73
|
|
75
74
|
if @argv.include?("--debug-webpacker")
|
76
75
|
cmd = [ "node", "--inspect-brk"] + cmd
|
77
|
-
@argv.delete "--debug-webpacker"
|
78
76
|
end
|
79
77
|
|
80
78
|
cmd += ["--config", @webpack_config]
|
data/lib/webpacker/helper.rb
CHANGED
@@ -72,15 +72,27 @@ module Webpacker::Helper
|
|
72
72
|
favicon_link_tag(resolve_path_to_image(name), options)
|
73
73
|
end
|
74
74
|
|
75
|
+
# Creates a script tag that references the named pack file, as compiled by webpack per the entries list
|
76
|
+
# in package/environments/base.js. By default, this list is auto-generated to match everything in
|
77
|
+
# app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
|
78
|
+
#
|
79
|
+
# Example:
|
80
|
+
#
|
81
|
+
# <%= javascript_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
|
82
|
+
# <script src="/packs/calendar-1016838bab065ae1e314.js" data-turbolinks-track="reload"></script>
|
83
|
+
def javascript_pack_tag(*names, **options)
|
84
|
+
javascript_include_tag(*sources_from_manifest_entries(names, type: :javascript), **options)
|
85
|
+
end
|
86
|
+
|
75
87
|
# Creates script tags that reference the js chunks from entrypoints when using split chunks API,
|
76
88
|
# as compiled by webpack per the entries list in package/environments/base.js.
|
77
89
|
# By default, this list is auto-generated to match everything in
|
78
|
-
# app/packs
|
90
|
+
# app/javascript/packs/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
|
79
91
|
# See: https://webpack.js.org/plugins/split-chunks-plugin/
|
80
92
|
#
|
81
93
|
# Example:
|
82
94
|
#
|
83
|
-
# <%=
|
95
|
+
# <%= javascript_packs_with_chunks_tag 'calendar', 'map', 'data-turbolinks-track': 'reload' %> # =>
|
84
96
|
# <script src="/packs/vendor-16838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>
|
85
97
|
# <script src="/packs/calendar~runtime-16838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>
|
86
98
|
# <script src="/packs/calendar-1016838bab065ae1e314.chunk.js" data-turbolinks-track="reload"></script>
|
@@ -89,13 +101,13 @@ module Webpacker::Helper
|
|
89
101
|
#
|
90
102
|
# DO:
|
91
103
|
#
|
92
|
-
# <%=
|
104
|
+
# <%= javascript_packs_with_chunks_tag 'calendar', 'map' %>
|
93
105
|
#
|
94
106
|
# DON'T:
|
95
107
|
#
|
96
|
-
# <%=
|
97
|
-
# <%=
|
98
|
-
def
|
108
|
+
# <%= javascript_packs_with_chunks_tag 'calendar' %>
|
109
|
+
# <%= javascript_packs_with_chunks_tag 'map' %>
|
110
|
+
def javascript_packs_with_chunks_tag(*names, **options)
|
99
111
|
javascript_include_tag(*sources_from_manifest_entrypoints(names, type: :javascript), **options)
|
100
112
|
end
|
101
113
|
|
@@ -115,35 +127,53 @@ module Webpacker::Helper
|
|
115
127
|
end
|
116
128
|
end
|
117
129
|
|
130
|
+
# Creates a link tag that references the named pack file, as compiled by webpack per the entries list
|
131
|
+
# in package/environments/base.js. By default, this list is auto-generated to match everything in
|
132
|
+
# app/javascript/packs/*.js. In production mode, the digested reference is automatically looked up.
|
133
|
+
#
|
134
|
+
# Note: If the development server is running and hot module replacement is active, this will return nothing.
|
135
|
+
# In that setup you need to configure your styles to be inlined in your JavaScript for hot reloading.
|
136
|
+
#
|
137
|
+
# Examples:
|
138
|
+
#
|
139
|
+
# <%= stylesheet_pack_tag 'calendar', 'data-turbolinks-track': 'reload' %> # =>
|
140
|
+
# <link rel="stylesheet" media="screen" href="/packs/calendar-1016838bab065ae1e122.css" data-turbolinks-track="reload" />
|
141
|
+
def stylesheet_pack_tag(*names, **options)
|
142
|
+
stylesheet_link_tag(*sources_from_manifest_entries(names, type: :stylesheet), **options)
|
143
|
+
end
|
144
|
+
|
118
145
|
# Creates link tags that reference the css chunks from entrypoints when using split chunks API,
|
119
146
|
# as compiled by webpack per the entries list in package/environments/base.js.
|
120
147
|
# By default, this list is auto-generated to match everything in
|
121
|
-
# app/packs
|
148
|
+
# app/javascript/packs/*.js and all the dependent chunks. In production mode, the digested reference is automatically looked up.
|
122
149
|
# See: https://webpack.js.org/plugins/split-chunks-plugin/
|
123
150
|
#
|
124
151
|
# Examples:
|
125
152
|
#
|
126
|
-
# <%=
|
153
|
+
# <%= stylesheet_packs_with_chunks_tag 'calendar', 'map' %> # =>
|
127
154
|
# <link rel="stylesheet" media="screen" href="/packs/3-8c7ce31a.chunk.css" />
|
128
155
|
# <link rel="stylesheet" media="screen" href="/packs/calendar-8c7ce31a.chunk.css" />
|
129
156
|
# <link rel="stylesheet" media="screen" href="/packs/map-8c7ce31a.chunk.css" />
|
130
157
|
#
|
131
158
|
# DO:
|
132
159
|
#
|
133
|
-
# <%=
|
160
|
+
# <%= stylesheet_packs_with_chunks_tag 'calendar', 'map' %>
|
134
161
|
#
|
135
162
|
# DON'T:
|
136
163
|
#
|
137
|
-
# <%=
|
138
|
-
# <%=
|
139
|
-
def
|
164
|
+
# <%= stylesheet_packs_with_chunks_tag 'calendar' %>
|
165
|
+
# <%= stylesheet_packs_with_chunks_tag 'map' %>
|
166
|
+
def stylesheet_packs_with_chunks_tag(*names, **options)
|
140
167
|
stylesheet_link_tag(*sources_from_manifest_entrypoints(names, type: :stylesheet), **options)
|
141
168
|
end
|
142
169
|
|
143
170
|
private
|
171
|
+
def sources_from_manifest_entries(names, type:)
|
172
|
+
names.map { |name| current_webpacker_instance.manifest.lookup!(name, type: type) }.flatten
|
173
|
+
end
|
144
174
|
|
145
175
|
def sources_from_manifest_entrypoints(names, type:)
|
146
|
-
names.map { |name| current_webpacker_instance.manifest.lookup_pack_with_chunks!(name
|
176
|
+
names.map { |name| current_webpacker_instance.manifest.lookup_pack_with_chunks!(name, type: type) }.flatten.uniq
|
147
177
|
end
|
148
178
|
|
149
179
|
def resolve_path_to_image(name, **options)
|
data/lib/webpacker/manifest.rb
CHANGED
@@ -92,7 +92,7 @@ class Webpacker::Manifest
|
|
92
92
|
# When the user provides a name with a file extension, we want to try to strip it off.
|
93
93
|
def manifest_name(name, pack_type)
|
94
94
|
return name if File.extname(name.to_s).empty?
|
95
|
-
File.basename(name,
|
95
|
+
File.basename(name, pack_type)
|
96
96
|
end
|
97
97
|
|
98
98
|
def manifest_type(pack_type)
|
data/lib/webpacker/version.rb
CHANGED
data/package.json
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
module.exports = function config(api) {
|
2
|
+
const validEnv = ['development', 'test', 'production']
|
3
|
+
const currentEnv = api.env()
|
4
|
+
const isDevelopmentEnv = api.env('development')
|
5
|
+
const isProductionEnv = api.env('production')
|
6
|
+
const isTestEnv = api.env('test')
|
7
|
+
|
8
|
+
if (!validEnv.includes(currentEnv)) {
|
9
|
+
throw new Error(
|
10
|
+
`Please specify a valid NODE_ENV or BABEL_ENV environment variable. Valid values are "development", "test", and "production". Instead, received: "${JSON.stringify(currentEnv)}".`
|
11
|
+
)
|
12
|
+
}
|
13
|
+
|
14
|
+
return {
|
15
|
+
presets: [
|
16
|
+
isTestEnv && [
|
17
|
+
'@babel/preset-env',
|
18
|
+
{
|
19
|
+
targets: { node: 'current' },
|
20
|
+
modules: 'commonjs'
|
21
|
+
}
|
22
|
+
],
|
23
|
+
(isProductionEnv || isDevelopmentEnv) && [
|
24
|
+
'@babel/preset-env',
|
25
|
+
{
|
26
|
+
useBuiltIns: 'entry',
|
27
|
+
corejs: '3.8',
|
28
|
+
modules: false,
|
29
|
+
bugfixes: true,
|
30
|
+
loose: true,
|
31
|
+
exclude: ['transform-typeof-symbol']
|
32
|
+
}
|
33
|
+
],
|
34
|
+
[
|
35
|
+
'@babel/preset-react',
|
36
|
+
{
|
37
|
+
development: isDevelopmentEnv || isTestEnv,
|
38
|
+
useBuiltIns: true
|
39
|
+
}
|
40
|
+
]
|
41
|
+
].filter(Boolean),
|
42
|
+
plugins: [
|
43
|
+
'babel-plugin-macros',
|
44
|
+
[
|
45
|
+
'@babel/plugin-proposal-class-properties',
|
46
|
+
{ loose: true }
|
47
|
+
],
|
48
|
+
[
|
49
|
+
'@babel/plugin-transform-runtime',
|
50
|
+
{
|
51
|
+
helpers: false,
|
52
|
+
regenerator: true,
|
53
|
+
corejs: false
|
54
|
+
}
|
55
|
+
],
|
56
|
+
isProductionEnv && [
|
57
|
+
'babel-plugin-transform-react-remove-prop-types',
|
58
|
+
{ removeImport: true }
|
59
|
+
]
|
60
|
+
].filter(Boolean)
|
61
|
+
}
|
62
|
+
}
|
data/package/babel/preset.js
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
const { moduleExists } = require('@rails/webpacker')
|
2
|
-
|
3
1
|
module.exports = function config(api) {
|
4
2
|
const validEnv = ['development', 'test', 'production']
|
5
3
|
const currentEnv = api.env()
|
@@ -9,15 +7,16 @@ module.exports = function config(api) {
|
|
9
7
|
|
10
8
|
if (!validEnv.includes(currentEnv)) {
|
11
9
|
throw new Error(
|
12
|
-
`Please specify a valid NODE_ENV or BABEL_ENV environment variable. Valid values are "development", "test", and "production". Instead, received: "${JSON.stringify(
|
13
|
-
currentEnv
|
14
|
-
)}".`
|
10
|
+
`Please specify a valid NODE_ENV or BABEL_ENV environment variable. Valid values are "development", "test", and "production". Instead, received: "${JSON.stringify(currentEnv)}".`
|
15
11
|
)
|
16
12
|
}
|
17
13
|
|
18
14
|
return {
|
19
15
|
presets: [
|
20
|
-
isTestEnv && [
|
16
|
+
isTestEnv && [
|
17
|
+
'@babel/preset-env',
|
18
|
+
{ targets: { node: 'current' } }
|
19
|
+
],
|
21
20
|
(isProductionEnv || isDevelopmentEnv) && [
|
22
21
|
'@babel/preset-env',
|
23
22
|
{
|
@@ -28,28 +27,18 @@ module.exports = function config(api) {
|
|
28
27
|
loose: true,
|
29
28
|
exclude: ['transform-typeof-symbol']
|
30
29
|
}
|
31
|
-
],
|
32
|
-
moduleExists('@babel/preset-typescript') && [
|
33
|
-
'@babel/preset-typescript',
|
34
|
-
{ allExtensions: true, isTSX: true }
|
35
|
-
],
|
36
|
-
moduleExists('@babel/preset-react') && [
|
37
|
-
'@babel/preset-react',
|
38
|
-
{
|
39
|
-
development: isDevelopmentEnv || isTestEnv,
|
40
|
-
useBuiltIns: true
|
41
|
-
}
|
42
30
|
]
|
43
31
|
].filter(Boolean),
|
44
32
|
plugins: [
|
45
33
|
'babel-plugin-macros',
|
46
|
-
[
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
34
|
+
[
|
35
|
+
'@babel/plugin-proposal-class-properties',
|
36
|
+
{ loose: true }
|
37
|
+
],
|
38
|
+
[
|
39
|
+
'@babel/plugin-transform-runtime',
|
40
|
+
{ helpers: false }
|
41
|
+
]
|
53
42
|
].filter(Boolean)
|
54
43
|
}
|
55
44
|
}
|