Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle helmet using rollup #395

Merged
merged 3 commits into from Dec 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 2 additions & 40 deletions .babelrc
@@ -1,55 +1,17 @@
{
"env": {
"commonjs": {
"presets": [
["env", {
"targets": {
"browsers": ["last 1 versions", "ie >= 10"]
},
"modules": "commonjs",
"loose": true,
"useBuiltIns": true
}]
],
"plugins": [
"transform-export-extensions",
"transform-class-properties",
"transform-object-rest-spread",
"transform-remove-strict-mode"
]
},
"test": {
"plugins": [
["istanbul", {
"exclude": [
"**/node_modules/**",
"**/packages/**",
"**/test/**",
"**/Test*"
]
}],
"transform-export-extensions",
"transform-class-properties",
"transform-object-rest-spread",
"transform-remove-strict-mode"
]
}
},
"presets": [
["env", {
"targets": {
"browsers": ["last 1 versions", "ie >= 10"]
},
"modules": false,
"loose": true,
"useBuiltIns": true
"loose": true
}],
"react"
],
"plugins": [
"transform-export-extensions",
"transform-class-properties",
"transform-object-rest-spread",
"transform-remove-strict-mode"
"external-helpers"
]
}
1 change: 1 addition & 0 deletions .npmignore
Expand Up @@ -12,3 +12,4 @@ test/
node_modules
src
travis.yml
rollup.config.js
46 changes: 27 additions & 19 deletions karma.config.js
Expand Up @@ -22,11 +22,10 @@ module.exports = function(config) {
// frameworks to use
frameworks: ["chai-sinon", "mocha"],

files: ["./test/test.js"],
files: ["./test/*.js"],

preprocessors: {
// add webpack as preprocessor
"./test/test.js": ["webpack", "sourcemap"]
"./test/*.js": ["rollup", "sourcemap"]
},

coverageReporter: {
Expand All @@ -40,23 +39,32 @@ module.exports = function(config) {
]
},

webpack: {
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.js$/,
// exclude this dirs from coverage
exclude: [/node_modules/],
loader: "babel-loader"
}
]
rollupPreprocessor: {
output: {
format: "iife",
name: "helmet",
sourcemap: "inline"
},
watch: true
},

webpackServer: {
noInfo: true
plugins: [
require("rollup-plugin-replace")({
"process.env.NODE_ENV": "'development'"
}),
require("rollup-plugin-babel")({
exclude: "node_modules/**",
plugins: [
[
"istanbul",
{
exclude: ["**/node_modules/**", "**/test/**"]
}
]
]
}),
require("rollup-plugin-node-resolve")({
browser: true
}),
require("rollup-plugin-commonjs")()
]
},

// test results reporter to use
Expand Down
25 changes: 11 additions & 14 deletions package.json
Expand Up @@ -36,22 +36,17 @@
"react-side-effect": "^1.1.0"
},
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-core": "^6.24.0",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.4.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-istanbul": "^4.0.0",
"babel-plugin-transform-class-properties": "^6.23.0",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-plugin-transform-remove-strict-mode": "^0.0.2",
"babel-preset-env": "^1.2.2",
"babel-preset-react": "^6.23.0",
"chai": "^3.5.0",
"codecov": "^2.1.0",
"conventional-changelog-cli": "^1.3.1",
"cross-env": "^3.2.4",
"cz-conventional-changelog": "^2.0.0",
"eslint": "^3.18.0",
"eslint-config-nfl": "^11.1.0",
Expand All @@ -70,31 +65,33 @@
"karma-firefox-launcher": "^1.0.1",
"karma-html-reporter": "^0.2.7",
"karma-mocha": "^1.3.0",
"karma-rollup-preprocessor": "^6.1.0",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "^0.0.30",
"karma-tap-reporter": "^0.0.6",
"karma-webpack": "^2.0.3",
"mocha": "^3.2.0",
"prettier": "^1.4.4",
"react": "^15.x",
"react-dom": "^15.x",
"rimraf": "^2.6.1",
"rollup": "^0.67.0",
"rollup-plugin-babel": "^3.0.7",
"rollup-plugin-commonjs": "^9.2.0",
"rollup-plugin-node-resolve": "^3.4.0",
"rollup-plugin-replace": "^2.1.0",
"sinon": "^2.1.0",
"sinon-chai": "^2.8.0",
"webpack": "^2.2.1"
"sinon-chai": "^2.8.0"
},
"scripts": {
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"clean": "rimraf lib coverage es",
"lint": "eslint --ignore-path .gitignore --fix -- .",
"test": "cross-env BABEL_ENV=test karma start karma.config.js",
"test": "karma start karma.config.js",
"posttest": "istanbul report lcov text",
"pretest": "npm run clean && npm run lint",
"commit": "git-cz",
"compile": "npm run compile:commonjs && npm run compile:es",
"compile:commonjs": "cross-env BABEL_ENV=commonjs babel src --out-dir lib",
"compile:es": "cross-env BABEL_ENV=es babel src --out-dir es --ignore test.js",
"prepublish": "npm run compile"
"build": "rollup -c",
"prepublish": "npm run build"
},
"config": {
"commitizen": {
Expand Down
37 changes: 37 additions & 0 deletions rollup.config.js
@@ -0,0 +1,37 @@
import babel from "rollup-plugin-babel";

import pkg from "./package.json";

const baseConfig = {
input: "src/Helmet.js",
plugins: [
babel({
exclude: "node_modules/**"
})
],
external: [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies)
]
};

export default [
Object.assign(
{
output: {
file: pkg.main,
format: "cjs"
}
},
baseConfig
),
Object.assign(
{
output: {
file: "es/Helmet.js",
format: "esm"
}
},
baseConfig
)
];
1 change: 0 additions & 1 deletion src/Helmet.js
Expand Up @@ -284,4 +284,3 @@ const HelmetExport = Helmet(HelmetSideEffects);
HelmetExport.renderStatic = HelmetExport.rewind;

export {HelmetExport as Helmet};
export default HelmetExport;
2 changes: 0 additions & 2 deletions test/test.js

This file was deleted.