Skip to content
This repository was archived by the owner on May 4, 2020. It is now read-only.

Commit e1c207d

Browse files
authored
chore: build CommonJS by default (#674)
1 parent fa635e1 commit e1c207d

File tree

80 files changed

+270
-281
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+270
-281
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ functional-tests/
1111
.rpt2_cache
1212
test262
1313
temp
14-
dist-es6
1514
polyfill-locales.js
15+
dist-es6

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@
88
"url": "https://github.com/formatjs/formatjs"
99
},
1010
"scripts": {
11-
"build:packages": "lerna run --parallel clean && lerna run build",
12-
"build": "yarn run prettier && yarn run build:packages",
11+
"build": "yarn run clean && lerna run build",
12+
"clean": "lerna run --parallel clean",
1313
"cover:collect": "mkdir -p ./.nyc_output/ && for d in $(find packages -type d -name '.nyc_output' -maxdepth 2 -exec find '{}' -type f ';'); do (cp $d ./.nyc_output/); done; nyc report --reporter=lcov --report-dir=${COVERAGE_DIR:-artifacts/coverage}",
1414
"cover": "lerna run cover --since",
1515
"dev:test": "lerna run test --since master",
1616
"karma:ci": "karma start karma.conf-ci.js",
1717
"karma:local": "karma start karma.conf.js",
1818
"lint": "eslint 'packages/*/src/**/*.ts?(x)' --fix",
1919
"postversion": "yarn run prettier",
20-
"prepublishOnly": "yarn run build",
20+
"prepublishOnly": "yarn run prettier && yarn run build",
2121
"prettier": "prettier --write 'packages/*/{test,tests,src,scripts}/**/*.ts' 'website/**/*.js' 'packages/babel-plugin-react-intl/test/**/*.js' '**/*.md'",
2222
"prettier:check": "prettier --check 'packages/*/{test,tests,src,scripts}/**/*.ts' 'website/**/*.js' 'packages/babel-plugin-react-intl/test/**/*.js' '**/*.md'",
23-
"test": "lerna run lint && yarn run prettier:check && lerna run --parallel test"
23+
"test": "lerna run lint && yarn run prettier:check && lerna run --parallel test && jest -c tests/jest.config.js"
2424
},
2525
"devDependencies": {
2626
"@babel/cli": "^7.8.4",

packages/babel-plugin-react-intl/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"schema-utils": "^2.6.6"
2626
},
2727
"scripts": {
28-
"clean": "rimraf lib test/fixtures/**/actual.json *.tsbuildinfo",
28+
"clean": "rimraf lib dist test/fixtures/**/actual.json *.tsbuildinfo",
2929
"test": "cross-env TS_NODE_PROJECT=./tsconfig.json cross-env NODE_ENV=test jest",
3030
"cover": "npm t -- --coverage",
3131
"build": "json2ts -i src/options.schema.json -o src/options.ts && tsc"

packages/babel-plugin-react-intl/tsconfig.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@
33
"compilerOptions": {
44
"outDir": "dist",
55
"rootDir": "src",
6-
"module": "commonjs",
76
"baseUrl": ".",
8-
"paths": {
9-
"intl-messageformat-parser": ["../intl-messageformat-parser"]
10-
},
117
"types": [
128
"babel__core",
139
"babel__generator",

packages/cli/jest.config.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ module.exports = {
33
testEnvironment: 'node',
44
globals: {
55
'ts-jest': {
6-
tsConfig: 'tsconfig.json'
6+
// TODO: figure out editor tsconfig
7+
tsConfig: 'tsconfig.jest.json'
78
}
89
}
9-
};
10+
};

packages/cli/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@
3636
"url": "git+ssh://[email protected]/formatjs/formatjs.git"
3737
},
3838
"scripts": {
39-
"clean": "rimraf lib *.tsbuildinfo",
40-
"build": "tsc -p tsconfig.build.json",
41-
"test": "cross-env TS_NODE_PROJECT=./tsconfig.json cross-env NODE_ENV=test jest"
39+
"clean": "rimraf lib dist *.tsbuildinfo",
40+
"build": "tsc",
41+
"test": "cross-env TS_NODE_PROJECT=./tsconfig.jest.json cross-env NODE_ENV=test jest"
4242
},
4343
"dependencies": {
4444
"@babel/plugin-proposal-class-properties": "^7.8.3",

packages/cli/tsconfig.build.json

Lines changed: 0 additions & 9 deletions
This file was deleted.

packages/cli/tsconfig.jest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": ".",
5+
},
6+
"include": ["src/**/*.ts", "tests/**/*.ts"],
7+
"exclude": ["tests/extract/integration_tests/typescript/**/*.tsx"],
8+
}

packages/cli/tsconfig.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
// Targeting node >= 8
55
"target": "es2017",
66
"outDir": "lib",
7-
"rootDir": ".",
8-
"module": "esnext",
7+
"rootDir": "src",
98
"esModuleInterop": true,
109
"noUnusedLocals": true,
1110
"sourceMap": true,
@@ -30,7 +29,5 @@
3029
"yargs"
3130
]
3231
},
33-
// Also include tests in the default tsconfig.json for better editor integration.
34-
"include": ["src/**/*.ts", "tests/**/*.ts"],
35-
"exclude": ["tests/extract/integration_tests/typescript/**/*.tsx"],
32+
"include": ["src/**/*.ts"],
3633
}

packages/eslint-plugin-formatjs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"src"
99
],
1010
"scripts": {
11-
"build": "tsc -p tsconfig.build.json",
11+
"build": "tsc",
1212
"test": "cross-env TS_NODE_PROJECT=./tsconfig.json cross-env NODE_ENV=test jest"
1313
},
1414
"repository": {

packages/eslint-plugin-formatjs/tsconfig.build.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/eslint-plugin-formatjs/tsconfig.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
"compilerOptions": {
44
"target": "es6",
55
"outDir": "dist",
6-
"rootDir": ".",
7-
"module": "commonjs",
6+
"rootDir": "src",
87
"noUnusedLocals": true,
98
"sourceMap": true,
109
"preserveConstEnums": false,
@@ -27,5 +26,6 @@
2726
"stack-utils",
2827
"yargs"
2928
]
30-
}
29+
},
30+
"include": ["src/**/*.ts"]
3131
}

packages/formatjs-extract-cldr-data/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"src"
1111
],
1212
"scripts": {
13-
"build": "tsc -p tsconfig.build.json",
13+
"build": "tsc",
14+
"clean": "rimraf dist",
1415
"test": "cross-env TS_NODE_PROJECT=./tsconfig.json cross-env NODE_ENV=test jest --maxWorkers=100%",
1516
"verify": "ts-node scripts/verify-numbers",
1617
"cover": "npm t -- --coverage"

packages/formatjs-extract-cldr-data/tsconfig.build.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/formatjs-extract-cldr-data/tsconfig.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"module": "commonjs",
54
"outDir": "dist",
65
"rootDir": "src",
7-
"baseUrl": ".",
8-
"paths": {
9-
"intl-messageformat-parser": ["../intl-messageformat-parser"]
10-
},
116
"types": [
127
"babel__core",
138
"babel__generator",
@@ -28,5 +23,6 @@
2823
"stack-utils",
2924
"yargs"
3025
]
31-
}
32-
}
26+
},
27+
"include": ["src"]
28+
}

packages/intl-displaynames/jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
testEnvironment: 'node',
44
globals: {
55
'ts-jest': {
6-
tsConfig: 'tsconfig.cjs.json'
6+
tsConfig: 'tsconfig.json'
77
}
88
}
99
};

packages/intl-displaynames/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414
"author": "Linjie Ding <[email protected]>",
1515
"homepage": "https://github.com/formatjs/formatjs",
1616
"license": "MIT",
17-
"jsnext": "dist-es6/index.js",
1817
"main": "dist/index.js",
1918
"module": "lib/index.js",
19+
"module:es6": "dist-es6/index.js",
2020
"types": "lib/index.d.js",
2121
"files": [
2222
"dist",
@@ -36,14 +36,14 @@
3636
"formatjs-extract-cldr-data": "^10.1.5"
3737
},
3838
"scripts": {
39-
"cldr": "ts-node --project tsconfig.cjs.json scripts/cldr",
39+
"cldr": "ts-node scripts/cldr",
4040
"build": "yarn run cldr && yarn run compile && yarn run rollup",
4141
"clean": "rimraf dist dist-es6 lib *.tsbuildinfo",
42-
"jest": "cross-env NODE_ICU_DATA=../../node_modules/full-icu TS_NODE_PROJECT=tsconfig.cjs.json cross-env NODE_ENV=test jest",
43-
"test262": "cross-env NODE_ICU_DATA=../../node_modules/full-icu TS_NODE_PROJECT=tsconfig.cjs.json ts-node tests/runner",
42+
"jest": "cross-env NODE_ICU_DATA=../../node_modules/full-icu cross-env NODE_ENV=test jest",
43+
"test262": "cross-env NODE_ICU_DATA=../../node_modules/full-icu ts-node tests/runner",
4444
"test": "yarn run jest && yarn run test262",
4545
"rollup": "rollup -c rollup.config.js",
46-
"compile": "tsc && tsc -p tsconfig.cjs.json && tsc -p tsconfig.es6.json && api-extractor run --local"
46+
"compile": "tsc && tsc -p tsconfig.esm.json && tsc -p tsconfig.es6.json && api-extractor run --local"
4747
},
4848
"bugs": {
4949
"url": "https://github.com/formatjs/formatjs/issues"

packages/intl-displaynames/rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ export default [
6363
name: 'IntlDisplayNames'
6464
},
6565
plugins: [resolve({
66-
mainFields: ['jsnext', 'module', 'main']
66+
mainFields: ['module:es6', 'module', 'main']
6767
}), commonjsConfig, jsonConfig]
6868
},
6969
];

packages/intl-displaynames/tsconfig.es6.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"target": "es6",
5+
"module": "esnext",
56
"outDir": "dist-es6",
67
}
78
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "dist",
5-
"module": "commonjs"
4+
"outDir": "lib",
5+
"module": "esnext"
66
},
77
}

packages/intl-displaynames/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
44
"lib": ["dom", "es5", "esnext.intl", "es2017.intl", "es2018.intl"],
5-
"outDir": "lib",
5+
"outDir": "dist",
66
"rootDir": "src",
77
"allowSyntheticDefaultImports": true,
88
"noFallthroughCasesInSwitch": true,

packages/intl-format-cache/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
"src"
1212
],
1313
"scripts": {
14-
"clean": "rimraf dist lib *.tsbuildinfo",
15-
"benchmark": "ts-node --project tsconfig.cjs.json tests/benchmark",
16-
"build": "tsc && tsc -p tsconfig.cjs.json && rollup -c rollup.config.js",
17-
"test": "cross-env TS_NODE_PROJECT=../../tsconfig.cjs.json mocha --opts ../../mocha.opts tests/index.ts"
14+
"clean": "rimraf dist lib tests/browser.js tests/browser.js.map *.tsbuildinfo",
15+
"benchmark": "ts-node tests/benchmark",
16+
"build": "tsc && tsc -p tsconfig.esm.json && rollup -c rollup.config.js",
17+
"test": "mocha --opts ../../mocha.opts tests/index.ts"
1818
},
1919
"devDependencies": {
2020
"@formatjs/intl-pluralrules": "^1.5.6",

packages/intl-format-cache/tsconfig.cjs.json

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"outDir": "lib",
5+
"module": "esnext"
6+
},
7+
}
Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "lib",
4+
"outDir": "dist",
55
"rootDir": "src",
6-
"baseUrl": ".",
7-
"paths": {
8-
"@formatjs/intl-relativetimeformat": ["../intl-relativetimeformat"],
9-
"intl-messageformat": ["../intl-messageformat"]
10-
}
116
},
12-
"include": ["src/*.ts"]
13-
}
7+
"include": ["src"]
8+
}

packages/intl-listformat/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,3 @@ tests/browser.*
55
src/locales.ts
66
src/en.ts
77
tests/polyfill-all.js
8-
dist-es6/

packages/intl-listformat/jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module.exports = {
33
testEnvironment: 'node',
44
globals: {
55
'ts-jest': {
6-
tsConfig: 'tsconfig.cjs.json'
6+
tsConfig: 'tsconfig.json'
77
}
88
}
9-
};
9+
};

packages/intl-listformat/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636
],
3737
"scripts": {
3838
"build": "yarn run cldr && yarn run compile",
39-
"cldr": "ts-node --project tsconfig.cjs.json scripts/cldr",
40-
"clean": "rimraf dist lib dist-es6 *.tsbuildinfo",
41-
"compile": "tsc && api-extractor run --local && tsc -p tsconfig.cjs.json && tsc -p tsconfig.es6.json && rollup -c rollup.config.js",
42-
"jest": "cross-env NODE_ICU_DATA=../../node_modules/full-icu TS_NODE_PROJECT=tsconfig.cjs.json cross-env NODE_ENV=test jest",
43-
"test": "yarn run jest && cross-env NODE_ICU_DATA=../../node_modules/full-icu TS_NODE_PROJECT=tsconfig.cjs.json ts-node tests/runner"
39+
"cldr": "ts-node scripts/cldr",
40+
"clean": "rimraf dist lib dist-es6 dist-es6 *.tsbuildinfo",
41+
"compile": "tsc && tsc -p tsconfig.esm.json && tsc -p tsconfig.es6.json && api-extractor run --local && rollup -c rollup.config.js",
42+
"jest": "cross-env NODE_ICU_DATA=../../node_modules/full-icu NODE_ENV=test jest",
43+
"test": "yarn run jest && cross-env NODE_ICU_DATA=../../node_modules/full-icu ts-node tests/runner"
4444
},
4545
"homepage": "https://github.com/formatjs/formatjs",
4646
"license": "MIT",

packages/intl-listformat/tsconfig.cjs.json

Lines changed: 0 additions & 8 deletions
This file was deleted.

packages/intl-listformat/tsconfig.es6.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
44
"target": "es6",
5+
"module": "esnext",
56
"outDir": "dist-es6"
67
}
7-
}
8+
}
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"module": "commonjs"
4+
"outDir": "lib",
5+
"module": "esnext"
56
}
6-
}
7+
}

0 commit comments

Comments
 (0)