IT |
ITmedia 総合記事一覧 |
[ITmedia ビジネスオンライン] 人気の旅行先ランキング 国内と海外の1位は? |
https://www.itmedia.co.jp/business/articles/2305/21/news042.html
|
itmedia |
2023-05-21 11:25:00 |
TECH |
Techable(テッカブル) |
「Morus」がグローバル展開に向けたPreAラウンドで約2億円の資金調達を実施 |
https://techable.jp/archives/207903
|
morus |
2023-05-21 02:00:24 |
AWS |
lambdaタグが付けられた新着投稿 - Qiita |
CloudWatch LogsのメトリクスフィルターでLambdaの処理の統計情報を取得する |
https://qiita.com/neruneruo/items/56e8b5672f332239a71d
|
cloudwatchlogs |
2023-05-21 11:55:40 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
CloudFunctions(Python)でChatGPTを使った要約LINEBotを作ってみる |
https://qiita.com/ttttpzm/items/6c9542126af72c94eae0
|
chatg |
2023-05-21 11:54:43 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
[忘備録]dockerによるdjangoの起動方法 |
https://qiita.com/goto2023/items/c7477521fadbf009be52
|
django |
2023-05-21 11:42:59 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
辞書のリストの操作【Python】 |
https://qiita.com/john-rocky/items/5a62f0e725933d560ded
|
teamsteamamember |
2023-05-21 11:21:37 |
python |
Pythonタグが付けられた新着投稿 - Qiita |
ABC302回答メモ |
https://qiita.com/Konini64/items/58124051d8c4ca87ea46
|
面倒 |
2023-05-21 11:19:23 |
Linux |
Ubuntuタグが付けられた新着投稿 - Qiita |
Ubuntu UxPlay を使用してミラーリング |
https://qiita.com/pro9rae/items/14e5ff76c0f67c9aa87d
|
iphone |
2023-05-21 11:04:13 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
[忘備録]dockerによるdjangoの起動方法 |
https://qiita.com/goto2023/items/c7477521fadbf009be52
|
django |
2023-05-21 11:42:59 |
Ruby |
Railsタグが付けられた新着投稿 - Qiita |
【Rails・未経験・ポートフォリオ】stravaAPIを使用して、自転車のコース共有アプリを作成してみた |
https://qiita.com/rikuya98/items/5e0f8f54ab9d78978f7d
|
rails |
2023-05-21 11:56:43 |
技術ブログ |
Developers.IO |
[アップデート] Amazon Omics Storage のシーケンスストアへファイルを直接保存できるようになりました |
https://dev.classmethod.jp/articles/amazon-omics-storage-support-direct-upload/
|
amazonomicsstorage |
2023-05-21 02:59:25 |
海外TECH |
DEV Community |
How to develop a svelte component and publish it as a package in NPM |
https://dev.to/ernanej/how-to-develop-a-svelte-component-and-publish-it-as-a-package-in-npm-40pc
|
How to develop a svelte component and publish it as a package in NPMPublish your favorite svelte component as a package on npm and make it available for use anytime When we like a certain component that we develop we end up using and reusing it countless times in different ways that is replicating your files and logic in many different places in the project or in several other projects or simply redeploying the same component over and over again This will work of course However it is not the best way to act in this situation Imagine that you will have to carry out maintenance or simply change say the color of this component Imagine that there are Well you will have to make this change in each component present in your project correct What if it is already applied to other projects well the change should be made too The problem I think we already understood But how to solve it When it comes to a project that uses the same technology in the case that we will see in this post Svelte for example you can create a component and publish it as a package in NPM and reuse it whenever you need it That s what we ll see here for cases where the projects do not share the same technology this is a matter for another time But if you like spoilers you can read about WebComponents What will we develop I recently made a simple svelte component hence the idea of the post to perform evaluations It is simply a nest of stars and in it the user will be able to show his satisfaction with such content that the component will return the selected information in its configuration prop He will be the one we will develop For this you need to have an account on NPM have NodeJs and NPM installed on your machine and be patient to venture out Initializing the projectThe first step like any project is to create a directory for it let s go mkdir svelte star rating cd svelte star ratingNow we can actually initialize our project npm init yThis command will create a package json file and will automatically fill in some information about the package we are developing like name author description etc the y flag will perform a short auto fill If you want to do it manually run without it But don t worry you can always change package json when needed Installing required dependenciesThe next step is to install the necessary development dependencies of our package That way notice that package json will add the dev dependencies section In addition I will take the opportunity to make some changes such as name author keywords etc Feel free to fill in as you see fit Finally the package json should look like this name ernane svelte star rating version description Simple component to assign scores based on stars homepage bugs url repository type git url git keywords svelte star ratting component sapper author ernane lt ernane junior gmail com gt license MIT devDependencies rollup rollup plugin node resolve rollup plugin svelte svelte Criação do componenteAs usual I create my logic files usually in a subdirectory named src I ll follow that pattern here In this way we will create an index js file it will be the starting point of our component Basically we will import the main component of our package and export it as default in index It will be something like this src index jsimport SvelteStarRating from SvelteStarRating svelte export default SvelteStarRating As a consequence we will now have to create the file which will be our svelte component itself SvelteStarRating svelte To test it let s just put a test message at the moment lt src SvelteStarRating svelte gt lt p gt Hello World It s my first package svelte component SvelteStarRating lt p gt In this file we will have all the logic and implementation of our package In it we will add styles necessary imports among other things Let s go ahead we ll be back in it Formalizing structureNow that we have the main structure of our component we need to formalize it in our package json For this we will need to make some more changes to it main dist index js module dist index mjs svelte src index js scripts build rollup c dev rollup c w Since this part is a bit tricky let s see what it s actually doing In main we define what will be the output after the execution of the compilation script In module we define the same but as output an mjs extension file so that Node can differentiate it among the modules created with CommonJS and ES In svelte we are defining the path of our main file the index js that we created earlier And finally scripts will be the commands used for execution and compilation in development Note that the dist subdirectory which we specified in the first two commands does not exist as it will be automagically generated After these small changes our package json will look like this name ernane svelte star rating version description Simple component to assign scores based on stars main dist index js module dist index mjs svelte src index js scripts build rollup c dev rollup c w homepage bugs url repository type git url git keywords svelte star ratting component sapper author ernane lt ernane junior gmail com gt license MIT devDependencies rollup rollup plugin node resolve rollup plugin svelte svelte Creating the rollup config js fileYou are probably already familiar with this file because it is Svelte But basically we perform the basic build configuration of our simple project import svelte from rollup plugin svelte import resolve from rollup plugin node resolve const pkg require package json export default input src AtButton svelte output file pkg module format es file pkg main format umd name Name plugins svelte resolve Wow Package successfully configured for use Testing component locallyBefore we publish our new component on NPM it s always good to test it to see how it really is and if its result is satisfactory For this we can use it on our machine even before we send it for publication For this let s create in parallel a simple project in Svelte For this case I ll use svelte playground itself npx degit sveltejs template svelte playgroundThen we access the cloned project and install two initial dependencies cd svelte playground npm installNow in order to use our component as an npm package and apply it to this project we can run the following command in the directory of our svelte star rating package npm linkWith it we will get a response similar to this npm WARN svelte star rating No repository field audited packages in s packages are looking for funding run npm fund for details found vulnerabilitiesAfter that now in the svelte playground test project we can run the same command but now going to the directory of our new package on our machine npm link path svelte star ratingThat way we can use our component as a package locally and best of all in realtime Using component locallyAccess the test project we created svelte playground and run the project under development using the command present in your package json npm run devEThen access the browser at the suggested port and see the application running After that we can now apply our component to this project and thus visualize its changes at runtime for that we go to the src app svelte file to make some changes lt src app svelte gt lt script gt import StarRating from ernane svelte star rating lt script gt lt StarRating gt And then we ll have our component running locally Fantastic isn t it Now we just have to develop our new component the way we want and check if the changes made match what we want Here is the current development status of my svelte star rating Publishing package in NPMGreat we already have our component working we would like And now well now we publish it Publishing is as simple as a push check it out First you must be logged into your NPM account if you are not or don t know just follow the steps described here After being logged in and sure you want to publish the first version of your package just run the following command npm publish access publicReady you can access your profile on the NPM page and you will see a new package added Simple no Testing new NPM packageYou ve undoubtedly done this here hundreds of times or maybe less Access your package information that will tell you how to install it But following the standards you can do it with the simple npm install passing the name defined in the package json of your project i e npm i ernane svelte star ratingUsage will be the same as before import and use Well that you already know If you have any questions here is the repository that I used to store the package mentioned here in the post and the link to it already published on npm I hope you enjoyed this post and that it helped you in some way to find what you were looking for Official NPM documentation Rollup Documentation Svelte Documentation |
2023-05-21 02:24:14 |
海外ニュース |
Japan Times latest articles |
Zelenskyy uses Hiroshima G7 visit to throw spotlight back on Ukraine war |
https://www.japantimes.co.jp/news/2023/05/21/national/politics-diplomacy/ukraine-zelenskyy-g7-hiroshima/
|
Zelenskyy uses Hiroshima G visit to throw spotlight back on Ukraine warThe visit has thrown the spotlight at the G summit firmly onto the war in Ukraine and is likely to further galvanize backing for arms |
2023-05-21 11:41:44 |
海外ニュース |
Japan Times latest articles |
Trump or DeSantis? Neither, say Ukrainian-American voters angry at war stance |
https://www.japantimes.co.jp/news/2023/05/21/world/politics-diplomacy-world/ukrainian-americans-trump-desantis/
|
Trump or DeSantis Neither say Ukrainian American voters angry at war stanceAmericans claiming Ukrainian descent may only total close to million but they are densely distributed in competitive areas |
2023-05-21 11:35:23 |
ニュース |
BBC News - Home |
Martin Amis: Celebrated British novelist dies aged 73 |
https://www.bbc.co.uk/news/entertainment-arts-65660768?at_medium=RSS&at_campaign=KARANGA
|
london |
2023-05-21 02:51:39 |
ビジネス |
東洋経済オンライン |
「仕事の質とスピードを両立」するシンプルな法則 「仕事の質」は相手のニーズから逆算して考える | リーダーシップ・教養・資格・スキル | 東洋経済オンライン |
https://toyokeizai.net/articles/-/672350?utm_source=rss&utm_medium=http&utm_campaign=link_back
|
東洋経済オンライン |
2023-05-21 11:30:00 |
海外TECH |
reddit |
[Highlight] Nikola Jokic is called for his 4th personal foul on a controversial call |
https://www.reddit.com/r/nba/comments/13ng1o1/highlight_nikola_jokic_is_called_for_his_4th/
|
Highlight Nikola Jokic is called for his th personal foul on a controversial call submitted by u NitroXYZ to r nba link comments |
2023-05-21 02:13:55 |
コメント
コメントを投稿