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

Hds-1742: build and publish hds-js package #1206

Merged
merged 7 commits into from
Jan 16, 2024

Conversation

NikoHelle
Copy link
Contributor

Description

Vanilla JS package for HDS: hds-js!

The hds-js exports code from the hds-react. It has no own source files. Bundled code is hand-picked and added to thepackages/hds-js/index.ts.

This way the hds-js is very light and does not require tests or dependencies or pipelines.

Components, React or CSS are not exported. There are checks to make sure the package has only vanilla js.

Closes https://helsinkisolutionoffice.atlassian.net/browse/HDS-1742

Motivation and Context

CookieConsent read/write functions are needed without React. Non-React parts of the Login are also bundled.

How Has This Been Tested?

The result has been released as v3.4.0-alpha.6.

A vanilla-js app has been created with Vite and is attached to this PR. Unzipit, run yarn and then yarn dev.

hds-js-test.zip

Add to changelog

  • Added needed line to changelog

@NikoHelle NikoHelle requested review from a team January 5, 2024 20:24
Copy link
Contributor

@mrTuomoK mrTuomoK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good jooooob! 👍

No need for manual lists.

Tried also plugin "rollup-plugin-auto-external", but it messes up imports by using sometimes "import '../.../node_modules/x" instead of "import x"

It also breaks regular expressions in extrenals-list and babel runtimes are not included.

Note: babel/runtime/* are not imported anymore in lib/index.js. Downshift includes them.
exports.ts includes all files exported as hds-js package.

To get all login related vanilla js code, the vanilla js had to be split from all exports in the login component.

.gitignore and .npmignore are copies of the React version, without some files related only to that package.
hds-js is built like React, but without css.

Also dependencies of the hds-js/package.json are updated via rollup, with  yarn update:hds-js

The code is built with yarn build:hds-js.

Practically build/update:hds-js build the same esm version. Update also re-creates the package.json

Styles should not be linted with hds-js, so created new scripts from linting.
Added checks to make sure react or css is not included in the hds-js bundle.

Also warns/throws if a node_module is bundled.
The bundled cjs/*.* has same filenames as the source. So result would be exports.js.
@NikoHelle NikoHelle force-pushed the hds-1742-hds-js-package branch from 2f0806b to 6b2221f Compare January 16, 2024 07:45
@NikoHelle NikoHelle merged commit 3760c10 into development Jan 16, 2024
6 checks passed
@NikoHelle NikoHelle deleted the hds-1742-hds-js-package branch January 16, 2024 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants