Skip to content

Commit beb4b84

Browse files
Feature/replace micro-bundle with rollup (#131)
1 parent 4ebddb0 commit beb4b84

File tree

6 files changed

+75
-22
lines changed

6 files changed

+75
-22
lines changed

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
language: node_js
2-
node_js:
3-
- "12"
42
addons:
53
chrome: stable
6-
script:
7-
- npm run quickstart
8-
- npm run test
9-
4+
matrix:
5+
include:
6+
- node_js: "12"
7+
script: npm run quickstart && npm run test
8+
- node_js: "14"
9+
script: npm run quickstart && npm run test
1010
notifications:
1111
email:
1212
recipients:
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {execSync} from "child_process";
2+
import fs from 'fs';
3+
import * as path from "path";
4+
5+
describe('tests for the package output', () => {
6+
it('ensures that the pacakge contains the right files', () => {
7+
execSync('npm run build');
8+
const dirContents = fs.readdirSync(path.resolve(__dirname, '../dist'));
9+
10+
expect(dirContents.includes('index.js')).toBe(true);
11+
expect(dirContents.includes('index.umd.js')).toBe(true);
12+
expect(dirContents.includes('index.cjs.js')).toBe(true);
13+
expect(dirContents.includes('index.d.ts')).toBe(true);
14+
expect(dirContents.includes('package.json')).toBe(true);
15+
});
16+
});

packages/react/package.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
"author": "cloudinary",
66
"license": "MIT",
77
"repository": "https://github.com/cloudinary/frontend-frameworks",
8-
"main": "dist/index.js",
9-
"umd:main": "./dist/index.umd.js",
10-
"module": "dist/index.esm.js",
8+
"main": "index.umd.js",
9+
"module": "index.js",
10+
"types": "index.d.ts",
1111
"sideEffects": false,
12-
"source": "src/index.tsx",
1312
"engines": {
1413
"node": ">=10"
1514
},
1615
"scripts": {
17-
"build": "npm run build --prefix ../html && microbundle --format esm,umd,cjs --jsx React.createElement --compress false && cp package.json ./dist",
18-
"start": "microbundle watch --no-compress --format modern,cjs",
16+
"build": "npm run build --prefix ../html && tsc && rollup -c && cp package.json ./dist",
1917
"test": "jest",
2018
"test-coverage": "jest --coverage"
2119
},
@@ -53,14 +51,20 @@
5351
"eslint-plugin-react": "^7.17.0",
5452
"eslint-plugin-standard": "^4.0.1",
5553
"gh-pages": "^2.2.0",
56-
"microbundle": "^0.13.0",
5754
"npm-run-all": "^4.1.5",
5855
"prettier": "^2.0.4",
5956
"react": "^16.13.1",
6057
"react-dom": "^16.13.1",
6158
"react-scripts": "^3.4.1",
6259
"ts-jest": "^26.4.4",
63-
"typescript": "^3.7.5"
60+
"typescript": "^3.7.5",
61+
"@cloudinary/html": "^1.0.1",
62+
"@rollup/plugin-commonjs": "^21.0.1",
63+
"@rollup/plugin-json": "^4.1.0",
64+
"@rollup/plugin-node-resolve": "^13.1.3",
65+
"@rollup/plugin-replace": "^3.0.1",
66+
"@rollup/plugin-typescript": "^8.3.0",
67+
"rollup": "^2.66.1"
6468
},
6569
"jest": {
6670
"transformIgnorePatterns": [

packages/react/rollup.config.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import resolve from '@rollup/plugin-node-resolve';
2+
import typescript from '@rollup/plugin-typescript';
3+
import commonjs from '@rollup/plugin-commonjs';
4+
import replace from '@rollup/plugin-replace';
5+
import { version } from './package.json';
6+
7+
export default [
8+
{
9+
input: 'src/index.tsx',
10+
output: [
11+
{
12+
file: 'dist/index.umd.js',
13+
format: 'umd',
14+
name: 'CloudinaryBaseSDK'
15+
},
16+
{
17+
file: 'dist/index.js',
18+
format: 'esm'
19+
},
20+
{
21+
file: 'dist/index.cjs.js',
22+
format: 'cjs'
23+
}
24+
],
25+
plugins: [
26+
resolve(),
27+
replace({
28+
PACKAGE_VERSION_INJECTED_DURING_BUILD: version,
29+
preventAssignment: false
30+
}),
31+
typescript({ target: 'es5' }),
32+
commonjs()
33+
]
34+
}
35+
];
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from 'react'
2-
import { version } from '../../package.json';
32

43
export const SDKAnalyticsConstants = {
5-
sdkSemver: version,
4+
sdkSemver: 'PACKAGE_VERSION_INJECTED_DURING_BUILD',
65
techVersion: React.version,
76
sdkCode: 'J'
87
};

packages/react/tsconfig.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"compilerOptions": {
3-
"outDir": "dist",
43
"module": "esnext",
4+
"declarationDir" : "./dist",
55
"lib": [
66
"dom",
77
"esnext"
@@ -27,12 +27,11 @@
2727
"forceConsistentCasingInFileNames": true,
2828
"resolveJsonModule": true,
2929
"isolatedModules": true,
30-
"noEmit": true,
31-
"types": ["jest", "node"]
30+
"emitDeclarationOnly": true,
31+
"types": ["jest", "node"],
32+
"baseUrl": "src"
3233
},
33-
"include": [
34-
"src"
35-
],
34+
"include": ["src/index.tsx"],
3635
"exclude": [
3736
"node_modules",
3837
"dist",

0 commit comments

Comments
 (0)