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

Package distribution as UMD #43

Merged
merged 8 commits into from
Mar 30, 2020
Merged
Show file tree
Hide file tree
Changes from 5 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
46 changes: 16 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@labkey/api",
"version": "0.0.42",
"version": "0.0.43-fb-umd-no-rollup.0",
"description": "JavaScript client API for LabKey Server",
"scripts": {
"build": "npm run build:dist && npm run build:docs",
"build:dist": "npm run clean && webpack --config webpack.config.js && rollup -c",
"build:dist": "npm run clean && webpack --config webpack.config.js",
"build:docs": "npm run clean:docs && typedoc --options typedoc.js ./src/labkey && touch docs/.nojekyll",
"clean": "rimraf dist && npm run clean:docs",
"clean:docs": "rimraf docs",
Expand All @@ -19,12 +19,11 @@
"labkey",
"javascript"
],
"main": "dist/labkey-api-js-core.cjs.js",
"module": "dist/labkey-api-js-core.es.js",
"types": "dist/labkey.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"author": {
"name": "Nick Kerr",
"email": "nicka@labkey.com",
"email": "nickk@labkey.com",
"url": "https://www.labkey.org"
},
"repository": {
Expand All @@ -36,24 +35,20 @@
"registry": "https://artifactory.labkey.com/artifactory/api/npm/libs-client"
},
"devDependencies": {
"@babel/core": "7.8.4",
"@rollup/plugin-node-resolve": "7.1.1",
"@types/jest": "25.1.3",
"@babel/core": "7.9.0",
"@types/jest": "25.1.4",
"@types/sinon": "7.5.2",
"cross-env": "7.0.0",
"cross-env": "7.0.2",
"gh-pages": "2.2.0",
"jest": "25.1.0",
"jest": "25.2.3",
"jest-teamcity-reporter": "0.9.0",
"rimraf": "3.0.2",
"rollup": "1.31.1",
"rollup-plugin-babel": "4.3.3",
"rollup-plugin-typescript2": "0.26.0",
"sinon": "9.0.0",
"sinon": "9.0.1",
"ts-jest": "25.2.1",
"ts-loader": "6.2.1",
"typedoc": "0.16.10",
"typescript": "3.8.2",
"webpack": "4.41.6",
"ts-loader": "6.2.2",
"typedoc": "0.17.3",
"typescript": "3.8.3",
"webpack": "4.42.1",
"webpack-cli": "3.3.11"
},
"jest": {
Expand All @@ -69,16 +64,7 @@
"ts",
"js"
],
"moduleDirectories": [
"node_modules"
],
"testPathIgnorePatterns": [
"/node_modules/"
],
"testRegex": "(\\.(spec))\\.(ts)$",
"testURL": "http://localhost",
"transform": {
"^.+\\.ts?$": "ts-jest"
}
"preset": "ts-jest",
"testRegex": "(\\.(spec))\\.(ts)$"
}
}
52 changes: 0 additions & 52 deletions rollup.config.js

This file was deleted.

File renamed without changes.
24 changes: 24 additions & 0 deletions src/labkey/dom/Utils.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright (c) 2020 LabKey Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { loadDOMContext } from './constants';

describe('loadDOMContext', () => {

it('Error without jQuery', () => {
const { $ } = loadDOMContext();
expect(() => { $(); }).toThrowError('jQuery');
});
});
4 changes: 3 additions & 1 deletion src/labkey/dom/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ if (typeof jQuery !== 'undefined') {
LABKEY.$ = jQuery;
}
else {
console.warn('jQuery not available. When using the DOM version of the LabKey API jQuery is expected to be available.');
LABKEY.$ = () => {
throw new Error('jQuery not available. When using the DOM version of the LabKey API jQuery is expected to be available.');
};
}

export function loadDOMContext(): LabKeyDOM {
Expand Down
2 changes: 1 addition & 1 deletion src/wrapper-dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This is not a part of the API definition and SHOULD NOT define any APIs. Additionally,
* this file SHOULD NOT export anything.
*/
import * as API from './labkey'
import * as API from './index'
import * as DOM from './labkey/dom/index'
import * as __package__ from './package'

Expand Down
2 changes: 1 addition & 1 deletion src/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* This is not a part of the API definition and SHOULD NOT define any APIs. Additionally,
* this file SHOULD NOT export anything.
*/
import * as API from './labkey'
import * as API from './index'
import * as __package__ from './package'

declare let LABKEY: any;
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"moduleResolution": "node",
"noEmit": false,
"noImplicitAny": true,
"removeComments": true,
"removeComments": false,
"resolveJsonModule": true,
"rootDir": "src",
"sourceMap": false,
"sourceMap": true,
"target": "ES5"
}
}
58 changes: 56 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0
*/
'use strict';
const path = require('path');

module.exports = {
const apiGlobalConfig = {

mode: 'production',

Expand Down Expand Up @@ -41,4 +42,57 @@ module.exports = {
resolve: {
extensions: [ '.ts' ]
}
};
};

const umdPackageConfig = {

entry: './src/index.ts',

mode: 'production',

target: 'web',

devtool: 'source-map',

module: {
rules: [
{
test: /^(?!.*spec\.ts?$).*\.ts?$/,
loaders: [{
loader: 'ts-loader',
options: {
compilerOptions: {
outDir: path.resolve(__dirname, 'dist'),
declaration: true,
removeComments: true,
target: 'ES6',
},
onlyCompileBundledFiles: true
}
}],
exclude: /node_modules/
}
]
},

optimization: {
// don't minimize the code from components, module/app usages will be doing that if they want to
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// don't minimize the code from components, module/app usages will be doing that if they want to
// don't minimize; module/app usages will be doing that if they want to

minimize: false
},

output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js',
library: '@labkey/api',
libraryTarget: 'umd'
},

resolve: {
extensions: [ '.ts' ]
}
};

module.exports = [
apiGlobalConfig,
umdPackageConfig
];
Loading