Skip to content

Commit d89a30a

Browse files
committed
update
1 parent 3551ee6 commit d89a30a

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/gulpfile.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import gulp from 'gulp';
1010
import glob from 'glob';
1111
import fs from 'fs-extra';
1212
import rimraf from 'rimraf';
13-
1413
import { getProjectPath, getConfig } from './utils/projectHelper';
1514
import getBabelCommonConfig from './getBabelCommonConfig';
1615
import getTSCommonConfig from './getTSCommonConfig';
@@ -28,10 +27,12 @@ const packageJson = fs.readJsonSync(getProjectPath('package.json'));
2827

2928
const tsDefaultReporter = ts.reporter.defaultReporter();
3029
const cwd = process.cwd();
31-
const libDir = getProjectPath('lib');
30+
const cjsDir = getProjectPath('lib');
3231
const esDir = getProjectPath('es');
3332
const localeDir = getProjectPath('locale');
3433

34+
const libDir = process.env.LIB_DIR || 'components';
35+
3536
// FIXME: hard code, not find typescript can modify the path resolution
3637
const localeDts = `import type { Locale } from '../lib/locale';
3738
declare const localeValues: Locale;
@@ -144,18 +145,14 @@ gulp.task(
144145
})
145146
);
146147

147-
const _libDir = process.env.LIB_DIR || 'components';
148-
149148
function babelify(js: ICompileStream['js'], modules: boolean) {
150-
const babelConfig = getBabelCommonConfig(modules, {
151-
enabledReactCompiler: _libDir === 'dist',
152-
});
149+
const babelConfig = getBabelCommonConfig(modules, { enabledReactCompiler: libDir === 'dist' });
153150
delete babelConfig.cacheDirectory;
154151
if (modules === false) {
155152
babelConfig.plugins.push(replaceLib);
156153
}
157154
const stream = js.pipe(babel(babelConfig as Parameters<typeof babel>[0]));
158-
return stream.pipe(gulp.dest(modules === false ? esDir : libDir));
155+
return stream.pipe(gulp.dest(modules === false ? esDir : cjsDir));
159156
}
160157

161158
function insertUseClient() {
@@ -178,15 +175,15 @@ function insertUseClient() {
178175

179176
async function compile(modules?: boolean) {
180177
const { compile: { transformTSFile, transformFile } = {} } = await getConfig();
181-
rimraf.sync(modules !== false ? libDir : esDir);
178+
rimraf.sync(modules !== false ? cjsDir : esDir);
182179

183180
const assets = gulp
184181
.src(['components/**/*.@(png|svg|json)'])
185-
.pipe(gulp.dest(modules === false ? esDir : libDir));
182+
.pipe(gulp.dest(modules === false ? esDir : cjsDir));
186183
let error = 0;
187184

188185
// =============================== FILE ===============================
189-
let transformFileStream;
186+
let transformFileStream: NodeJS.ReadWriteStream;
190187

191188
if (transformFile) {
192189
transformFileStream = gulp
@@ -199,7 +196,7 @@ async function compile(modules?: boolean) {
199196
next();
200197
})
201198
)
202-
.pipe(gulp.dest(modules === false ? esDir : libDir));
199+
.pipe(gulp.dest(modules === false ? esDir : cjsDir));
203200
}
204201

205202
// ================================ TS ================================
@@ -252,7 +249,7 @@ async function compile(modules?: boolean) {
252249
tsResult.on('finish', check);
253250
tsResult.on('end', check);
254251
const tsFilesStream = babelify(tsResult.js, modules);
255-
const tsd = tsResult.dts.pipe(gulp.dest(modules === false ? esDir : libDir));
252+
const tsd = tsResult.dts.pipe(gulp.dest(modules === false ? esDir : cjsDir));
256253
return merge2([tsFilesStream, tsd, assets, transformFileStream].filter(s => s));
257254
}
258255

0 commit comments

Comments
 (0)