Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/typescript support poc 2 #1427

Closed
wants to merge 96 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
cf5868b
feat(packages/sui-bundler): add ts support
andresz1 May 24, 2022
1782cdc
feat: add support for tsx
May 24, 2022
d6a64ad
Merge branch 'master' into feat/typescript-support-poc-2
Jun 9, 2022
6258208
Merge branch 'feat/typescript-support-poc' into feat/typescript-suppo…
andresz1 Jun 10, 2022
be032c1
Merge branch 'feat/typescript-support-poc-2' of github.com:SUI-Compon…
andresz1 Jun 10, 2022
d317f4c
feat(packages/sui-bundler): update config
andresz1 Aug 25, 2022
c88abfd
feat(packages/sui-studio): add initial typescript support
andresz1 Aug 25, 2022
ecb5b24
feat(packages/sui-studio): remove index extension to support typescri…
andresz1 Sep 1, 2022
b2953ba
Merge branch 'master' into feat/typescript-support-poc-2
andresz1 Sep 9, 2022
70bc6ef
feat(packages/sui-bundler): remove not needed app extension
andresz1 Sep 9, 2022
bdbadd2
Merge branch 'feat/typescript-support-poc' into feat/typescript-suppo…
andresz1 Sep 12, 2022
f5e3f27
feat(packages/sui-studio): update package import
andresz1 Sep 12, 2022
9205c48
feat(packages/sui-studio): update studio import
andresz1 Sep 12, 2022
85ce350
chore: ts overrides changes
Oct 17, 2022
b853f92
feat(packages/sui-test): add jest command for sui-test
giodelabarrera Dec 13, 2022
f4c7c51
chore(Root): add npmrc for allow isolated npm config
giodelabarrera Dec 14, 2022
798a5d4
chore(packages/sui-test): add jest dependencies
giodelabarrera Dec 14, 2022
a00b251
feat(packages/sui-test): add default sui jest config
giodelabarrera Dec 14, 2022
0e3c577
chore(packages/sui-test): add swc jest
giodelabarrera Dec 14, 2022
ec0b8c0
chore(packages/sui-test): remove babel-jest dependency
giodelabarrera Dec 14, 2022
bb1c153
docs(packages/sui-test): add todo comment
giodelabarrera Dec 15, 2022
751f91f
feat(packages/sui-js-compiler): use latest swc helpers version
Dec 20, 2022
3ed25f5
feat(packages/sui-studio): remove extensions from imports
Dec 20, 2022
3330883
feat(packages/sui-lint): fix rule value
Dec 20, 2022
2909eeb
feat(packages/sui-bundler): use latest swc helpers
Dec 20, 2022
9c37ed9
Merge branch 'master' into feat/poc-jest
giodelabarrera Jan 9, 2023
5caa961
chore(packages/sui-test): add beta
giodelabarrera Jan 9, 2023
2d63279
chore(packages/sui-bundler): add typescript tag
giodelabarrera Jan 9, 2023
7fffe91
chore(packages/sui-js-compiler): add typescript tag
giodelabarrera Jan 9, 2023
96ec6e2
chore(packages/sui-lint): add typescript tag
giodelabarrera Jan 9, 2023
7fd4957
chore(packages/sui-studio): add typescript tag
giodelabarrera Jan 9, 2023
8c5afa4
feat(packages/sui-bundler): read typescript mode from package json co…
Jan 11, 2023
12b84c8
chore(packages/sui-bundler): add version typescript number
giodelabarrera Jan 12, 2023
0988f8b
chore(packages/sui-test): create jest tag beta version
giodelabarrera Jan 12, 2023
36a13a7
feat(packages/sui-lint): add eslint rules overrides for chai tests
Jan 30, 2023
6dba47a
feat(packages/sui-lint): Disabled the rule return-await ( for typescr…
Feb 6, 2023
113e481
feat(packages/sui-js-compiler): add new test folder to ignore
giodelabarrera Feb 8, 2023
621e364
chore(packages/sui-js-compiler): add jest beta tag
giodelabarrera Feb 8, 2023
f75f241
Merge branch 'master' into feat/poc-jest
giodelabarrera Feb 8, 2023
8e4769e
feat(packages/sui-js-compiler): use ignore name for destructuring and…
giodelabarrera Feb 8, 2023
c2af7b7
chore(packages/sui-js-compiler): upgrade version
giodelabarrera Feb 8, 2023
3e3dcaa
feat(packages/sui-lint): add jest rules
giodelabarrera Feb 8, 2023
5b62800
chore(packages/sui-lint): add eslint jest dependency
giodelabarrera Feb 8, 2023
f0ac5b3
chore(packages/sui-lint): upgrade version
giodelabarrera Feb 13, 2023
fb8f526
chore(packages/sui-react-context): use package types from lib folder
Mar 8, 2023
30ae1b1
Merge branch 'feat/typescript-support-poc' into feat/typescript-suppo…
Mar 8, 2023
ef67cf8
feat(packages/sui-lint): add eslint-config-standard-react dependency
Mar 8, 2023
d0451af
feat(packages/sui-bundler): bump version after master merge
Mar 8, 2023
1bd063d
feat(packages/sui-js-compiler): bump version after master merge
Mar 8, 2023
66e6fe2
feat(packages/sui-lint): bump version after master merge
Mar 8, 2023
6fed8fe
feat(packages/sui-studio): bump version after master merge
Mar 8, 2023
b6e6bcc
feat(packages/sui-lint): upgrade to latest eslint ts plugin
Mar 30, 2023
16380e1
Merge branch 'master' into feat/typescript-support-poc-2
Apr 19, 2023
ecdc2b9
feat(packages/sui-bundler): use latest swc versions
Apr 20, 2023
7833cac
feat(packages/sui-js-compiler): use latest swc versions
Apr 20, 2023
e1114b3
feat(packages/sui-bundler): bump version for latest swc
Apr 20, 2023
32dc648
feat(packages/sui-js-compiler): bump version for latest swc
Apr 20, 2023
0f69a24
Merge branch 'feat/typescript-support-poc' into feat/typescript-suppo…
kikoruiz May 15, 2023
77c7180
feat(packages/sui-bundler): adapt bundler to new changes
kikoruiz May 17, 2023
8fd91e7
Merge branch 'feat/typescript-support-poc' into feat/typescript-suppo…
kikoruiz May 22, 2023
e7d6353
chore(packages/sui-studio): update deps
kikoruiz May 22, 2023
16469f7
fix(packages/sui-bundler): reset swc dependencies versions
kikoruiz May 25, 2023
895f01c
Merge branch 'master' into feat/typescript-support-poc-2
kikoruiz May 25, 2023
5568b6d
Merge branch 'master' into feat/poc-jest
andresz1 May 29, 2023
16e2bd7
chore: update code owners
kikoruiz Jun 2, 2023
0e2f2a2
feat(packages/sui-lint): add jest rules
andresz1 Jun 6, 2023
f15be4c
feat(packages/sui-jest): add wrapper for jest
giodelabarrera Jun 7, 2023
edbeccd
chore(packages/sui-jest): update homepage url
giodelabarrera Jun 7, 2023
8b99407
chore(packages/sui-jest): improve package description
giodelabarrera Jun 7, 2023
46ea335
docs(packages/sui-jest): add basic usage and config description
giodelabarrera Jun 7, 2023
4a0050d
chore(packages/sui-jest): modify package description
giodelabarrera Jun 7, 2023
1789352
feat(packages/sui-test): remove jest since it has been moved to a new…
giodelabarrera Jun 7, 2023
a5fa72a
docs(packages/sui-jest): update specific config option
giodelabarrera Jun 7, 2023
c7f6721
chore(packages/sui-js-compiler): apply format
giodelabarrera Jun 8, 2023
da1b99a
docs(Root): add sui-jest for available packages
giodelabarrera Jun 8, 2023
df148e5
feat(packages/sui-lint): remove comment
andresz1 Jun 8, 2023
bf53091
feat(packages/sui-mono): upgrade git-url-parse dependency to major 13
jordevo Jun 9, 2023
666e40b
Merge pull request #1609 from SUI-Components/feat-upgrade-sui-mono-gi…
jordevo Jun 9, 2023
f261932
release(packages/sui-mono): v2.35.0 [skip ci]
sui-bot Jun 9, 2023
a8b5d1c
Merge pull request #1565 from SUI-Components/feat/poc-jest
giodelabarrera Jun 12, 2023
879f30d
release(packages/sui-jest): v1.1.0 [skip ci]
sui-bot Jun 12, 2023
29202e4
release(packages/sui-js-compiler): v1.24.0 [skip ci]
sui-bot Jun 12, 2023
d1a99f3
release(packages/sui-lint): v4.31.0 [skip ci]
sui-bot Jun 12, 2023
130d67a
release(packages/sui-test): v8.26.0 [skip ci]
sui-bot Jun 12, 2023
a851c59
fix(packages/sui-i18n): fix missed key warning when i18n.url
javiauso Jun 12, 2023
03eedc7
Merge pull request #1610 from SUI-Components/fix/i18n-url-translate-e…
javiauso Jun 12, 2023
46957a2
release(packages/sui-i18n): v1.33.0 [skip ci]
sui-bot Jun 12, 2023
7d5f61b
Merge pull request #1608 from SUI-Components/feat/lint-jest
andresz1 Jun 13, 2023
b8bed2b
release(packages/sui-lint): v4.32.0 [skip ci]
sui-bot Jun 13, 2023
316c987
fix(packages/sui-i18n): restore slash when token is validated in i18n…
javiauso Jun 13, 2023
eb9cc8d
fix(packages/sui-lint): update jest rules
andresz1 Jun 13, 2023
37af403
Merge pull request #1612 from SUI-Components/fix/sui-jest-lint
andresz1 Jun 13, 2023
f8e57a1
release(packages/sui-lint): v4.33.0 [skip ci]
sui-bot Jun 13, 2023
ed3d01f
Merge pull request #1611 from SUI-Components/fix/i18n-url-translate-e…
javiauso Jun 13, 2023
6854f78
release(packages/sui-i18n): v1.34.0 [skip ci]
sui-bot Jun 13, 2023
aee0a28
Merge branch 'feat/typescript-support-poc-2' of github.com:SUI-Compon…
carlosvillu Jun 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Each line is a file pattern followed by one or more owners.

# These owners will be the default owners for everything in the repo.
* @sui-bot @kikoruiz @andresz1
* @sui-bot @kikoruiz @andresz1 @carlosvillu
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ packages/sui-studio/test/server/integration/empty-studio/components/fake/compone

!packages/sui-sass-loader/test/server/fixtures/**/node_modules

contract/logs/pact.log
contract/logs/pact.log
.npmrc
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ SUI is a set of packages which goal to ease development of SUI-based components
| [sui-helpers](./packages/sui-helpers) | A set of internal helpers used by sui-related packages. |
| [sui-hoc](./packages/sui-hoc) | React utility belt for function components and higher-order components |
| [sui-i18n](./packages/sui-i18n) | Isomorphic i18n service for browser and node |
| [sui-jest](./packages/sui-jest) | CLI to work with Jest |
| [sui-js](./packages/sui-js) | Javascript utilities |
| [sui-js-compiler](./packages/sui-js-compiler) | Javascript compiler |
| [sui-lint](./packages/sui-lint) | CLI to lint your code and make it compliant to SUI official rules |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@
"stylelint": {
"extends": "./node_modules/@s-ui/lint/stylelint.config.js"
}
}
}
7 changes: 1 addition & 6 deletions packages/sui-bundler/bin/sui-bundler-dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,7 @@ const start = async ({
} = {}) => {
clearConsole()
// Warn and crash if required files are missing
if (
!checkRequiredFiles([
path.join(config.context, 'index.html'),
path.join(config.context, 'app.js')
])
) {
if (!checkRequiredFiles([path.join(config.context, 'index.html')])) {
log.error(
`✖ Required files are missing, create and index.html and app.js inside your src folder.`
)
Expand Down
2 changes: 1 addition & 1 deletion packages/sui-bundler/loaders/linkLoaderConfigBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module.exports = ({config, packagesToLink, linkAll}) => {
* if neccesary
*/
const linkLoader = {
test: /\.(jsx?|scss)$/,
test: /\.(jsx?|tsx?|scss)$/,
enforce: 'pre', // this will ensure is execute before transformations
use: {
loader: require.resolve('./LinkLoader'),
Expand Down
11 changes: 7 additions & 4 deletions packages/sui-bundler/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@s-ui/bundler",
"version": "9.38.0",
"version": "9.39.0-typescript.6",
"description": "Config-free bundler for ES6 React apps.",
"bin": {
"sui-bundler": "./bin/sui-bundler.js"
Expand All @@ -21,9 +21,11 @@
},
"homepage": "https://github.com/SUI-Components/sui/tree/master/packages/sui-bundler#readme",
"dependencies": {
"@babel/core": "7.18.10",
"@babel/core": "7.21.8",
"@s-ui/helpers": "1",
"@s-ui/sass-loader": "1",
"@swc/core": "1.3.14",
"@swc/helpers": "0.4.12",
"address": "1.2.0",
"autoprefixer": "10.4.8",
"babel-loader": "8.2.5",
Expand All @@ -34,7 +36,7 @@
"css-minimizer-webpack-plugin": "4.0.0",
"esbuild": "0.15.5",
"escape-string-regexp": "4.0.0",
"fast-glob": "3.2.11",
"fast-glob": "3.2.12",
"find-free-ports": "3.0.0",
"html-webpack-plugin": "5.5.0",
"https-browserify": "1.0.0",
Expand All @@ -46,8 +48,9 @@
"stream-http": "3.2.0",
"strip-ansi": "6.0.1",
"style-loader": "3.3.1",
"swc-loader": "^0.2.1",
"url": "0.11.0",
"webpack": "5.74.0",
"webpack": "5.82.1",
"webpack-dev-server": "4.10.0",
"webpack-manifest-plugin": "5.0.0",
"webpack-node-externals": "3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/sui-bundler/shared/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const {config} = require('./config.js')

exports.MAIN_ENTRY_POINT = './app.js'
exports.MAIN_ENTRY_POINT = './app'
exports.config = config

exports.cleanList = list => list.filter(Boolean)
Expand Down
105 changes: 83 additions & 22 deletions packages/sui-bundler/shared/module-rules-babel.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,93 @@
/* eslint-disable no-console */
const fs = require('fs-extra')
const path = require('path')
const {config} = require('./index.js')

const tsConfigPath = path.join(process.cwd(), 'tsconfig.json')
let isTypeScriptEnabled = false

try {
if (fs.existsSync(tsConfigPath)) {
isTypeScriptEnabled = true
}
} catch (err) {
console.error(err)
}

const EXCLUDED_FOLDERS_REGEXP = new RegExp(
`node_modules(?!${path.sep}@s-ui(${path.sep}studio)(${path.sep}workbench)?${path.sep}src)`
)

module.exports = ({isServer = false, supportLegacyBrowsers = true} = {}) => ({
test: /\.jsx?$/,
exclude: EXCLUDED_FOLDERS_REGEXP,
use: [
{
loader: require.resolve('babel-loader'),
options: {
cacheDirectory: true,
cacheCompression: false,
babelrc: false,
compact: true,
presets: [
[
require.resolve('babel-preset-sui'),
{
isServer,
isModern: !supportLegacyBrowsers,
targets: config.targets
module.exports = ({isServer = false, supportLegacyBrowsers = true} = {}) =>
isTypeScriptEnabled
? {
test: /\.(js|ts)x?$/,
exclude: EXCLUDED_FOLDERS_REGEXP,
use: [
{
loader: require.resolve('swc-loader'),
options: {
minify: true,
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
dynamicImport: true,
privateMethod: true,
functionBind: true,
exportDefaultFrom: true,
exportNamespaceFrom: true,
decorators: true,
decoratorsBeforeExport: true,
topLevelAwait: true,
importMeta: true
},
transform: {
legacyDecorator: true,
react: {
useBuiltins: true,
runtime: 'automatic'
}
},
target: 'es5',
loose: true,
externalHelpers: true
},
env: {
targets: {
ie: '11'
},
dynamicImport: true,
loose: true,
mode: 'entry',
coreJs: 3
}
}
}
]
}
: {
test: /\.jsx?$/,
exclude: EXCLUDED_FOLDERS_REGEXP,
use: [
{
loader: require.resolve('babel-loader'),
options: {
cacheDirectory: true,
cacheCompression: false,
babelrc: false,
compact: true,
presets: [
[
require.resolve('babel-preset-sui'),
{
isServer,
isModern: !supportLegacyBrowsers,
targets: config.targets
}
]
]
}
]
}
]
}
}
]
})
2 changes: 1 addition & 1 deletion packages/sui-bundler/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const webpackConfig = {
timers: false
},
modules: ['node_modules', path.resolve(process.cwd())],
extensions: ['.js', '.json']
extensions: ['.js', '.tsx', '.ts', '.json']
},
stats: 'errors-only',
entry: cleanList([
Expand Down
18 changes: 18 additions & 0 deletions packages/sui-i18n/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# CHANGELOG

# 1.34.0 (2023-06-13)


### Bug Fixes

* **packages/sui-i18n:** restore slash when token is validated in i18n.url ([316c987](https://github.com/SUI-Components/sui/commit/316c987e3b5c06a068e0edf493520c139b07cdfa))



# 1.33.0 (2023-06-12)


### Bug Fixes

* **packages/sui-i18n:** fix missed key warning when i18n.url ([a851c59](https://github.com/SUI-Components/sui/commit/a851c59bc0ef53e466a79a45c250b46ee1a3deb6))



# 1.32.0 (2023-03-03)


Expand Down
2 changes: 1 addition & 1 deletion packages/sui-i18n/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@s-ui/i18n",
"version": "1.32.0",
"version": "1.34.0",
"type": "module",
"main": "lib/index.js",
"description": "> Isomorphic i18n service for browser and node.",
Expand Down
2 changes: 1 addition & 1 deletion packages/sui-i18n/src/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ export default class Rosetta {
url(urlPattern, allowQueryParams) {
return urlPattern
.split('/')
.map(token => slugify(this.t(token), allowQueryParams))
.map(token => token && slugify(this.t(token), allowQueryParams))
.join('/')
}

Expand Down
12 changes: 9 additions & 3 deletions packages/sui-i18n/test/fixtures/languages.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
export const LANGUAGES = {
'es-ES': {
literalOne: 'TranslateOneEsES',
withPlural: 'uno |||| varios'
withPlural: 'uno |||| varios',
profilePathSegment: 'mi-perfil',
privacyPathSegment: 'privacidad'
},
'en-GB': {
literalOne: 'TranslateOneEnGB',
withPlural: 'one |||| many'
withPlural: 'one |||| many',
profilePathSegment: 'my-profile',
privacyPathSegment: 'privacy'
},
'ca-ES': {
literalOne: 'TranslateOneCaES',
withPlural: 'un |||| varis'
withPlural: 'un |||| varis',
profilePathSegment: 'meu-perfil',
privacyPathSegment: 'privacitat'
}
}

Expand Down
6 changes: 6 additions & 0 deletions packages/sui-i18n/test/i18nSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ describe('I18N', () => {
expect(i18n.n(1000000)).to.eql('1,000,000')
})

it('generate url properly', () => {
expect(i18n.url('/profilePathSegment/privacyPathSegment')).to.eql(
'/my-profile/privacy'
)
})

describe('with pound sterling (GBP) as currency type', () => {
beforeEach(() => {
i18n.currency = 'GBP'
Expand Down
2 changes: 2 additions & 0 deletions packages/sui-jest/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src
test
11 changes: 11 additions & 0 deletions packages/sui-jest/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# CHANGELOG

# 1.1.0 (2023-06-12)


### Features

* **packages/sui-jest:** add wrapper for jest ([f15be4c](https://github.com/SUI-Components/sui/commit/f15be4c48d8b1ade07a407c0781c79b181b4a52b))



70 changes: 70 additions & 0 deletions packages/sui-jest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# sui-jest

This is a CLI that abstracts away all configuration for [Jest](https://jestjs.io/).

## Installation

```sh
npm install -D @s-ui/jest
```

## Usage

This CLI exposes a bin called `sui-jest` with all options that [Jest CLI Options](https://jestjs.io/docs/cli) supports.

**From node**

```sh
node ./node_modules/.bin/sui-jest [Jest CLI Options]
```

**From npm script**

```json
// package.json
{
scripts: {
"test:jest": "sui-jest",
}
}
```
```sh
npm run test:jest -- [Jest CLI Options]
```

### Overriding Config

`sui-jest` allows you to specify your own configuration. There are various ways that it works, but basically if you want to have your own config for something, just add the configuration and `sui-jest` will use it instead of its own internal config.

**Specific**

From CLI using the `--config` flag with the path of the specific jest config file.

```sh
node ./node_modules/.bin/sui-jest --config jest.config.[*]
```

**Automatic**

Create a `jest.config.[*]` config file in your root project or within the `packages/*`, and `sui-jest` will use the jest config file closest to where it has been executed.

```js
// jest.config.js

module.exports = {
testEnvironment: 'jsdom',
testMatch: ['**/__tests__/**/*.test.js'],
// ...
}
```

*In construction*

In addition, `sui-jest` will expose its basic configuration so you can use it and override only the parts of the config you need to.


## Inspiration

This is inspired by [kcd-scripts](https://github.com/kentcdodds/kcd-scripts).


4 changes: 4 additions & 0 deletions packages/sui-jest/bin/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// TODO: add sui jest common config
const jestConfig = {}

module.exports = jestConfig
Loading