-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
354 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
const path = require('path') | ||
const globby = require('globby') | ||
const nodeResolve = require('@rollup/plugin-node-resolve') | ||
const postCss = require('rollup-plugin-postcss') | ||
|
||
const CORE_PKG_DIR = 'packages/core' | ||
const BUNDLE_DIRS = [ // TODO: use glob! | ||
'packages/bundle', | ||
'packages-premium/bundle' | ||
] | ||
|
||
|
||
module.exports = [ | ||
...BUNDLE_DIRS.map(bundleMainConfig), | ||
localeAllConfig(), | ||
...localEachConfigs() | ||
] | ||
|
||
|
||
function bundleMainConfig(bundleDir) { | ||
return { | ||
input: path.join(bundleDir, 'tsc/main.js'), | ||
output: { | ||
format: 'iife', | ||
name: 'FullCalendar', | ||
dir: path.join(bundleDir, 'dist') | ||
}, | ||
plugins: [ | ||
nodeResolve(), | ||
postCss({ | ||
extract: true // to separate file | ||
}) | ||
], | ||
watch: { | ||
// chokidar: { | ||
// awaitWriteFinish: true, // has good defaults | ||
// }, | ||
// buildDelay: 1000, // doesn't work in rollup v1 | ||
clearScreen: false // because tsc does it | ||
} | ||
} | ||
} | ||
|
||
|
||
function localeAllConfig() { | ||
return { | ||
input: path.join(CORE_PKG_DIR, 'locales-all.js'), | ||
output: BUNDLE_DIRS.map((bundleDir) => ({ | ||
format: 'iife', | ||
name: 'FullCalendar', | ||
dir: bundleDir | ||
})), | ||
plugins: [ | ||
localeAllWrap() | ||
] | ||
} | ||
} | ||
|
||
|
||
function localEachConfigs() { | ||
return globby.sync('locales/*.js', { cwd: CORE_PKG_DIR }).map((localeFile) => ({ | ||
input: path.join(CORE_PKG_DIR, localeFile), | ||
output: BUNDLE_DIRS.map((bundleDir) => ({ | ||
format: 'iife', | ||
name: 'FullCalendar', | ||
dir: bundleDir, | ||
entryFileNames: localeFile | ||
})), | ||
plugins: [ | ||
localeEachWrap() | ||
] | ||
})) | ||
} | ||
|
||
|
||
function localeAllWrap() { | ||
return { | ||
renderChunk(code) { | ||
return code.replace(/^var FullCalendar = /, 'FullCalendar.globalLocales = ') | ||
} | ||
} | ||
} | ||
|
||
|
||
function localeEachWrap() { | ||
return { | ||
renderChunk(code) { | ||
return code.replace(/^var FullCalendar = /, 'FullCalendar.globalLocales.push') | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
const path = require('path') | ||
const globby = require('globby') | ||
const dts = require('rollup-plugin-dts').default | ||
|
||
|
||
const MAIN_PATHS = [ | ||
'packages?(-premium)/*/tsc/main.js', | ||
'!packages?(-premium)/bundle/tsc/main.js', | ||
'!packages?(-premium)/__tests__/tsc/main.js' | ||
] | ||
|
||
|
||
module.exports = [ | ||
...jsConfigs(), | ||
...dtsConfigs() | ||
] | ||
|
||
|
||
function jsConfigs() { | ||
return globby.sync(MAIN_PATHS).map((mainPath) => ({ | ||
input: mainPath, | ||
output: { | ||
format: 'es', | ||
dir: path.resolve(mainPath, '../../dist') | ||
}, | ||
plugins: [ | ||
externalizeStylesheets(), | ||
externalizeNamed(mainPath) | ||
], | ||
watch: { | ||
chokidar: { // better than default watch util. doesn't fire change events on stat changes (like last opened) | ||
awaitWriteFinish: { // because tsc/rollup sometimes takes a long time to write and triggers two recompiles | ||
stabilityThreshold: 500, | ||
pollInterval: 100 | ||
} | ||
}, | ||
clearScreen: false | ||
} | ||
})) | ||
} | ||
|
||
|
||
function externalizeStylesheets() { | ||
return { | ||
resolveId(id) { | ||
if (id.match(/\.css$/)) { | ||
return { id, external: true } | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
function externalizeNamed(mainPath) { | ||
return { | ||
resolveId(id) { | ||
if ( | ||
id !== mainPath && // not the main file | ||
!id.match(/^\./) // non-relative | ||
) { | ||
return { id, external: true } | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
function dtsConfigs() { | ||
return globby.sync(MAIN_PATHS).map((mainPath) => ({ | ||
input: mainPath.replace(/\.js$/, '.d.ts'), | ||
output: { | ||
format: 'es', | ||
file: path.resolve(mainPath, '../../dist/main.d.ts') | ||
}, | ||
plugins: [ | ||
externalizeStylesheets(), | ||
externalizeVDom(), | ||
dts() | ||
] | ||
})) | ||
} | ||
|
||
|
||
function externalizeVDom() { // TODO: will need to copy these over manually!!! | ||
return { | ||
resolveId(id) { | ||
if (id.match(/\/vdom$/)) { | ||
return { id, external: true } | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e # immediately exit upon error | ||
cd "`dirname $0`/.." # start in project root | ||
|
||
npm run tsc | ||
npm run locales | ||
npm run rollup:packages | ||
npm run sass # will write to dest dirs created by rollup:packages | ||
npm run rollup:bundles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.