Skip to content

Commit

Permalink
add release:alpha script
Browse files Browse the repository at this point in the history
  • Loading branch information
kristojorg committed Sep 20, 2021
1 parent 8ed054e commit fef228e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
33 changes: 16 additions & 17 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import child_process from 'child_process';
const rimraf = util.promisify(origRimraf);
const exec = util.promisify(child_process.exec);

/**
* @todo
*
* - Figure out how to export the fonts and include them with dynamic urls in the css?
* - Possibly export a CJS or IIFE version?
* - Possibly add postcss or something to support namespaces?
*/

const isWatchEnabled = process.argv[2] === '-w';
// for now we bundle for production whenever we aren't in watch mode
const isProduction = !isWatchEnabled;
Expand All @@ -20,7 +28,7 @@ const isProduction = !isWatchEnabled;
async function generateDts() {
try {
return await exec(
`tsc --declaration --emitDeclarationOnly --declarationDir dist`
`tsc --declaration --emitDeclarationOnly --declarationDir dist/types`
);
} catch (e) {
return Promise.reject(e.stdout);
Expand All @@ -42,6 +50,10 @@ async function buildTs(
external: [
'react-dom',
'react',
/**
* @todo - We currently ignore these fonts, but we need to figure out a better way
* to include them
*/
'fonts/AccessibleDfA.otf',
'fonts/iAWriterDuospace-Regular.ttf',
],
Expand Down Expand Up @@ -77,21 +89,6 @@ async function buildAll() {
await fs.mkdir('dist');
console.log('🧹 Cleaned output folder -', chalk.blue('dist/'));

// build the main entrypoint as an IIFE module for use in a
// <script> tag. This is built at dist/reader.js for backwards
// compatibility
// const p1 = buildTs(
// {
// format: 'iife',
// entryPoints: ['src/index.tsx'],
// globalName: 'WebReader',
// outfile: 'dist/iife.js',
// minify: isProduction,
// },
// 'Compiled IIFE (for <script> tags)',
// 'dist/iife.js'
// );

// build the main entrypoint as an ES Module.
// This one doesn't need to be minified because it will
// be rebundled by the consumer's bundler
Expand All @@ -113,7 +110,9 @@ async function buildAll() {

// generate type declarations
const p3 = generateDts()
.then(() => logBundled('Generated TS Declarations', 'dist/index.d.ts'))
.then(() =>
logBundled('Generated TS Declarations', 'dist/types/index.d.ts')
)
.catch((e) => err('TS Error', e));

// wait for everything to finish running in parallel
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"homepage": "https://github.com/NYPL-Simplified/web-reader",
"main": "dist/index.js",
"module": "dist/index.js",
"typings": "dist/index.d.ts",
"typings": "dist/types/index.d.ts",
"files": [
"dist"
],
Expand All @@ -33,7 +33,8 @@
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook",
"cors-proxy": "node example/cors-proxy.js",
"release": "release-it --verbose"
"release": "release-it --verbose",
"release:alpha": "release-it --verbose --preRelease=alpha"
},
"peerDependencies": {
"react": "^16.8.0 || 17.x",
Expand Down

0 comments on commit fef228e

Please sign in to comment.