Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cli-app-scripts): use the same build dir for modes #302

Merged
merged 1 commit into from
Feb 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to remove the existing directory before running the compiler in watch mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, Webpack Dev Server crashes if the directory disappears and needs to be restarted. Just overwriting the files works however, but we need to ensure that the dir is there on first run.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Meaning webpack devserver somewhere else in the monorepo? Unfortunate, but OK for now 👌

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for example when I run Storybook for ui-core and the build folder disappears, Storybook crashes, so deleting it on every rebuild is a bit annoying.


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