Skip to content

Commit 56ca7b8

Browse files
authored
Merge pull request #463 from Inist-CNRS/esm
Esm everywhere
2 parents d9af929 + b7a2dae commit 56ca7b8

22 files changed

+118
-94
lines changed

packages/basics/test/basics.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
const assert = require('assert');
2-
const from = require('from');
3-
const { PassThrough } = require('stream');
4-
const ezs = require('../../core/src');
1+
import assert from 'assert';
2+
import { PassThrough } from 'stream';
3+
import fs from 'fs';
4+
import from from 'from';
5+
import ezs from '../../core/src';
6+
import statements from '../src';
7+
8+
ezs.use(statements);
59

6-
ezs.use(require('../src'));
710

811
describe('test', () => {
912
it('CSVObject #1', (done) => {

packages/basics/test/tar-dump.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const assert = require('assert');
2-
const from = require('from');
3-
const ezs = require('../../core/src');
1+
import assert from 'assert';
2+
import from from 'from';
3+
import ezs from '../../core/src';
4+
import ezsBasics from '../src';
45

5-
ezs.use(require('../src'));
6+
ezs.use(ezsBasics);
67

78
describe('TARDump', () => {
89
const input = [

packages/basics/test/tar-extract.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
const assert = require('assert');
2-
const fs = require('fs');
3-
const ezs = require('../../core/src');
1+
import assert from 'assert';
2+
import fs from 'fs';
3+
import ezs from '../../core/src';
4+
import ezsBasics from '../src';
45

5-
ezs.use(require('../src'));
6+
ezs.use(ezsBasics);
67

78
describe('TARExtract', () => {
89
it('should extract JSON content (manual)', (done) => {

packages/basics/test/txt-zip.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
const assert = require('assert');
2-
const from = require('from');
3-
const pako = require('pako');
4-
const ezs = require('../../core/src');
1+
import assert from 'assert';
2+
import from from 'from';
3+
import pako from 'pako';
4+
import ezs from '../../core/src';
5+
import ezsBasics from '../src';
56

6-
ezs.use(require('../src'));
7+
ezs.use(ezsBasics);
78

89
describe('txt-zip', () => {
910
it('should zip a stream containing a string', (done) => {

packages/basics/test/zip-extract.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
const assert = require('assert');
2-
const fs = require('fs');
3-
const ezs = require('../../core/src');
1+
import assert from 'assert';
2+
import fs from 'fs';
3+
import from from 'from';
4+
import ezs from '../../core/src';
5+
import ezsBasics from '../src';
46

5-
ezs.use(require('../src'));
7+
ezs.use(ezsBasics);
68

79
describe('ZIPExtract', () => {
810
it('should extract JSON content', (done) => {

packages/core/src/constants.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import filenameRegex from 'filename-regex';
2-
import { version } from '../package.json';
2+
import pckg from '../package.json' with { type: 'json' };
33

44
export const VERBOSE = 'ezs:*,-ezs:debug,-ezs:trace';
5-
export const VERSION = version;
5+
export const VERSION = pckg.version;
66
export const STARTED_AT = Date.now();
77
export const RX_FILENAME = filenameRegex();

packages/core/src/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,5 @@ ezs.createTrap = (file, env) => {
150150
};
151151
ezs.use(Statements);
152152

153-
module.exports = ezs;
153+
//module.exports = ezs;
154+
export default ezs;

packages/core/src/server/errorHandler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import debug from 'debug';
22
import JSONB from 'json-buffer';
3-
import { httpRequestErrorTotal } from './metrics';
3+
import { httpRequestErrorTotal } from './metrics.js';
44

55
const errorHandler = (ezs, request, response) => (error, code = 400) => {
66
const stringError = ezs.serializeError(error);

packages/core/src/server/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ import eos from 'end-of-stream';
55
import controlServer from 'http-shutdown';
66
import { parse } from 'url';
77
import debug from 'debug';
8-
import knownPipeline from './knownPipeline';
9-
import serverInformation from './serverInformation';
10-
import serverControl from './serverControl';
11-
import errorHandler from './errorHandler';
12-
import settings from '../settings';
13-
import { RX_FILENAME } from '../constants';
8+
import knownPipeline from './knownPipeline.js';
9+
import serverInformation from './serverInformation.js';
10+
import serverControl from './serverControl.js';
11+
import errorHandler from './errorHandler.js';
12+
import settings from '../settings.js';
13+
import { RX_FILENAME } from '../constants.js';
1414
import {
1515
metrics,
1616
httpConnectionTotal,
1717
httpConnectionOpen,
1818
httpRequestDurationMicroseconds,
1919
aggregatorRegistry,
20-
} from './metrics';
20+
} from './metrics.js';
2121
import {
2222
createFusible,
2323
enableFusible,
2424
disableFusible
25-
} from '../fusible';
25+
} from '../fusible.js';
2626

2727
function isPipeline() {
2828
const f = this.pathName.match(RX_FILENAME);

packages/core/src/server/knownPipeline.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import { pipeline } from 'stream';
66
import once from 'once';
77
import merge from 'lodash/merge.js';
88
import cloneDeep from 'lodash/cloneDeep.js';
9-
import { metricsHandle } from './metrics';
10-
import errorHandler from './errorHandler';
11-
import { isFile } from '../file';
12-
import breaker from '../statements/breaker';
13-
import settings from '../settings';
9+
import { metricsHandle } from './metrics.js';
10+
import errorHandler from './errorHandler.js';
11+
import { isFile } from '../file.js';
12+
import breaker from '../statements/breaker.js';
13+
import settings from '../settings.js';
1414

1515
const dispositionFrom = ({ extension }) => (extension ? `attachment; filename="dump.${extension}"` : 'inline');
1616

0 commit comments

Comments
 (0)