Skip to content

Commit

Permalink
fix(cli-app-scripts): use the same build dir for modes (#302)
Browse files Browse the repository at this point in the history
This removes the devOut path and usage of it, instead opting for
building the development build and production build into the same
folder: ./build.

For libraries in monorepo situations this is important as they will look
up the main or module key in the package.json file, which is usually set
to e.g. ./build/{cjs,es}/lib.js when using the cli-app-scripts to build
the lib.
  • Loading branch information
varl committed Feb 18, 2020
1 parent 6ae8032 commit dd2802b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 6 additions & 4 deletions cli/src/lib/compiler/compileLibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,7 @@ const compileLibrary = async ({ config, paths, mode, watch }) => {
const input =
(config.entryPoints && config.entryPoints[config.type]) ||
'src/index.js'
const outDir = mode === 'production' ? paths.buildOutput : paths.devOut

fs.removeSync(outDir)
fs.ensureDirSync(outDir)
const outDir = paths.buildOutput

const pkg = require(paths.package)

Expand All @@ -50,6 +47,9 @@ const compileLibrary = async ({ config, paths, mode, watch }) => {
reporter.debug('Rollup config', rollupConfig)

if (!watch) {
fs.removeSync(outDir)
fs.ensureDirSync(outDir)

// create a bundle
try {
const bundle = await rollup.rollup(rollupConfig)
Expand Down Expand Up @@ -81,6 +81,8 @@ const compileLibrary = async ({ config, paths, mode, watch }) => {
process.exit(1)
}
} else {
fs.ensureDirSync(outDir)

return new Promise((resolve, reject) => {
reporter.debug('watching...')
const watcher = rollup.watch({
Expand Down
1 change: 0 additions & 1 deletion cli/src/lib/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ module.exports = (cwd = process.cwd()) => {
i18nLocales: path.join(base, './src/locales'),

d2: path.join(base, './.d2/'),
devOut: path.join(base, './.d2/devOut'),
appOutputFilename: 'App.js',
shell: path.join(base, './.d2/shell'),
shellAppEntrypoint: path.join(base, './.d2/shell/src/App.js'),
Expand Down

0 comments on commit dd2802b

Please sign in to comment.