Skip to content

Commit

Permalink
Pack for both browser and ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
bennothommo committed Aug 7, 2023
1 parent 5d68f67 commit d3d321d
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
}]
},
"ignorePatterns": [
"rollup.config.mjs",
"rollup.*.config.mjs",
"jest.config.js",
"tests/*.js",
"dist/"
Expand Down
4 changes: 1 addition & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ module.exports = {
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
targets: '> 0.5%, last 2 versions, not dead, Firefox ESR, not ie > 0',
},
],
],
Expand Down
27 changes: 24 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,28 @@
"name": "@wintercms/snowboard",
"version": "0.1.0",
"description": "The Winter CMS Snowboard.js framework as a standalone module",
"browser": "src/browser.js",
"keywords": [
"winter",
"wintercms",
"snowboard",
"framework",
"organization",
"management"
],
"main": "dist/snowboard.esm.js",
"browser": "dist/snowboard.min.js",
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w",
"build": "npm run build:esm && npm run build:browser",
"build:browser": "rollup -c rollup.browser.config.mjs",
"build:esm": "rollup -c rollup.esm.config.mjs",
"watch": "rollup -c rollup.esm.config.js -w",
"lint": "eslint --ext .js src tests",
"test": "jest"
},
"author": "Ben Thomson <[email protected]>",
"homepage": "https://wintercms.com",
"repository": "github:wintercms/snowboard.js",
"bugs": "https://github.com/wintercms/snowboard.js/issues",
"license": "MIT",
"dependencies": {
"js-cookie": "^3.0.5"
Expand All @@ -30,5 +44,12 @@
"jest": "^29.6.2",
"jest-environment-jsdom": "^29.6.2",
"rollup": "^3.27.2"
},
"files": [
"dist/*.js"
],
"engines": {
"node": ">=14.18.0",
"npm": ">=8.0.0"
}
}
2 changes: 1 addition & 1 deletion rollup.config.mjs → rollup.browser.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import terser from '@rollup/plugin-terser';
import { nodeResolve } from '@rollup/plugin-node-resolve';

export default {
input: 'src/main.js',
input: 'src/browser.js',
output: [
{
file: 'dist/snowboard.js',
Expand Down
14 changes: 14 additions & 0 deletions rollup.esm.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { nodeResolve } from '@rollup/plugin-node-resolve';

export default {
input: 'src/esm.js',
output: [
{
file: 'dist/snowboard.esm.js',
format: 'esm',
}
],
plugins: [
nodeResolve(),
],
};
3 changes: 3 additions & 0 deletions src/browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Snowboard from './main/Snowboard';

export default new Snowboard();
9 changes: 9 additions & 0 deletions src/esm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Snowboard from './main/Snowboard';
import PluginBase from './abstracts/PluginBase';
import Singleton from './abstracts/Singleton';

export {
Snowboard,
PluginBase,
Singleton,
};
9 changes: 0 additions & 9 deletions src/main.js

This file was deleted.

4 changes: 4 additions & 0 deletions src/main/Snowboard.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ProxyHandler from './ProxyHandler';
import PluginBase from '../abstracts/PluginBase';
import Singleton from '../abstracts/Singleton';
import PluginLoader from './PluginLoader';
Expand Down Expand Up @@ -52,6 +53,9 @@ export default class Snowboard {
this.initialise();

this.debug('Snowboard framework initialised');

/* eslint-disable no-constructor-return */
return new Proxy(this, ProxyHandler);
}

/**
Expand Down

0 comments on commit d3d321d

Please sign in to comment.