-
-
Notifications
You must be signed in to change notification settings - Fork 699
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #731 from fkhadra/next
V9
- Loading branch information
Showing
46 changed files
with
5,791 additions
and
6,166 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"plugin:react/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaFeatures": { | ||
"jsx": true | ||
}, | ||
"ecmaVersion": "latest", | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"react", | ||
"react-hooks", | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
"react-hooks/exhaustive-deps": "warn" | ||
} | ||
} |
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 |
---|---|---|
|
@@ -9,4 +9,5 @@ yarn-error.log | |
cjs/ | ||
esm/ | ||
dist/ | ||
.cache | ||
.cache | ||
/addons |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run prettier && npm run lint |
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,11 @@ | ||
module.exports = { | ||
presets: [ | ||
[ | ||
'@babel/preset-env', | ||
{ | ||
shippedProposals: true, | ||
targets: '>0.5%, not ie 11, not op_mini all', | ||
}, | ||
], | ||
], | ||
}; |
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,63 @@ | ||
import { existsSync } from 'node:fs'; | ||
import { readdir, readFile, writeFile, rename } from 'node:fs/promises'; | ||
import { exec } from 'node:child_process'; | ||
import path from 'node:path'; | ||
import { promisify } from 'node:util'; | ||
|
||
const asyncExec = promisify(exec); | ||
|
||
const packageJson = JSON.parse( | ||
await readFile(new URL('./package.json', import.meta.url)) | ||
); | ||
|
||
const DEBUG = process.argv.slice(2)[0] === 'debug'; | ||
const BASE_DIR = './src/addons'; | ||
const MICRO_BUNDLE = './node_modules/.bin/microbundle'; | ||
|
||
try { | ||
const dirs = await readdir(BASE_DIR); | ||
|
||
for (const dir of dirs) { | ||
let entryPoint = path.join(BASE_DIR, dir, 'index.ts'); | ||
const exportKey = `./addons/${dir}`; | ||
const exportValues = { | ||
require: '', | ||
import: '' | ||
}; | ||
|
||
if (!existsSync(entryPoint)) { | ||
if (existsSync(`${entryPoint}x`)) { | ||
entryPoint = `${entryPoint}x`; | ||
} else { | ||
throw new Error(`${entryPoint} does not exist`); | ||
} | ||
} | ||
|
||
for (const moduleType of ['cjs', 'esm']) { | ||
const filename = moduleType === 'esm' ? 'index.esm.js' : 'index.js'; | ||
const out = `./dist/addons/${dir}/${filename}`; | ||
const exportOut = `./addons/${dir}/${filename}`; | ||
|
||
const { stdout, stderr } = await asyncExec( | ||
`${MICRO_BUNDLE} -i ${entryPoint} -o ${out} --no-pkg-main -f ${moduleType} --jsx React.createElement --external react-toastify --compress ${!DEBUG}` | ||
); | ||
console.log(stdout); | ||
console.log(stderr); | ||
|
||
if (moduleType === 'cjs') { | ||
exportValues.require = exportOut; | ||
} else if (moduleType === 'esm') { | ||
exportValues.import = exportOut; | ||
} | ||
} | ||
|
||
packageJson.exports = Object.assign(packageJson.exports, { | ||
[exportKey]: exportValues | ||
}); | ||
} | ||
|
||
await writeFile('./package.json', JSON.stringify(packageJson, null, 2)); | ||
await rename('./dist/addons', './addons'); | ||
} catch (error) { | ||
throw error; | ||
} |
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
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 |
---|---|---|
@@ -1,13 +1,14 @@ | ||
import 'react-app-polyfill/ie11'; | ||
import { render } from 'react-dom'; | ||
import { createRoot } from 'react-dom/client'; | ||
import * as React from 'react'; | ||
import { App } from './components/App'; | ||
|
||
import './index.css'; | ||
|
||
render( | ||
const root = createRoot(document.getElementById('root')!); | ||
|
||
root.render( | ||
<React.StrictMode> | ||
<App /> | ||
</React.StrictMode>, | ||
document.getElementById('root') | ||
</React.StrictMode> | ||
); |
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.