Skip to content

Commit

Permalink
Switch clabe.js to es module version
Browse files Browse the repository at this point in the history
  • Loading branch information
dpilafian committed Aug 12, 2021
1 parent c4d5fdf commit 689a1c4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
26 changes: 9 additions & 17 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,37 +29,29 @@ const task = {
.pipe(header(bannerJs))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest('dist'));
const buildEsm = () =>
gulp.src('build/clabe.js')
.pipe(replace(headerComments.js, ''))
.pipe(header(bannerJs))
.pipe(replace('[VERSION]', pkg.version))
.pipe(size({ showFiles: true }))
.pipe(rename({ extname: '.esm.js' }))
.pipe(gulp.dest('dist'));
const buildUmd = () =>
gulp.src('build/umd/clabe.js')
.pipe(header(bannerJs))
.pipe(replace('[VERSION]', pkg.version))
.pipe(rename({ extname: '.umd.cjs' }))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest('dist'));
const buildJs = () =>
gulp.src('build/clabe.js')
.pipe(replace(headerComments.js, ''))
.pipe(header(bannerJs))
.pipe(replace('[VERSION]', pkg.version))
.pipe(replace(/^export { (.*) };/m, 'if (typeof window === "object") window.$1 = $1;'))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest('dist'))
.pipe(replace(/^export { (.*) };/m, 'if (typeof window === "object") window.$1 = $1;'))
.pipe(babel(babelMinifyJs))
.pipe(rename({ extname: '.min.js' }))
.pipe(header(bannerJs.replace('\n\n', '\n')))
.pipe(gap.appendText('\n'))
.pipe(size({ showFiles: true }))
.pipe(size({ showFiles: true, gzip: true }))
.pipe(gulp.dest('dist'));
return mergeStream(buildDts(), buildEsm(), buildUmd(), buildJs());
const buildUmd = () =>
gulp.src('build/umd/clabe.js')
.pipe(header(bannerJs))
.pipe(replace('[VERSION]', pkg.version))
.pipe(rename({ extname: '.umd.cjs' }))
.pipe(size({ showFiles: true }))
.pipe(gulp.dest('dist'));
return mergeStream(buildDts(), buildJs(), buildUmd());
},

};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Analyze or create a CLABE number for a Mexican bank account (written in TypeScript)",
"license": "MIT",
"type": "module",
"module": "dist/clabe.esm.js",
"module": "dist/clabe.js",
"jsdelivr": "dist/clabe.min.js",
"main": "dist/clabe.umd.cjs",
"types": "dist/clabe.d.ts",
Expand All @@ -13,7 +13,7 @@
],
"exports": {
".": {
"import": "./dist/clabe.esm.js",
"import": "./dist/clabe.js",
"require": "./dist/clabe.umd.cjs"
},
"./": "./dist/"
Expand Down
4 changes: 2 additions & 2 deletions spec/node.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@

// Imports
import { assertDeepStrictEqual } from 'assert-deep-strict-equal';
import { clabe } from '../dist/clabe.esm.js';
import { clabe } from '../dist/clabe.js';

// Setup
const mode = { type: 'ES Module', file: 'dist/clabe.esm.js' };
const mode = { type: 'ES Module', file: 'dist/clabe.js' };
const filename = import.meta.url.replace(/.*\//, ''); //jshint ignore:line

// Specification suite
Expand Down

0 comments on commit 689a1c4

Please sign in to comment.