Skip to content

Commit

Permalink
Merge pull request #132 from PostHog/module-bundling
Browse files Browse the repository at this point in the history
Bundle module.js in ES5
  • Loading branch information
macobo authored Nov 27, 2020
2 parents 4e0e7fc + 25e5ec6 commit 6e879fe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Requiring module in SSR
name: Server-side rendering and ES5

on:
- pull_request
Expand All @@ -13,7 +13,10 @@ jobs:
with:
node-version: 14

- run: yarn install && yarn build-module
- run: yarn install && yarn build-module && yarn build

- name: Run es-check to check if our bundle is ES5 compatible
run: yarn add es-check; npx es-check es5 dist/*.js

- name: Require module via node
run: cd dist; node -e "require('./module')"
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"start": "parcel watch src/loader-globals.js --out-file dist/array.js",
"serve": "parcel serve src/loader-globals.js --port 3001 --out-file dist/array.js",
"build": "parcel build src/loader-globals.js --out-file dist/array.js --no-source-maps",
"build-module": "./node_modules/.bin/rollup -i src/loader-module.js -f cjs -o dist/module.js -c rollup.config.js",
"build-module": "rollup -i src/loader-module.js -f cjs -o dist/module.js -c rollup.config.js",
"process-types": "mkdir -p dist; eslint src --ext .ts -c .eslintrc.ts.js --fix && tsc && cp -f src/*.d.ts dist/",
"lint": "eslint src --fix",
"prepublishOnly": "yarn lint && yarn test && yarn build && yarn build-module && yarn process-types",
Expand All @@ -25,6 +25,7 @@
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.1.0",
"@typescript-eslint/eslint-plugin": "^3.5.0",
Expand Down
10 changes: 4 additions & 6 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import resolve from '@rollup/plugin-node-resolve'
import babel from '@rollup/plugin-babel'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'

export default {
plugins: [
json(),
resolve({
browser: true,
main: true,
jsnext: true,
}),
resolve({ browser: true, modulesOnly: true }),
babel({ babelHelpers: 'bundled', presets: ['@babel/preset-env'] }),
],
}
4 changes: 2 additions & 2 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pkg from '../package.json'
import { version } from '../package.json'

var Config = {
DEBUG: false,
LIB_VERSION: pkg.version,
LIB_VERSION: version,
}

export default Config

0 comments on commit 6e879fe

Please sign in to comment.