Skip to content

Commit 053f697

Browse files
author
Dimitri Kopriwa
committed
fix(extract): extract was not testing for rel or abs path created with babel-merge
1 parent c921ade commit 053f697

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/cli/cmds/intl_cmds/extract.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,15 @@ exports.handler = (argv) => {
132132
}
133133

134134
// we use defaults presets and plugins for react if nothing is found
135-
babelConfig.presets = babelConfig.presets || ['@babel/preset-react'];
135+
babelConfig.presets = babelConfig.presets || [
136+
[
137+
'@babel/preset-env',
138+
{
139+
modules: false,
140+
},
141+
],
142+
'@babel/preset-react',
143+
];
136144
babelConfig.plugins = babelConfig.plugins || [
137145
'@babel/plugin-transform-runtime',
138146
'@babel/plugin-transform-async-to-generator',
@@ -146,16 +154,21 @@ exports.handler = (argv) => {
146154
},
147155
],
148156
];
157+
149158
// do not use presets that are not installed
150159
babelConfig.presets = babelConfig.presets.filter((preset) => {
151160
const name = typeof preset === 'string' ? preset : preset[0];
152-
return !!fs.existsSync(path.join(argv.path, 'node_modules', name));
161+
const absPath = fs.existsSync(name);
162+
const relPath = fs.existsSync(path.join(argv.path, 'node_modules', name));
163+
return absPath || relPath;
153164
});
154165

155166
// do not use plugins that are not installed
156167
babelConfig.plugins = babelConfig.plugins.filter((plugin) => {
157168
const name = typeof plugin === 'string' ? plugin : plugin[0];
158-
return !!fs.existsSync(path.join(argv.path, 'node_modules', name));
169+
const absPath = fs.existsSync(name);
170+
const relPath = fs.existsSync(path.join(argv.path, 'node_modules', name));
171+
return absPath || relPath;
159172
});
160173

161174
// we add react-intl plugins to the list

0 commit comments

Comments
 (0)