Skip to content

Commit

Permalink
rollup, remove gulp for lots of things
Browse files Browse the repository at this point in the history
  • Loading branch information
arshaw committed Jan 16, 2019
1 parent f644b36 commit 881b21f
Show file tree
Hide file tree
Showing 20 changed files with 213 additions and 176 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
tmp
dist

# awesome-typescript-loader
.awcache
.sass-cache

# npm
node_modules
Expand Down
17 changes: 17 additions & 0 deletions bin/sass-args.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env node

const path = require('path')
const tsConfig = require(path.resolve(__dirname, '../tsconfig.json'))

let packagePaths = tsConfig.compilerOptions.paths
let parts = []

for (let packageName in packagePaths) {
let jsPath = packagePaths[packageName][0]
let srcPath = path.dirname(jsPath)
let distPath = 'dist/' + packageName

parts.push(srcPath + ':' + distPath)
}

console.log(parts.join(' '))
38 changes: 0 additions & 38 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,11 @@
const gulp = require('gulp')
const del = require('del')

require('./tasks/webpack')
require('./tasks/ts-types')
require('./tasks/minify')
require('./tasks/archive')
require('./tasks/test')
require('./tasks/lint')
require('./tasks/bump')
require('./tasks/example-repos')

// when running just `gulp`
gulp.task('default', [ 'dist' ])

// everything needed for running demos and developing
gulp.task('dev', [
'webpack:dev',
'ts-types'
])

// watch anything that needs to be built
gulp.task('watch', [
'webpack:watch',
'ts-types:watch'
])

// generates all files that end up in package manager release
gulp.task('dist', [
'webpack',
'ts-types',
'minify'
])

// like dist, but runs tests and linting, and generates archive
gulp.task('release', [
'example-repos:build',
'lint',
'dist',
'archive',
'test:single' // headless, single run
])

// group these somewhat unrelated tasks together for CI
gulp.task('lint-and-example-repos', [ 'lint', 'example-repos:build' ])

gulp.task('clean', function() {
return del([ 'dist/', 'tmp/', '.awcache/' ])
})
38 changes: 13 additions & 25 deletions karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,44 +30,32 @@ module.exports = function(config) {
'node_modules/xhr-mock/dist/xhr-mock.js', // TODO: should include this via require(), but .d.ts problems
'node_modules/jasmine-jquery/lib/jasmine-jquery.js',
'node_modules/jquery-simulate/jquery.simulate.js',
'node_modules/luxon/build/global/luxon.js', // TODO: how to deal with IE11?

// main lib AND plugin files
'dist/fullcalendar/main.js',
'dist/fullcalendar/main.css',
'dist/fullcalendar/locales-all.js',
'dist/fullcalendar-agenda/main.js',
'dist/fullcalendar-agenda/main.css',
'dist/fullcalendar-list/main.js',
'dist/fullcalendar-list/main.css',
'dist/fullcalendar-gcal/main.js',
'dist/fullcalendar-moment/main.js',
'dist/fullcalendar-moment-timezone/main.js',
'dist/fullcalendar-rrule/main.js',

// COMMENT-OUT THESE LINES when testing IE11
'node_modules/luxon/build/global/luxon.js',
'dist/fullcalendar-luxon/main.js',
// core and plugin files
'dist/**/*.js',
'dist/**/*.css',

// sourcemaps
{ pattern: 'dist/**/*.map', included: false, nocache: true, watched: false },

// src files referenced from sourcemaps
{ pattern: 'src/**/*', included: false, nocache: true, watched: false },

// a way to dump variables into the test environment
'tmp/automated-test-config.js',

// so plugins can dump files into here and test side effects
'tmp/test-side-effects/*.js',

// tests
'tests/automated/base.css',
'tmp/automated-tests.js',

// this sends a huge list to the client!!!!????
{ // serve all other files
pattern: '**/*',
included: false, // don't immediately execute
nocache: true, // don't let the webserver cache
watched: false // don't let changes trigger tests to restart
}
],

// make console errors aware of source files
preprocessors: {
'**/*.js': [ 'sourcemap' ]
'dist/**/*.js': [ 'sourcemap' ]
},

// test results reporter to use
Expand Down
38 changes: 20 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"@types/luxon": "^1.4.1",
"bootstrap": "^3.4.0",
"components-jqueryui": "github:components/jqueryui",
"concurrently": "^4.1.0",
"css-loader": "^0.28.11",
"del": "^2.2.1",
"dragula": "^3.7.2",
"dts-generator": "^2.1.0",
"eslint": "^4.19.1",
Expand All @@ -54,7 +54,6 @@
"gulp-tslint": "^8.1.3",
"gulp-uglify": "^2.0.0",
"gulp-util": "^3.0.7",
"gulp-watch": "^4.3.11",
"gulp-zip": "^3.2.0",
"jasmine-core": "2.5.2",
"jasmine-jquery": "^2.1.1",
Expand All @@ -67,31 +66,34 @@
"karma-verbose-reporter": "0.0.6",
"native-promise-only": "^0.8.1",
"node-sass": "^4.11.0",
"rollup": "^1.1.0",
"rollup-plugin-multi-entry": "^2.1.0",
"rollup-plugin-node-resolve": "^4.0.0",
"rollup-plugin-scss": "^0.4.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"rollup-plugin-typescript2": "^0.18.1",
"tslib": "^1.9.3",
"tslint": "^5.12.1",
"tslint-config-standard": "^7.1.0",
"typescript": "^3.2.2",
"xhr-mock": "^2.4.1",
"yargs": "^4.8.1"
},
"main": "dist/fullcalendar.js",
"types": "dist/fullcalendar.d.ts",
"main": "dist/fullcalendar/main.js",
"types": "dist/fullcalendar/main.d.ts",
"files": [
"dist/*.js",
"dist/*.css",
"dist/*.d.ts",
"dist/plugins/*.js",
"dist/plugins/*.css",
"dist/locales/*.js",
"README.*",
"LICENSE.*",
"CHANGELOG.*",
"CONTRIBUTING.*"
"dist/**/*"
],
"scripts": {
"clean": "gulp clean",
"dist": "gulp dist",
"lint": "gulp lint-and-example-repos",
"test": "gulp test:single"
"clean": "rm -rf dist tmp",
"build": "tsc && npm run rollup && npm run sass",
"watch": "concurrently --raw 'tsc --watch' 'npm run rollup-watch' 'npm run sass-watch'",
"rollup": "rollup -c --environment BUILD:production",
"rollup-watch": "sleep 5 && rollup -c --environment BUILD:development --watch",
"sass": "sass --update --sourcemap=none $(bin/sass-args.js)",
"sass-watch": "sass --watch $(bin/sass-args.js)",
"test": "karma start karma.config.js --auto-watch",
"test-single": "karma start karma.config.js --browsers ChromeHeadless_custom --single-run",
"lint": "gulp lint-and-example-repos"
}
}
143 changes: 143 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import path from 'path'
import glob from 'glob'
import resolve from 'rollup-plugin-node-resolve'
import multiEntry from 'rollup-plugin-multi-entry'
import sourcemaps from 'rollup-plugin-sourcemaps'
import rootPackageConfig from './package.json'
import tsConfig from './tsconfig.json'

let isDev
if (!/^(development|production)$/.test(process.env.BUILD)) {
console.warn('BUILD environment not specified. Assuming \'development\'')
isDev = true
} else {
isDev = process.env.BUILD == 'development'
}

let packagePaths = tsConfig.compilerOptions.paths
let packageNames = Object.keys(packagePaths)
let packageGlobals = {
superagent: 'superagent',
luxon: 'luxon',
moment: 'moment',
rrule: 'rrule',
fullcalendar: 'FullCalendar'
}

let watchOptions = {
clearScreen: false // let tsc do the screan clearing
}

for (let packageName of packageNames) {
if (!packageGlobals[packageName]) {
packageGlobals[packageName] = 'FullCalendar.defaultPlugins.' + packageName
}
}

let externalPackageNames = Object.keys(
Object.assign(
{},
packageGlobals,
rootPackageConfig.dependencies, // hopefully covered in packageGlobals
rootPackageConfig.peerDependencies // (if not, rollup will give an error)
)
)

export default [
...packageNames.map(buildPackageConfig),
...buildLocaleConfigs(),
buildTestConfig()
]

function buildPackageConfig(packageName) {
return {
onwarn,
watch: watchOptions,
input: 'tmp/tsc-output/' + packagePaths[packageName][0] + '.js',
external: externalPackageNames,
output: {
file: 'dist/' + packageName + '/main.js',
globals: packageGlobals,
exports: 'named',
name: packageGlobals[packageName],
format: 'umd',
sourcemap: isDev,
sourcemapExcludeSources: true
},
plugins: [
resolve(),
sourcemaps()
]
}
}

function buildLocaleConfigs() {
let localePaths = glob.sync('tmp/tsc-output/locales/*.js')
let configs = []

for (let localePath of localePaths) {
configs.push({
onwarn,
watch: watchOptions,
input: localePath,
external: externalPackageNames,
output: {
file: 'dist/fullcalendar/locales/' + path.basename(localePath),
globals: packageGlobals,
exports: 'none',
format: 'umd'
}
})
}

// ALL locales in one file
configs.push({
onwarn,
watch: watchOptions,
input: localePaths,
external: externalPackageNames,
output: {
file: 'dist/fullcalendar/locales-all.js',
globals: packageGlobals,
exports: 'none',
format: 'umd'
},
plugins: [
multiEntry()
]
})

return configs
}

function buildTestConfig() {
return {
onwarn,
watch: watchOptions,
input: [
'tmp/tsc-output/tests/automated/globals.js',
'tmp/tsc-output/tests/automated/hacks.js',
'tmp/tsc-output/tests/automated/**/*.js'
],
external: externalPackageNames,
output: {
file: 'tmp/automated-tests.js',
globals: packageGlobals,
exports: 'none',
format: 'umd'
},
plugins: [
resolve(),
sourcemaps(),
multiEntry({
exports: false // otherwise will complain about exported utils
})
]
}
}

function onwarn(warning, warn) {
if (warning.code !== 'PLUGIN_WARNING') {
warn(warning)
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 9 additions & 9 deletions src/core/main.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@

@import './common/common.scss';
@import './common/common.standard.scss';
@import './common/common.jquery-ui.scss';
@import './common/common.bootstrap3.scss';
@import './common/common.bootstrap4.scss';
@import './toolbar.scss';
@import './view.scss';
@import './basic/basic.scss';
@import './common/common';
@import './common/standard';
@import './common/jqueryui';
@import './common/bootstrap3';
@import './common/bootstrap4';
@import './toolbar';
@import './view';
@import './basic/basic';

@media print {
@import './common/print.scss';
@import './common/print';
}
26 changes: 0 additions & 26 deletions src/tslib-lite.js

This file was deleted.

0 comments on commit 881b21f

Please sign in to comment.