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

build: es6 #6720

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
dist/
es/
Copy link
Member

Choose a reason for hiding this comment

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

we should also add es/ to .gitignore

15 changes: 15 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ module.exports = {
"@babel/proposal-class-properties",
"@babel/proposal-object-rest-spread",
"@babel/plugin-proposal-optional-chaining",
[
"babel-plugin-module-resolver",
{
"alias": {
"root": ".",
"components": "./src/core/components",
"containers": "./src/core/containers",
"core": "./src/core",
"plugins": "./src/plugins",
"img": "./src/img",
"corePlugins": "./src/core/plugins",
"less": "./src/less"
}
}
]
]
},
"es": {
Expand Down
7 changes: 7 additions & 0 deletions config/jest/jest.artifact-es.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const path = require('path');

module.exports = {
rootDir: path.join(__dirname, '..', '..'),
testEnvironment: 'jsdom',
testMatch: ['**/test/build-artifacts/es.js'],
};
1 change: 1 addition & 0 deletions config/jest/jest.unit.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');

module.exports = {
rootDir: path.join(__dirname, '..', '..'),
moduleDirectories: ['node_modules', 'src'],
testEnvironment: 'jsdom',
testMatch: [
'**/test/unit/*.js?(x)',
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "swagger-ui",
"version": "3.38.0",
"main": "dist/swagger-ui.js",
"module": "dist/swagger-ui-es-bundle.js",
"module": "es/index.js",
"homepage": "https://github.com/swagger-api/swagger-ui",
"repository": "[email protected]:swagger-api/swagger-ui.git",
"contributors": [
Expand All @@ -24,6 +24,7 @@
"build-stylesheets": "webpack --colors --config webpack/stylesheets.babel.js",
"build:es:bundle": "webpack --colors --config webpack/es-bundle.babel.js",
"build:es:bundle:core": "webpack --colors --config webpack/es-bundle-core.babel.js",
"build:es": "cross-env BABEL_ENV=es babel src --out-dir es",
"predev": "npm install",
"dev": "webpack-dev-server --config webpack/dev.babel.js",
"deps-license": "license-checker --production --csv --out $npm_package_config_deps_check_dir/licenses.csv && license-checker --development --csv --out $npm_package_config_deps_check_dir/licenses-dev.csv",
Expand All @@ -41,6 +42,7 @@
"test:artifact:umd:bundle": "npm run build-bundle && cross-env BABEL_ENV=commonjs jest --config ./config/jest/jest.artifact-umd-bundle.config.js",
"test:artifact:es:bundle": "npm run build:es:bundle && cross-env BABEL_ENV=commonjs jest --config ./config/jest/jest.artifact-es-bundle.config.js",
"test:artifact:es:bundle:core": "npm run build:es:bundle:core && cross-env BABEL_ENV=commonjs jest --config ./config/jest/jest.artifact-es-bundle-core.config.js",
"test:artifact:es": "npm run build:es && cross-env BABEL_ENV=commonjs jest --config ./config/jest/jest.artifact-es.config.js",
"test:unit-jest": "cross-env BABEL_ENV=test jest --config ./config/jest/jest.unit.config.js",
"e2e-initial-render": "nightwatch test/e2e-selenium/scenarios/ --config test/e2e-selenium/nightwatch.json --group initial-render",
"mock-api": "json-server --watch test/e2e-selenium/db.json --port 3204",
Expand Down
8 changes: 8 additions & 0 deletions test/build-artifacts/es.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { describe, expect, test } from '@jest/globals';
import SwaggerUI from '../../es';

describe('webpack browser es build', () => {
test('should export a function for es-bundle', () => {
expect(SwaggerUI).toBeInstanceOf(Function);
});
});