-
Notifications
You must be signed in to change notification settings - Fork 46.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add and compile a simple hook with rollup and babel.
- Loading branch information
Showing
5 changed files
with
638 additions
and
7 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,10 @@ | ||
const plugins = [ | ||
[ | ||
'babel-plugin-react-compiler', | ||
{ | ||
target: '18', | ||
}, | ||
], | ||
]; | ||
|
||
module.exports = {plugins}; |
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 +1,13 @@ | ||
throw new Error('Not implemented yet'); | ||
import {useState, useEffect} from 'react'; | ||
|
||
export function useTime() { | ||
const [time, setTime] = useState(() => new Date()); | ||
useEffect(() => { | ||
const id = setInterval(() => { | ||
setTime(new Date()); | ||
}, 1000); | ||
return () => clearInterval(id); | ||
}, []); | ||
|
||
return time; | ||
} |
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,51 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import json from '@rollup/plugin-json'; | ||
import terser from '@rollup/plugin-terser'; | ||
import prettier from 'rollup-plugin-prettier'; | ||
import banner2 from 'rollup-plugin-banner2'; | ||
import babel from '@rollup/plugin-babel'; | ||
|
||
const ROLLUP_CONFIG = { | ||
input: 'index.js', | ||
output: { | ||
file: 'dist/index.js', | ||
format: 'esm', | ||
sourcemap: false, | ||
exports: 'named', | ||
}, | ||
plugins: [ | ||
json(), | ||
babel({babelHelpers: 'bundled'}), | ||
terser({ | ||
format: { | ||
comments: false, | ||
}, | ||
compress: false, | ||
mangle: false, | ||
}), | ||
prettier(), | ||
banner2( | ||
() => `/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @lightSyntaxTransform | ||
* @noflow | ||
* @nolint | ||
* @preventMunge | ||
* @preserve-invariant-messages | ||
*/ | ||
` | ||
), | ||
], | ||
}; | ||
|
||
export default ROLLUP_CONFIG; |
Oops, something went wrong.