Skip preserving file extension for generated path
See original GitHub issueBabel would emit the files with js extension irrespective of the extension of source files, which would cause problem to test individual files without using webpack or gulp, since required modules path would never be resolved, becuase generated files would have an extension of js
and the generated webpack alias path would be referring to jsx
(i.e original extension)
I’ve shown an example to support the use case
.babelrc
{
"presets": ["es2015", "react","stage-2"],
"plugins" : [
["babel-plugin-webpack-alias", { "config": "./webpack/server/server.js" }]
],
}
webpack config
resolve : {
extensions: ['','.js','.jsx'],
modules : [srcPath,path.join(basePath,'./node_modules')],
alias : {
template: path.join(srcPath,'./template')
},
},
es6 code
import Layout from 'template/Layout';
Generating es5 file post babel transformation
src/server/template/Layout.jsx -> lib/server/template/Layout.js
Post babel transformation
var _Layout = require('./Layout.jsx'); //should be './Layout.js'
var _Layout2 = _interopRequireDefault(_Layout);
Running in node
Error: Cannot find module './Layout.jsx'
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to get the filename without the extension in Java?
The removeExtension method preserves the rest of the path along with the filename. ... Remove the file extension from a filename, that may...
Read more >How can I recursively copy files by file extension, preserving ...
At the Linux command line, I'd like to copy a (very large) set of .txt files from one directory (and its subdirectories) to...
Read more >SharePoint Migration Tool settings - Microsoft 365
Enter a list of file extensions of file types you do not want to migrate. Separate each extension entered with a colon. Do...
Read more >Ignoring Code - Prettier
Use .prettierignore to ignore (i.e. not reformat) certain files and folders completely. Use “prettier-ignore” comments to ignore parts of files.
Read more >cp - Copy specific file type keeping the folder structure
c would be created on the remote machine, preserving its full path. These extra path elements are called "implied directories" (i.e. the "foo" ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@adriantoine thanks alot, i’ll check and revert back to you
@devarsh It’s just been released in v2.1.0!