File size: 1,004 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
const fs = require( 'fs' );
const path = require( 'path' );
/**
* Given a module name, returns the package version
* @param {string} id Module name
* @returns {string} Module version
*/
function getModuleVersion( id ) {
return require( id + '/package.json' ).version;
}
/**
* Cache identifier string for use with babel-loader. This is an extension of
* the default cacheIdentifier, including package version from our custom Babel
* transform plugin to ensure proper cachebusting.
* @see https://github.com/babel/babel-loader/blob/501d60d/src/index.js#L85-L92
* @type {string}
*/
module.exports = JSON.stringify( {
'babel-loader': getModuleVersion( 'babel-loader' ),
'babel-core': getModuleVersion( '@babel/core' ),
'babel-plugin-transform-wpcalypso-async': getModuleVersion(
'@automattic/babel-plugin-transform-wpcalypso-async'
),
babelrc: fs.readFileSync( path.resolve( __dirname, '../../../babel.config.js' ), 'utf8' ),
env: process.env.BABEL_ENV || process.env.NODE_ENV,
} );
|