diff --git a/gulpfile.cjs b/gulpfile.cjs index 8a6f459a..09b4deb0 100644 --- a/gulpfile.cjs +++ b/gulpfile.cjs @@ -1,21 +1,17 @@ const {spawn} = require('child_process'); const del = require('del'); const {promises} = require('fs'); -const {dest, series, src, task, watch} = require('gulp'); -const replace = require('gulp-replace'); +const {series, task, watch} = require('gulp'); const {EOL} = require('os'); const {delimiter, normalize, resolve} = require('path'); // Initialize the build system. -const _path = 'PATH' in process.env ? process.env.PATH : ''; +const _path = process.env.PATH ?? ''; const _vendor = resolve('node_modules/.bin'); if (!_path.includes(_vendor)) process.env.PATH = `${_vendor}${delimiter}${_path}`; /** Builds the project. */ -const esmRegex = /(export|import)\s+(.+)\s+from\s+'((?!.*\.js)\.[^']+)'/g; -task('build:fix', () => src('lib/**/*.js').pipe(replace(esmRegex, "$1 $2 from '$3.js'")).pipe(dest('lib'))); -task('build:js', () => _exec('tsc', ['--project', 'src/tsconfig.json'])); -task('build', series('build:js', 'build:fix')); +task('build', () => _exec('tsc', ['--project', 'src/tsconfig.json'])); /** Deletes all generated files and reset any saved state. */ task('clean', () => del(['build', 'doc/api', 'lib', 'var/**/*', 'web'])); diff --git a/lib/author.d.ts b/lib/author.d.ts index a5d4f811..fa8583c2 100644 --- a/lib/author.d.ts +++ b/lib/author.d.ts @@ -1,4 +1,4 @@ -import { JsonObject } from './json'; +import { JsonObject } from './json.js'; /** Represents the author of a comment. */ export declare class Author { ipAddress: string; diff --git a/lib/blog.d.ts b/lib/blog.d.ts index bc94d386..e8b0b9ed 100644 --- a/lib/blog.d.ts +++ b/lib/blog.d.ts @@ -1,4 +1,4 @@ -import { JsonObject } from './json'; +import { JsonObject } from './json.js'; /** Represents the front page or home URL transmitted when making requests. */ export declare class Blog { url?: URL | undefined; diff --git a/lib/client.d.ts b/lib/client.d.ts index a63c309a..96c687c5 100644 --- a/lib/client.d.ts +++ b/lib/client.d.ts @@ -1,7 +1,7 @@ /// import { EventEmitter } from 'events'; -import { Blog } from './blog'; -import { Comment } from './comment'; +import { Blog } from './blog.js'; +import { Comment } from './comment.js'; /** Specifies the result of a comment check. */ export declare enum CheckResult { /** The comment is not a spam (i.e. a ham). */ diff --git a/lib/comment.d.ts b/lib/comment.d.ts index e1b380d3..51e7dbb3 100644 --- a/lib/comment.d.ts +++ b/lib/comment.d.ts @@ -1,5 +1,5 @@ -import { Author } from './author'; -import { JsonObject } from './json'; +import { Author } from './author.js'; +import { JsonObject } from './json.js'; /** Represents a comment submitted by an author. */ export declare class Comment { author?: Author | undefined; diff --git a/lib/index.d.ts b/lib/index.d.ts index 1132f1b4..234d9181 100644 --- a/lib/index.d.ts +++ b/lib/index.d.ts @@ -1,5 +1,5 @@ -export * from './author'; -export * from './blog'; -export * from './client'; -export * from './comment'; -export * from './json'; +export * from './author.js'; +export * from './blog.js'; +export * from './client.js'; +export * from './comment.js'; +export * from './json.js'; diff --git a/share/api.http b/share/api.http index cdf425d0..711154f7 100644 --- a/share/api.http +++ b/share/api.http @@ -2,7 +2,7 @@ POST {{baseUrl}}/comment-check Content-Type: application/x-www-form-urlencoded -blog=https%3A%2F%2Fdev.belin.io%2Fakismet.js&comment_author=Akismet&comment_author_url=https%3A%2F%2Fdev.belin.io%2Fakismet.js&comment_content=I'm%20testing%20out%20the%20Service%20API.&comment_type=comment&is_test=true&referrer=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40cedx%2Fakismet&user_agent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64%3B%20rv%3A70.0)%20Gecko%2F20100101%20Firefox%2F70.0&user_ip=192.168.0.1&user_role=administrator +blog=https%3A%2F%2Fdocs.belin.io%2Fakismet.js&comment_author=Akismet&comment_author_url=https%3A%2F%2Fdocs.belin.io%2Fakismet.js&comment_content=I'm%20testing%20out%20the%20Service%20API.&comment_type=comment&is_test=true&referrer=https%3A%2F%2Fwww.npmjs.com%2Fpackage%2F%40cedx%2Fakismet&user_agent=Mozilla%2F5.0%20(Windows%20NT%2010.0%3B%20Win64%3B%20x64%3B%20rv%3A70.0)%20Gecko%2F20100101%20Firefox%2F70.0&user_ip=192.168.0.1&user_role=administrator ### @@ -10,6 +10,6 @@ blog=https%3A%2F%2Fdev.belin.io%2Fakismet.js&comment_author=Akismet&comment_auth POST {{baseUrl}}/comment-check Content-Type: application/x-www-form-urlencoded -blog=https%3A%2F%2Fdev.belin.io%2Fakismet.js&comment_author=viagra-test-123&comment_content=Spam!&comment_type=trackback&comment_author_email=akismet-guaranteed-spam%40example.com&is_test=true&user_ip=127.0.0.1&user_agent=Spam%20Bot%2F6.6.6 +blog=https%3A%2F%2Fdocs.belin.io%2Fakismet.js&comment_author=viagra-test-123&comment_content=Spam!&comment_type=trackback&comment_author_email=akismet-guaranteed-spam%40example.com&is_test=true&user_ip=127.0.0.1&user_agent=Spam%20Bot%2F6.6.6 ### diff --git a/src/author.ts b/src/author.ts index 1be3a42f..bedbf1d8 100644 --- a/src/author.ts +++ b/src/author.ts @@ -1,4 +1,4 @@ -import {JsonObject} from './json'; +import {JsonObject} from './json.js'; /** Represents the author of a comment. */ export class Author { diff --git a/src/blog.ts b/src/blog.ts index 98e54d43..a095440b 100644 --- a/src/blog.ts +++ b/src/blog.ts @@ -1,4 +1,4 @@ -import {JsonObject} from './json'; +import {JsonObject} from './json.js'; /** Represents the front page or home URL transmitted when making requests. */ export class Blog { diff --git a/src/client.ts b/src/client.ts index fe2024ba..c95a69db 100644 --- a/src/client.ts +++ b/src/client.ts @@ -1,9 +1,9 @@ import {EventEmitter} from 'events'; import fetch, {Response} from 'node-fetch'; -import {Blog} from './blog'; -import {Comment} from './comment'; -import {JsonObject} from './json'; -import {packageVersion} from './version.g'; +import {Blog} from './blog.js'; +import {Comment} from './comment.js'; +import {JsonObject} from './json.js'; +import {packageVersion} from './version.g.js'; /** Specifies the result of a comment check. */ export enum CheckResult { diff --git a/src/comment.ts b/src/comment.ts index a83607f5..1eee9988 100644 --- a/src/comment.ts +++ b/src/comment.ts @@ -1,5 +1,5 @@ -import {Author} from './author'; -import {JsonObject} from './json'; +import {Author} from './author.js'; +import {JsonObject} from './json.js'; /** Represents a comment submitted by an author. */ export class Comment { diff --git a/src/index.ts b/src/index.ts index 1132f1b4..234d9181 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,5 @@ -export * from './author'; -export * from './blog'; -export * from './client'; -export * from './comment'; -export * from './json'; +export * from './author.js'; +export * from './blog.js'; +export * from './client.js'; +export * from './comment.js'; +export * from './json.js'; diff --git a/src/tsconfig.json b/src/tsconfig.json index 9587e023..5d3dde28 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -8,7 +8,7 @@ "moduleResolution": "node", "outDir": "../lib", "strict": true, - "target": "es2019", + "target": "es2020", "tsBuildInfoFile": "../var/tsbuild.json" } }