Skip to content

Commit

Permalink
chore: Add npm run build scripts, using a common Rollup config file
Browse files Browse the repository at this point in the history
  • Loading branch information
eemeli committed Jul 28, 2021
1 parent e6f8b57 commit 3221fcb
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ root: true
env:
es6: true

parserOptions:
ecmaVersion: 2018
sourceType: module

overrides:
- files: ["*/src/*.js"]
extends:
- ./eslint-base.yaml
parserOptions:
ecmaVersion: 9
sourceType: module

- files: ["*/src/*.ts"]
parser: "@typescript-eslint/parser"
Expand Down
2 changes: 2 additions & 0 deletions fluent-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"parser"
],
"scripts": {
"build": "tsc",
"postbuild": "rollup -c ../rollup.config.mjs",
"test": "mocha 'test/*_test.js'"
},
"engines": {
Expand Down
2 changes: 2 additions & 0 deletions fluent-dedent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
"ftl"
],
"scripts": {
"build": "tsc",
"postbuild": "rollup -c ../rollup.config.mjs",
"test": "mocha 'test/*_test.js'"
},
"engines": {
Expand Down
2 changes: 2 additions & 0 deletions fluent-dom/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
"format"
],
"scripts": {
"build": "tsc",
"postbuild": "rollup -c ../rollup.config.mjs --globals cached-iterable:CachedIterable",
"test": "c8 mocha -ui tdd --require ./test/index.js 'test/*_test.js'"
},
"engines": {
Expand Down
3 changes: 3 additions & 0 deletions fluent-gecko/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
"localization",
"l10n"
],
"scripts": {
"build": "make build"
},
"devDependencies": {
"rollup-plugin-node-resolve": "^4.2.2"
}
Expand Down
2 changes: 2 additions & 0 deletions fluent-langneg/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"language-negotiation"
],
"scripts": {
"build": "tsc",
"postbuild": "rollup -c ../rollup.config.mjs",
"test": "mocha 'test/*_test.js'"
},
"engines": {
Expand Down
2 changes: 2 additions & 0 deletions fluent-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"reactjs"
],
"scripts": {
"build": "tsc",
"postbuild": "rollup -c ../rollup.config.mjs --globals @fluent/sequence:FluentSequence,cached-iterable:CachedIterable,react:React,prop-types:PropTypes",
"test": "jest --collect-coverage"
},
"engines": {
Expand Down
2 changes: 2 additions & 0 deletions fluent-sequence/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
"ftl"
],
"scripts": {
"build": "tsc",
"postbuild": "rollup -c ../rollup.config.mjs",
"test": "mocha 'test/*_test.js'"
},
"engines": {
Expand Down
2 changes: 2 additions & 0 deletions fluent-syntax/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"parser"
],
"scripts": {
"build": "tsc",
"postbuild": "rollup -c ../rollup.config.mjs",
"test": "mocha 'test/*_test.js'"
},
"engines": {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
"./fluent-*"
],
"scripts": {
"build": "npm run build -ws",
"lint": "eslint --max-warnings 0 'fluent-*/{src,test}/**/*.{js,ts}'",
"test:common": "c8 mocha 'fluent-*/test/*_test.js'",
"test": "npm run test:common && npm test -w fluent-dom && npm test -w fluent-react"
Expand Down
31 changes: 31 additions & 0 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { promises } from "fs";

// 'fs/promises' is only available from Node.js 14.0.0
const { readFile } = promises;

const globalName = {
"@fluent/bundle": "FluentBundle",
"@fluent/dedent": "FluentDedent",
"@fluent/dom": "FluentDOM",
"@fluent/langneg": "FluentLangNeg",
"@fluent/react": "FluentReact",
"@fluent/sequence": "FluentSequence",
"@fluent/syntax": "FluentSyntax",
};

module.exports = async function() {
// Current dir is the package's own directory here
const pkgSrc = await readFile("package.json", "utf8");
const { name, version } = JSON.parse(pkgSrc);

return {
input: "esm/index.js",
output: {
file: "index.js",
format: "umd",
amd: { id: name },
name: globalName[name],
banner: `/* ${name}@${version} */`,
},
};
};

0 comments on commit 3221fcb

Please sign in to comment.