-
Notifications
You must be signed in to change notification settings - Fork 0
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
Test bundler module res #124
Conversation
…atform into test-bundler-module-res
@@ -35,7 +36,7 @@ const LocalizedLink = ({ | |||
...rest | |||
}: LocalizedLinkProps) => { | |||
let locale = linkLang; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't found a nice way to import these routes, so far only a json file has worked with the nextjs.config rewrites. Adding a TODO
to look at a way to get rid of the as
here
|
||
import { version } from '@/../../package.json'; | ||
import logger from '@/logger'; | ||
import packageJson from '../../package.json' assert { type: 'json' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these absolute import paths can be troubleshot. I have a fix for them (to be applied in the next PR)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joneubank pointed out that absolute paths, while looking nice and tidy, can actually add confusion, and the esm standard is for relative paths anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they can also cleanup in some cases. ideally we could use both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right, relative is the ESM standard, but they make PR reviewing (as you don't have a full IDE in github), and they also make app onboarding so much harder (chasing the "dot dot rabbit" down its hole, vs "ah, this comes from the global utils" at first glance).
besides, just like having types in a js file (which is not js spec either), absolute paths are something we can handle through TS transpilation
@@ -1,4 +1,4 @@ | |||
import { Prisma, ConsentCategory } from '../../src/generated/client'; | |||
import { Prisma, ConsentCategory } from '../../src/generated/client/index.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oof. now this one "requirement" will sting for a lot of people 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yuuuuup.
|
||
import { ValidLanguage } from '@/i18n'; | ||
import ConsentForm from '@/components/ConsentForm'; | ||
import { ValidLanguage } from 'src/i18n'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this absolute path work because of nextjs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes appears it is nextjs + the bundler setting magic
"node": ">=18" | ||
}, | ||
"node": ">=18" | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious about this change. is this project using tabs or spaces?
edit: checked, it's spaces. I was under the impression we were going to use tabs in all new projects 🤔
did we change direction?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the linter settings (which apply things like tabs instead of spaces on fix-on-save) haven't been configured for all files in the repo (like package.json files), and when I was initially setting up the repo I was still using spaces so this may be a holdover from back then
In other words... my bad 🙈 This one's totally on me haha
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
absolutely terrible. I'm heartbroken!!
how dare you!? 😂
/s
Co-authored-by: Anders Richardsson <2107110+justincorrigible@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Tested locally and confirmed things are still building, running in dev, and now actually running with the start
command too 😅 Thanks so much for going down the rabbit holes required to get this all in! 🙌 🙇
Other than the little README update we talked about on Slack, this looks good to go 🚀
…atform into test-bundler-module-res
1819a8b
README.md
Outdated
@@ -41,12 +41,14 @@ The directory structure is as follows: | |||
│ └── src | |||
├── docker-scripts/ ← Docker Init Scripts | |||
└── packages/ | |||
├── common/ ← Shared Validation & Types | |||
│ └── src | |||
├── types/ ← Shared Validation & Types/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: Looks like we've got some rogue trailing slashes here: & Types/
, Logger/
, APIs/
-- also do you mind putting these in alphabetical order like they appear in the directory?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 (for reals this time)
Converting all apps and packages to use the ESM format, EXCLUDING
consent-ui
. This is the general direction JS is moving and we have already run into issues with newer versions of external libraries, i.e.url-join
andnanoid
.Change summary:
package.json
files:type: module
.npmrc
engine-strict=true
setting)null
as these shouldn't need to be imported anywhere"main"
to"exports"
field to match esm recommendationstart
script will usets-node
to run from thesrc
folder to avoid an issue encountered with theprisma
generated client folder, which was not being added to thedist
folder on build, as per @justincorrigible 's suggestion"workspace:^"
references to use the^
instead of*
syntax, for consistency. This is how it appears when installing a local package withpnpm add <package>
tsconfig.base.json
:module
andmoduleResolution settings
will beNodeNext
as recommended here,target
becomesESNext
extended
tsconfig.json
files:tsnode.esm
to true, cannot run without thistsnode.logError
to true to prevent apps running start script withts-node
from crashing if any type errors are encounteredconsent-ui
:Bundler
option recommended here, to continue taking advantage of nextjs magic.type: module
because this broke the postcss/tailwind styles@
alias for absolute imports, but will continue using this kind of import hereGeneral:
.js
file extensions to all imports, the path cannot be resolved properly otherwisepackage.json
in all apps.assert { type: 'json' }
required on the import to align with changes in Node 17, as mentioned here0.1.0
Packages:
common
renamed totypes
types
folderstypes
package.json to allow submodule imports, and updates all import statementsDocumentation will be added for all of this in #128