Skip to content

Commit 1904567

Browse files
committed
feat(parser-adapter-asyncapi-yaml-2): convert to ESM
Refs #930
1 parent e4ce197 commit 1904567

File tree

8 files changed

+24
-29
lines changed

8 files changed

+24
-29
lines changed

packages/apidom-parser-adapter-asyncapi-yaml-2/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/cjs
44
/types
55
/NOTICE
6+
/swagger-api-apidom-parser-adapter-asyncapi-yaml-2-*.tgz

packages/apidom-parser-adapter-asyncapi-yaml-2/.mocharc.js

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recursive": true,
3+
"spec": "test/**/*.ts",
4+
"file": ["test/mocha-bootstrap.cjs"]
5+
}

packages/apidom-parser-adapter-asyncapi-yaml-2/config/webpack/browser.config.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
'use strict';
2-
3-
const path = require('path');
4-
const { nonMinimizeTrait, minimizeTrait } = require('./traits.config');
1+
import path from 'node:path';
2+
import { nonMinimizeTrait, minimizeTrait } from './traits.config.js';
53

64
const browser = {
75
mode: 'production',
@@ -87,4 +85,4 @@ const browserMin = {
8785
...minimizeTrait,
8886
};
8987

90-
module.exports = [browser, browserMin];
88+
export default [browser, browserMin];

packages/apidom-parser-adapter-asyncapi-yaml-2/config/webpack/traits.config.js

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1-
'use strict';
1+
import webpack from 'webpack';
2+
import TerserPlugin from 'terser-webpack-plugin';
23

3-
const webpack = require('webpack');
4-
const TerserPlugin = require('terser-webpack-plugin');
5-
6-
const nonMinimizeTrait = {
4+
export const nonMinimizeTrait = {
75
optimization: {
86
minimize: false,
97
usedExports: false,
108
concatenateModules: false,
119
},
1210
};
1311

14-
const minimizeTrait = {
12+
export const minimizeTrait = {
1513
plugins: [
1614
new webpack.LoaderOptionsPlugin({
1715
minimize: true,
@@ -32,8 +30,3 @@ const minimizeTrait = {
3230
],
3331
},
3432
};
35-
36-
module.exports = {
37-
nonMinimizeTrait,
38-
minimizeTrait,
39-
};

packages/apidom-parser-adapter-asyncapi-yaml-2/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,24 @@
55
"publishConfig": {
66
"registry": "https://npm.pkg.github.com"
77
},
8-
"main": "cjs/adapter.js",
9-
"module": "es/adapter.js",
10-
"jsnext:main": "es/adapter.js",
8+
"type": "module",
119
"unpkg": "dist/apidom-parser-apdater-asyncapi-yaml-2.browser.min.js",
10+
"exports": {
11+
"import": "./es/adapter.js",
12+
"require": "./cjs/adapter.cjs"
13+
},
1214
"types": "types/adapter.d.ts",
1315
"scripts": {
1416
"build": "npm run clean && run-p --max-parallel ${CPU_CORES:-2} typescript:declaration build:es build:cjs build:umd:browser",
1517
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es --extensions '.ts' --root-mode 'upward'",
16-
"build:cjs": "cross-env BABEL_ENV=cjs babel src --out-dir cjs --extensions '.ts' --root-mode 'upward'",
18+
"build:cjs": "cross-env BABEL_ENV=cjs-new babel src --out-dir cjs --extensions '.ts' --out-file-extension '.cjs' --root-mode 'upward'",
1719
"build:umd:browser": "cross-env BABEL_ENV=browser BROWSERSLIST_ENV=production webpack --config config/webpack/browser.config.js --progress",
1820
"lint": "eslint ./",
1921
"lint:fix": "eslint ./ --fix",
2022
"clean": "rimraf ./es ./cjs ./dist ./types",
2123
"typescript:check-types": "tsc --noEmit",
2224
"typescript:declaration": "tsc -p declaration.tsconfig.json",
23-
"test": "cross-env BABEL_ENV=cjs mocha",
25+
"test": "cross-env NODE_ENV=test BABEL_ENV=cjs-new mocha",
2426
"perf": "cross-env BABEL_ENV=cjs node ./test/perf/index.js",
2527
"perf:lexical-analysis": "cross-env BABEL_ENV=cjs node ./test/perf/lexical-analysis.js",
2628
"perf:syntactic-analysis": "cross-env BABEL_ENV=cjs node ./test/perf/syntactic-analysis.js",

packages/apidom-parser-adapter-asyncapi-yaml-2/test/.eslintrc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@
2727
"mocha/no-exclusive-tests": 2
2828
},
2929
"overrides": [{
30-
"files": ["mocha-bootstrap.js"],
30+
"files": ["mocha-bootstrap.cjs"],
3131
"parserOptions": {
3232
"sourceType": "script"
33+
},
34+
"rules": {
35+
"@typescript-eslint/no-var-requires": 0
3336
}
3437
}]
3538
}
File renamed without changes.

0 commit comments

Comments
 (0)