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

feat: add a script to prepend the use client directive #466

Merged
merged 3 commits into from
Oct 26, 2023
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
21 changes: 15 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ const less = require('gulp-less');
const postcss = require('gulp-postcss');
const sourcemaps = require('gulp-sourcemaps');
const rename = require('gulp-rename');
const insert = require('gulp-insert');
const gulp = require('gulp');
const babelrc = require('./babel.config.js');
const STYLE_SOURCE_DIR = './src/less';
const STYLE_DIST_DIR = './dist/css';
const TS_SOURCE_DIR = ['./src/**/*.tsx', './src/**/*.ts', '!./src/**/*.d.ts'];
const ESM_DIR = './es';
const LIB_DIR = './lib';
const CJS_DIR = './lib';
const DIST_DIR = './dist';

function buildLess() {
Expand All @@ -36,7 +37,14 @@ function buildCSS() {
}

function buildLib() {
return gulp.src(TS_SOURCE_DIR).pipe(babel(babelrc())).pipe(gulp.dest(LIB_DIR));
return (
gulp
.src(TS_SOURCE_DIR)
.pipe(babel(babelrc()))
// adds the 'use-client' directive to /lib exported from rsuite-talbe
.pipe(insert.prepend(`'use client';\n`))
.pipe(gulp.dest(CJS_DIR))
);
}

function buildEsm() {
Expand All @@ -48,18 +56,19 @@ function buildEsm() {
NODE_ENV: 'esm'
})
)
)
) // adds the 'use-client' directive to /es exported from rsuite-talbe
.pipe(insert.prepend(`'use client';\n`))
.pipe(gulp.dest(ESM_DIR));
}

function copyTypescriptDeclarationFiles() {
return gulp.src('./src/**/*.d.ts').pipe(gulp.dest(LIB_DIR)).pipe(gulp.dest(ESM_DIR));
return gulp.src('./src/**/*.d.ts').pipe(gulp.dest(CJS_DIR)).pipe(gulp.dest(ESM_DIR));
}

function copyLessFiles() {
return gulp
.src(['./src/**/*.less', './src/**/fonts/**/*'])
.pipe(gulp.dest(LIB_DIR))
.pipe(gulp.dest(CJS_DIR))
.pipe(gulp.dest(ESM_DIR));
}

Expand All @@ -68,7 +77,7 @@ function copyFontFiles() {
}

function clean(done) {
del.sync([LIB_DIR, ESM_DIR, DIST_DIR], { force: true });
del.sync([CJS_DIR, ESM_DIR, DIST_DIR], { force: true });
done();
}

Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"build:gulp": "gulp build",
"build:types": "npx tsc --emitDeclarationOnly --outDir lib && npx tsc --emitDeclarationOnly --outDir es",
"build:docs": "rm -rf assets && NODE_ENV=production webpack",
"postbuild": "mocha test/build.test.js",
"dev": "webpack serve --mode development --port 3100 --host 0.0.0.0 --progress",
"publish:docs": "node docs/gh-pages.js",
"tdd": "cross-env NODE_ENV=test karma start",
Expand Down Expand Up @@ -98,6 +99,7 @@
"gh-pages": "^0.12.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-insert": "^0.5.0",
"gulp-less": "^5.0.0",
"gulp-postcss": "^7.0.1",
"gulp-rename": "^1.2.2",
Expand Down
Loading
Loading