I'm working on a Node.js library that's already in production, and we are implementing Webpack to use babel-loader. I'm using webpack-node-externals to leave external requires unresolved until runtime.
The thing is, at some points the library need information about the app that is using it, and so far it's bee requiring it using the following:
const basepath = process.cwd();
const pkg = require( path.join( basepath, 'package.json' ) );
const packageVersion = pkg.version;
This has been working fine so far, since process.cwd() resolves to the working directory of the app that is running the library. But when ebpack reaches this require, it tries to resolve it and replaces it with a webpackMissingModule error.
Is there a way to leave this require as it is until runtime? I tried using the externals property with no luck.
via Luis Gonzalez
No comments:
Post a Comment