async function createPackageFile() {
  const packageData = await fse.readFile(path.resolve(packagePath, './package.json'), 'utf8');
  const { nyc, scripts, devDependencies, workspaces, ...packageDataOther } = JSON.parse(
    packageData,
  );
  const newPackageData = {
    ...packageDataOther,
    sideEffects: false,
    private: false,
    main: './index.js',
    module: './esm/index.js',
  };
  const targetPath = path.resolve(buildPath, './package.json');

  await fse.writeFile(targetPath, JSON.stringify(newPackageData, null, 2), 'utf8');
  console.log(`Created package.json in ${targetPath}`);

  return newPackageData;
}
/**
 * Puts a package.json into every immediate child directory of rootDir.
 * That package.json contains information about esm for bundlers so that imports
 * like import body_class_toggler_controller from 'arara/body_class_toggler_controller' are tree-shakeable.
 *
 * It also tests that an this import can be used in typescript by checking
 * if an index.d.ts is present at that path.
 *
 * @param {string} rootDir
 */
Puts a package.json into every immediate child directory of rootDir.
That package.json contains information about esm for bundlers so that imports
like import body_class_toggler_controller from 'arara/body_class_toggler_controller' are tree-shakeable.

It also tests that an this import can be used in typescript by checking
if an index.d.ts is present at that path.

@param {string} rootDir
Puts a package . json into every immediate child directory of rootDir . That package . json contains information about esm for bundlers so that imports like import body_class_toggler_controller from ' arara / body_class_toggler_controller ' are tree - shakeable . It also tests that an this import can be used in typescript by checking if an index . d . ts is present at that path . @param { string } rootDir
async function createPackageFile() {
  const packageData = await fse.readFile(path.resolve(packagePath, './package.json'), 'utf8');
  const { nyc, scripts, devDependencies, workspaces, ...packageDataOther } = JSON.parse(
    packageData,
  );
  const newPackageData = {
    ...packageDataOther,
    sideEffects: false,
    private: false,
    main: './index.js',
    module: './esm/index.js',
  };
  const targetPath = path.resolve(buildPath, './package.json');
  await fse.writeFile(targetPath, JSON.stringify(newPackageData, null, 2), 'utf8');
  console.log(`Created package.json in ${targetPath}`);
  return newPackageData;
}
async function createPackageFile ( ) { const packageData = await fse . readFile ( path . resolve ( packagePath , './package.json' ) , 'utf8' ) ; const { nyc , scripts , devDependencies , workspaces , ... packageDataOther } = JSON . parse ( packageData , ) ; const newPackageData = { ... packageDataOther , sideEffects : false , private : false , main : './index.js' , module : './esm/index.js' , } ; const targetPath = path . resolve ( buildPath , './package.json' ) ; await fse . writeFile ( targetPath , JSON . stringify ( newPackageData , null , 2 ) , 'utf8' ) ; console . log ( ` ${ targetPath } ` ) ; return newPackageData ; }
Puts a package.json into every immediate child directory of rootDir.
Puts a package . json into every immediate child directory of rootDir .