Closed tkambler closed 7 years ago
I'm in the habit of modifying my application's globalPaths setting like so (within the renderer's HTML document):
globalPaths
const path = require('path'); require('module').globalPaths.push(path.resolve(__dirname, 'src'));
With this in place, I can now do the following:
require('app'); // Loads module located at ./src/app/index.js
This works great. The following generates an error though:
import App from 'app'; // Cannot find module 'app'
Is there an extra setting for babel, etc..., that I need to know about?
=======
Update...
I've since found out about the babel-plugin-module-resolver module. I've installed it and updated my app's .compilerc like so:
babel-plugin-module-resolver
.compilerc
{ "application/javascript": { "presets": [ "es2016-node5" ], "plugins": [ ["module-resolver", { "root": ["./src"] }], "transform-class-properties", "transform-async-to-generator", "transform-runtime" ], "sourceMaps": "inline" } }
After removing my earlier code that modified globalPaths, everything seems to be working as expected now.
I'm in the habit of modifying my application's
globalPaths
setting like so (within the renderer's HTML document):With this in place, I can now do the following:
This works great. The following generates an error though:
Is there an extra setting for babel, etc..., that I need to know about?
=======
Update...
I've since found out about the
babel-plugin-module-resolver
module. I've installed it and updated my app's.compilerc
like so:After removing my earlier code that modified
globalPaths
, everything seems to be working as expected now.