-
-
Notifications
You must be signed in to change notification settings - Fork 73
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
Isolate cookiebar module JS #119
Conversation
ac283e7
to
3a307fa
Compare
6f117ea
to
6c37cf0
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #119 +/- ##
==========================================
- Coverage 96.08% 96.03% -0.05%
==========================================
Files 12 11 -1
Lines 409 404 -5
Branches 70 52 -18
==========================================
- Hits 393 388 -5
Misses 11 11
Partials 5 5 ☔ View full report in Codecov by Sentry. |
Added boilerplate to create/bundle an npm package on Github, so that the build artifact(s) can be included in the static files of the django app for ease of use, and other projects can separately install the package for the JS with npm to bundle the JS with their own solution.
The added type safety helps catch bugs, and the setup is simple enough for people not too familiar with TS to be able to contribute. Small refactors have been done to avoid globals and localize state a bit more, which shouldn't affect anyone.
The cookiebar module TS source is taken as input, and the resulting bundle written to the cookie consent staticfiles directory.
The npm 'package' and the django staticfiles assets are exclusively to be built in the CI pipeline, and not kept in version control. This keeps a single source of truth and prevents us from forgetting to update the artifacts, at the cost of a little extra step for local development.
Ensure that the frontend package version is also bumped.
A package with type: module requires extensions in the imports to fully resolve them (tested with Webpack 5). We can simply use the .js extension even in .ts files, tsc understands it (even though this looks really weird).
6c37cf0
to
874a94c
Compare
The code is different from 0.5.0 beta 0, and the next release will be 0.6.0.
874a94c
to
0191b88
Compare
This puts the source code for the cookiebar module in its own source directory, allowing us to use Typescript to compile it down to JS.
Advantages:
TODO:
Expose package on Github (perhaps explore github packages as an alternative to npm registry?)not viable, see Need to make npm package public #120Ensure that the CI pipeline builds and publishes the build artifacts (so thatpublishing can't be automated at the momentnpm install https://...
works properly)static/cookie_consent/cookiebar.module.js