Skip to content

Commit

Permalink
fix: bundles all bulba code into cdn script
Browse files Browse the repository at this point in the history
  • Loading branch information
geotrev committed Feb 12, 2022
1 parent 98472a4 commit 76bc388
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 32 deletions.
13 changes: 8 additions & 5 deletions package-lock.json

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

8 changes: 4 additions & 4 deletions packages/element/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<p align="center">Write intuitive, deterministic, and extendable web components.</p>
<br>
<p align="center">
<a href="https://www.npmjs.com/package/bulba"><img src="https://img.shields.io/npm/v/bulba.svg?sanitize=true&style=flat-square" alt="Version"></a>
<a href="https://github.com/geotrev/bulba/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/bulba.svg?sanitize=true&style=flat-square" alt="License"></a>
<a href="https://www.npmjs.com/package/@bulba%2Felement"><img src="https://img.shields.io/npm/v/@bulba%2Felement.svg?sanitize=true&style=flat-square" alt="Version"></a>
<a href="https://github.com/geotrev/bulba/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@bulba%2Felement.svg?sanitize=true&style=flat-square" alt="License"></a>
<a href="https://github.com/geotrev/bulba/actions/workflows/test.yml?query=branch%3Amain"><img src="https://badgen.net/github/checks/geotrev/bulba/main?style=flat-square" alt="CI status" /></a>
<a href="https://bundlephobia.com/package/bulba"><img src="https://badgen.net/bundlephobia/minzip/bulba?style=flat-square" alt="bundle size" /></a>
<a href="https://www.libraries.io/npm/bulba"><img src="https://img.shields.io/librariesio/release/npm/bulba" alt="dependency status" /></a>
<a href="https://bundlephobia.com/package/@bulba%2Felement"><img src="https://badgen.net/bundlephobia/minzip/@bulba%2Felement?style=flat-square" alt="bundle size" /></a>
<a href="https://www.libraries.io/npm/@bulba%2Felement"><img src="https://img.shields.io/librariesio/release/npm/@bulba%2Felement" alt="dependency status" /></a>
</p>

<p align="center"><a href="https://todo-bulba-jsx.netlify.app/"><big>See Bulba in action!</big></a></p>
Expand Down
48 changes: 27 additions & 21 deletions packages/element/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
import getBaseConfig from "../../config/rollup.base.config"
import alias from "@rollup/plugin-alias"
import path from "path"
import getBaseConfig from "../../config/rollup.base.config"

const { baseConfig, terserPlugin, replacePlugin, Environments, plugins } =
getBaseConfig(process.cwd(), "Bulba")

const GLOBAL_NAME = "Bulba"
const moduleAliases = {
"@bulba/jsx": "../jsx/src/index.js",
"@bulba/template": "../template/src/index.js",
"@bulba/utils": "../utils/src/index.js",
}

function createDistConfigs() {
const external = [
"@bulba/element",
"@bulba/jsx",
"@bulba/template",
"@bulba/utils",
]
const baseDistOutput = {
format: "umd",
name: GLOBAL_NAME,
globals: {
"@bulba/element": GLOBAL_NAME,
"@bulba/jsx": GLOBAL_NAME,
"@bulba/template": GLOBAL_NAME,
"@bulba/utils": GLOBAL_NAME,
},
}

return [
Expand All @@ -32,8 +26,11 @@ function createDistConfigs() {
file: path.resolve(process.cwd(), "dist/bulba-jsx.js"),
sourcemap: true,
},
external,
plugins: [...plugins, replacePlugin(Environments.DEVELOPMENT)],
plugins: [
...plugins,
alias({ entries: moduleAliases }),
replacePlugin(Environments.DEVELOPMENT),
],
},
{
input: path.resolve(process.cwd(), "src/bundle-jsx.js"),
Expand All @@ -43,8 +40,11 @@ function createDistConfigs() {
sourcemap: true,
plugins: [terserPlugin],
},
external,
plugins: [...plugins, replacePlugin(Environments.PRODUCTION)],
plugins: [
...plugins,
alias({ entries: moduleAliases }),
replacePlugin(Environments.PRODUCTION),
],
},
{
input: path.resolve(process.cwd(), "src/bundle-template.js"),
Expand All @@ -53,8 +53,11 @@ function createDistConfigs() {
file: path.resolve(process.cwd(), "dist/bulba-template.js"),
sourcemap: true,
},
external,
plugins: [...plugins, replacePlugin(Environments.DEVELOPMENT)],
plugins: [
...plugins,
alias({ entries: moduleAliases }),
replacePlugin(Environments.DEVELOPMENT),
],
},
{
input: path.resolve(process.cwd(), "src/bundle-template.js"),
Expand All @@ -64,8 +67,11 @@ function createDistConfigs() {
sourcemap: true,
plugins: [terserPlugin],
},
external,
plugins: [...plugins, replacePlugin(Environments.PRODUCTION)],
plugins: [
...plugins,
alias({ entries: moduleAliases }),
replacePlugin(Environments.PRODUCTION),
],
},
]
}
Expand Down
1 change: 0 additions & 1 deletion packages/element/src/bundle-jsx.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./"
export * from "@bulba/jsx"
export * from "@rotom/utils"
1 change: 0 additions & 1 deletion packages/element/src/bundle-template.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from "./"
export * from "@bulba/template"
export * from "@rotom/utils"

0 comments on commit 76bc388

Please sign in to comment.