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

GH-39289: [JS] Add types to exports #39475

Merged
merged 2 commits into from
Jan 5, 2024
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
1 change: 1 addition & 0 deletions js/gulp/arrow-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export const arrowTask = ((cache) => memoizeTask(cache, function copyMain(target
const esnextUmdSourceMapsGlob = `${targetDir(`esnext`, `umd`)}/*.map`;
return ObservableForkJoin([
observableFromStreams(gulp.src(dtsGlob), gulp.dest(out)), // copy d.ts files
observableFromStreams(gulp.src(dtsGlob), gulpRename((p) => { p.extname = '.mts'; }), gulp.dest(out)), // copy d.ts files as esm
observableFromStreams(gulp.src(cjsGlob), gulp.dest(out)), // copy es2015 cjs files
observableFromStreams(gulp.src(cjsSourceMapsGlob), gulp.dest(out)), // copy es2015 cjs sourcemaps
observableFromStreams(gulp.src(esmSourceMapsGlob), gulp.dest(out)), // copy es2015 esm sourcemaps
Expand Down
38 changes: 28 additions & 10 deletions js/gulp/package-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,45 @@ const createMainPackageJson = (target, format) => (orig) => ({
type: 'commonjs',
main: `${mainExport}.node.js`,
module: `${mainExport}.node.mjs`,
types: `${mainExport}.node.d.ts`,
unpkg: `${mainExport}.es2015.min.js`,
jsdelivr: `${mainExport}.es2015.min.js`,
browser: {
[`./${mainExport}.node.js`]: `./${mainExport}.dom.js`,
[`./${mainExport}.node.mjs`]: `./${mainExport}.dom.mjs`
},
exports: {
'.': {
node: {
import: `./${mainExport}.node.mjs`,
require: `./${mainExport}.node.js`,
import: {
types: `./${mainExport}.node.d.mts`,
default: `./${mainExport}.node.mjs`,
},
require: {
types: `./${mainExport}.node.d.ts`,
default: `./${mainExport}.node.js`,
},
},
import: `./${mainExport}.dom.mjs`,
require: `./${mainExport}.dom.js`,
import: {
types: `./${mainExport}.dom.d.mts`,
default: `./${mainExport}.dom.mjs`,
},
require: {
types: `./${mainExport}.dom.d.ts`,
default: `./${mainExport}.dom.js`,
}
},
'./*': {
import: `./*.mjs`,
require: `./*.js`
}
import: {
types: `./*.d.mts`,
default: `./*.mjs`,
},
require: {
types: `./*.d.ts`,
default: `./*.js`,
},
},
},
types: `${mainExport}.node.d.ts`,
unpkg: `${mainExport}.es2015.min.js`,
jsdelivr: `${mainExport}.es2015.min.js`,
sideEffects: false,
esm: { mode: `all`, sourceMap: true }
});
Expand Down