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

fix: disable esModuleInterop #375

Open
wants to merge 7 commits into
base: current
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 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
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Worker, MessageChannel, MessagePort, receiveMessageOnPort } from 'worker_threads';
import { once } from 'events';
import EventEmitterAsyncResource from 'eventemitter-asyncresource';
import EventEmitterAsyncResource = require('eventemitter-asyncresource');
import { AsyncResource } from 'async_hooks';
import { cpus } from 'os';
import { fileURLToPath, URL } from 'url';
import { resolve } from 'path';
import { inspect, types } from 'util';
import assert from 'assert';
import assert = require('assert');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can change the way this is imported as discussed in #374 ?

import { Histogram, build } from 'hdr-histogram-js';
import { performance } from 'perf_hooks';
import hdrobj from 'hdr-histogram-percentiles-obj';
Expand Down
2 changes: 1 addition & 1 deletion test/abort-task.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AbortController } from 'abort-controller';
import { EventEmitter } from 'events';
import Piscina from '..';
import Piscina = require('..');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's tackle this differently, by exporting Piscina in different manners by exporting it as default, and named export.

Otherwise, this can potentially break the current user's expectations if esModuleInterop is set to false. Wdyt?

Copy link
Contributor Author

@SimenB SimenB Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the default export created by TS work as an actual default export in Node? The current one does as it's just module.exports =

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If exported by default, it will export it as module.exports.default = Piscina, if by named export, it translates to module.Piscina = Piscina. If just used as export Piscina, it just does module.exports = Piscina.

Exporting it as default, and named will enable imports like:

  • import { Piscina } from 'piscina'
  • import Piscina, { SomeType } from 'piscina'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems #517 did this 👍

import { test } from 'tap';
import { resolve } from 'path';

Expand Down
2 changes: 1 addition & 1 deletion test/async-context.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createHook, executionAsyncId } from 'async_hooks';
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';
import { resolve } from 'path';

Expand Down
2 changes: 1 addition & 1 deletion test/atomics-optimization.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';
import { resolve } from 'path';

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/console-log.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '../..';
import Piscina = require('../..');
import { resolve } from 'path';

const pool = new Piscina({
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/move.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '../..';
import Piscina = require('../..');
import assert from 'assert';
import { types } from 'util';

Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/simple-isworkerthread.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '../..';
import Piscina = require('../..');
import assert from 'assert';

assert.strictEqual(Piscina.isWorkerThread, true);
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/simple-workerdata.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '../..';
import Piscina = require('../..');
import assert from 'assert';

assert.strictEqual(Piscina.workerData, 'ABC');
Expand Down
2 changes: 1 addition & 1 deletion test/histogram.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';
import { resolve } from 'path';

Expand Down
2 changes: 1 addition & 1 deletion test/idle-timeout.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';
import { resolve } from 'path';
import { promisify } from 'util';
Expand Down
2 changes: 1 addition & 1 deletion test/messages.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '../dist/src';
import Piscina = require('../dist/src');
import { test } from 'tap';
import { resolve } from 'path';
import { once } from 'events';
Expand Down
2 changes: 1 addition & 1 deletion test/move-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import {
isMovable,
markMovable,
Expand Down
2 changes: 1 addition & 1 deletion test/nice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { resolve } from 'path';
import { test } from 'tap';

Expand Down
2 changes: 1 addition & 1 deletion test/option-validation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';

test('filename cannot be non-null/non-string', async ({ throws }) => {
Expand Down
2 changes: 1 addition & 1 deletion test/pool-destroy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';
import { resolve } from 'path';

Expand Down
2 changes: 1 addition & 1 deletion test/post-task.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MessageChannel } from 'worker_threads';
import { cpus } from 'os';
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';
import { resolve } from 'path';

Expand Down
2 changes: 1 addition & 1 deletion test/simple-test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';
import { version } from '../package.json';
import { pathToFileURL } from 'url';
Expand Down
2 changes: 1 addition & 1 deletion test/task-queue.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';
import { resolve } from 'path';
import { Task, TaskQueue } from '../dist/src/common';
Expand Down
2 changes: 1 addition & 1 deletion test/test-is-buffer-transferred.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '../dist/src';
import Piscina = require('../dist/src');
import { test } from 'tap';
import { resolve } from 'path';

Expand Down
2 changes: 1 addition & 1 deletion test/test-resourcelimits.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';
import { resolve } from 'path';

Expand Down
2 changes: 1 addition & 1 deletion test/test-uncaught-exception-from-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { test } from 'tap';
import { resolve } from 'path';
import { once } from 'events';
Expand Down
2 changes: 1 addition & 1 deletion test/thread-count.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Piscina from '..';
import Piscina = require('..');
import { cpus } from 'os';
import { test } from 'tap';
import { resolve } from 'path';
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"noUnusedParameters": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"esModuleInterop": false,

"resolveJsonModule": true, /* Include modules imported with '.json' extension */
"forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */
Expand Down