Skip to content

Commit

Permalink
#113 polyfils excluded for browser
Browse files Browse the repository at this point in the history
  • Loading branch information
janhommes committed Oct 22, 2020
1 parent 5d8aaf4 commit 3194bd7
Show file tree
Hide file tree
Showing 7 changed files with 195 additions and 123 deletions.
5 changes: 3 additions & 2 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,16 @@ <h2 data-bind="text:LastName"></h4>
</div>

<footer class="footer">
<p>&copy; Company 2019</p>
<p>&copy; Company 2020</p>
</footer>

</div> <!-- /container -->

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/q.js"></script>
<script src="https://unpkg.com/[email protected]/dist/umd/o.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/umd/o.polyfill.js"></script>
<script src="https://unpkg.com/[email protected]/dist/umd/o.min.js"></script>
<script src="js/knockout-3.2.0.js"></script>
<script src="js/ko.bindinghandler.currency.js"></script>
<script src="browser.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion example/node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const odata = require('../dist/cjs/o.js');
const odata = require('odata');


const oHandler = odata.o('https://services.odata.org/V4/%28S%28wptr35qf3bz4kb5oatn432ul%29%29/TripPinServiceRW/', {
Expand Down
36 changes: 21 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "o.js",
"name": "odata",
"description": "o.js is a isomorphic Odata Javascript library to simplify the request of data. The main goal is to build a standalone, lightweight and easy to understand Odata lib.",
"version": "1.1.0",
"version": "1.2.1",
"main": "dist/cjs/o.js",
"browser": "dist/umd/o.js",
"module": "dist/es2015/o.js",
Expand All @@ -10,7 +10,7 @@
"node": ">=10.0"
},
"dependencies": {
"cross-fetch": "^3.0.0",
"cross-fetch": "^3.0.6",
"tslib": "^1.9.3",
"universal-url": "2.0.0"
},
Expand All @@ -28,8 +28,9 @@
"rollup-plugin-uglify-es": "0.0.1",
"ts-jest": "^26.1.0",
"tslint": "^5.12.1",
"typescript": "^3.2.2",
"whatwg-fetch": "^3.0.0"
"typescript": "^3.9.7",
"whatwg-fetch": "^3.4.1",
"url-polyfill": "^1.1.11"
},
"scripts": {
"build": "rollup --config",
Expand Down
221 changes: 127 additions & 94 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,98 +1,131 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import sourceMaps from 'rollup-plugin-sourcemaps';
import typescript from 'rollup-plugin-typescript2';
import babel from 'rollup-plugin-babel';
import uglify from 'rollup-plugin-uglify-es';
import resolve from "rollup-plugin-node-resolve";
import commonjs from "rollup-plugin-commonjs";
import sourceMaps from "rollup-plugin-sourcemaps";
import typescript from "rollup-plugin-typescript2";
import babel from "rollup-plugin-babel";
import uglify from "rollup-plugin-uglify-es";

const pkg = require('./package.json');
const pkg = require("./package.json");

export default [{
input: `src/o.ts`,
output: [{
file: pkg.browser.replace(".js", ".min.js"),
name: 'odata',
format: 'umd',
sourcemap: true,
export default [
{
input: `src/o.ts`,
output: [
{
file: pkg.browser.replace(".js", ".min.js"),
name: "odata",
format: "umd",
sourcemap: true,
},
{
file: pkg.module,
format: "es",
sourcemap: true,
},
],
plugins: [
typescript({
useTsconfigDeclarationDir: true,
}),
commonjs(),
resolve({
browser: true,
}),
babel({
exclude: "node_modules/**",
}),
uglify(),
sourceMaps(),
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: "src/**",
},
{
file: pkg.module,
format: 'es',
sourcemap: true,
}
],
plugins: [
typescript({
useTsconfigDeclarationDir: true
}),
commonjs(),
resolve({
browser: true
}),
babel({
exclude: 'node_modules/**'
}),
uglify(),
sourceMaps(),
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: 'src/**',
}
},{
input: `src/o.ts`,
output: [{
file: pkg.browser,
name: 'odata',
format: 'umd',
sourcemap: true,
},
{
input: `src/o.ts`,
output: [
{
file: pkg.browser,
name: "odata",
format: "umd",
sourcemap: true,
},
{
file: pkg.module,
format: "es",
sourcemap: true,
},
],
plugins: [
typescript({
useTsconfigDeclarationDir: true,
}),
commonjs(),
resolve({
browser: true,
}),
babel({
exclude: "node_modules/**",
}),
sourceMaps(),
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: "src/**",
},
{
file: pkg.module,
format: 'es',
sourcemap: true,
}
],
plugins: [
typescript({
useTsconfigDeclarationDir: true
}),
commonjs(),
resolve({
browser: true
}),
babel({
exclude: 'node_modules/**'
}),
sourceMaps(),
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: 'src/**',
}
}, {
input: `src/o.ts`,
output: [{
file: pkg.main,
name: 'odata',
format: 'cjs',
sourcemap: true,
}],
plugins: [
typescript({
useTsconfigDeclarationDir: true,
noResolve: true
}),
resolve({
browser: false
}),
sourceMaps(),
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: 'src/**',
}
}]
},
{
input: `src/o.ts`,
output: [
{
file: pkg.main,
name: "odata",
format: "cjs",
sourcemap: true,
},
],
plugins: [
typescript({
useTsconfigDeclarationDir: true,
noResolve: true,
}),
resolve({
browser: false,
}),
sourceMaps(),
],
// Indicate here external modules you don't wanna include in your bundle (i.e.: 'lodash')
external: [],
watch: {
include: "src/**",
},
},
{
input: `src/o.polyfill.ts`,
output: [
{
file: 'dist/umd/o.polyfill.js',
name: "o.polyfill",
format: "umd",
sourcemap: true,
},
],
plugins: [
typescript({
useTsconfigDeclarationDir: true,
}),
commonjs(),
resolve({
browser: true,
}),
uglify(),
sourceMaps(),
],
watch: {
include: "src/**",
},
},
];
2 changes: 2 additions & 0 deletions src/o.polyfill.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import "url-polyfill";
import "whatwg-fetch";
Loading

0 comments on commit 3194bd7

Please sign in to comment.