From 689a1c48ab560ac7ea7f4b6a5d145d358b73ee85 Mon Sep 17 00:00:00 2001 From: dpilafian Date: Thu, 12 Aug 2021 04:04:26 -0700 Subject: [PATCH] Switch clabe.js to es module version --- gulpfile.js | 26 +++++++++----------------- package.json | 4 ++-- spec/node.spec.js | 4 ++-- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 3fe2683..931958b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -29,29 +29,14 @@ 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'))) @@ -59,7 +44,14 @@ const task = { .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()); }, }; diff --git a/package.json b/package.json index 4bd5e49..23bfe17 100644 --- a/package.json +++ b/package.json @@ -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", @@ -13,7 +13,7 @@ ], "exports": { ".": { - "import": "./dist/clabe.esm.js", + "import": "./dist/clabe.js", "require": "./dist/clabe.umd.cjs" }, "./": "./dist/" diff --git a/spec/node.spec.js b/spec/node.spec.js index e38ee16..4ff7b4a 100644 --- a/spec/node.spec.js +++ b/spec/node.spec.js @@ -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