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

Covert to V2 addon (a real npm package!) #345

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

NullVoxPopuli
Copy link
Contributor

@NullVoxPopuli NullVoxPopuli commented Jul 5, 2022

Changelog notes

  • BREAKING
    • requires ember-auto-import@v2 or embroider

(otherwise there is nothing changed about how @ember/string works and the two files involved (index.ts and cache.ts) show up as moves)

Changes

Much of this was done via ember init -b @embroider/blueprint --pnpm --typescript

There is some divergence, however (@ember/string is maybe not the best example of a use case for the v2 addon blueprint):

  • ci.yml / ember-try support is expanded back to ember 3.20

  • I removed @types/ember__string from the test-app, because we build the types here

  • I removed glint because this package does not need that tool, and tsc is sufficient

  • I removed linting from the test command in the test-app. it's silly as we have a separate lint command in CI having lint in the test command made the top-level pnpm test command do too much. Now test just means test.

  • tsconfig.json has additional settings set because declaration emit is kind of wonkey and we may want to consider adding a separate @tsconfig/ember (maybe @tsconfig/esm-library?) because @tsconfig/ember is currently splitting duty between libraries and apps, and trying to make both happy, even though apps are non-spec compliant, for the most part)

  • vitest for tests (in addition to the test-app (this was done in the original pass at conversion back in 2022))

    • this is because @ember/string is legit nothing special and requires no ember APIs. For folks working in this repo, this means they'll have instant test feedback and better editor integration when working in tests
    • If maintainers don't want this, I can move all the tests back to the ember app, but I think it's good to have as an example for certain types of utility libraries
    • the test app is stictly to check that the v2 addon boilerplate is correctly configured (addon-main.cjs, keywords: [ember-addon], etc).

Things we could do since @ember/string has no ember api usage

  • make it a real ESM package (type=module), remove keywords: [ember-addon], remove package.json#ember-addon, etc
  • for the type of library that @ember/string is, the v2 addon format is more boilerplate plate than we need and sets us back a bit from where we could be (still ahead of a v1 addon though!)

Unrelated changes

  • tests are now in TypeScript

@NullVoxPopuli NullVoxPopuli marked this pull request as ready for review July 9, 2022 02:12
jobs:
test:
name: Tests
name: "Tests"
runs-on: ubuntu-latest

steps:
Copy link
Member

Choose a reason for hiding this comment

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

Did we lose testing against multiple node versions here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I forgot to answer this!

There is no need, because the output of this repo is browser-code, so node isn't relevant.

package.json Outdated Show resolved Hide resolved
@NullVoxPopuli
Copy link
Contributor Author

NullVoxPopuli commented Jul 21, 2022

Gonna pull some smaller PRs out of this, since folks are interested in @ember/string again 🥳

I also want to use this as an opportunity to see how v2 addon conversions work.
It's not all that much, but it is precise.

(if a maintainer wants to convert this PR back to "Draft", that'd be appreciated <3 )

The order will be (and I'll link to these PRs as they're created):

  1. switch to pnpm
  2. convert to monorepo
  3. extract dummy / tests app to its own package / app (adding typescript to the tests app might be a separate PR, I'm not sure yet)
  4. convert addon to v2 addon
  5. convert core test suite to vitest (way faster than booting up an ember app, and we don't interact with any ember apis) -- the ember app will still stay (like it is in this PR, but it'll have fewer tests)

As this happens, the "diff" of this PR will get much smaller (even though most of it is lockfile, and js->ts conversions).
I don't think we need to do any releasing throughout this process.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

basically an original file!

) => initialChar + (chr ? chr.toUpperCase() : '');
const parts = str.split('/');

for (let i = 0; i < parts.length; i++) {
parts[i] = parts[i]
parts[i] = (parts as any)[i]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

added because TS has gotten stricter since this PR was initially opened and TS now considers this dangerous -- it would be great though if it could determine that i was bounded to the range within parts

.replace(STRING_CLASSIFY_REGEXP_1, replace1)
.replace(STRING_CLASSIFY_REGEXP_2, replace2);
}

return parts
.join('/')
.replace(STRING_CLASSIFY_REGEXP_3, (match /*, separator, chr */) =>
match.toUpperCase()
match.toUpperCase(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

newer prettier version wanted commas 🤷

"compilerOptions": {
"allowJs": true,
"declarationDir": "declarations",
"noEmit": false,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

these 3 settings here were required to generate declarations with tsc --declaration.

I need to look in to if it makes sense to put these in the addon-blueprint, or if we should just "fork" @tsconfig/ember at this point (still in tsconfig/bases tho) maybe with a v2 app the delta can start shrinking again

Add LTS 5.4

Run ember init to sync with blueprint

Lint:fix

Lint:fix

Fix package.json

Fix types build

tsc args!

Can we have the same compatibility as before?

Re-add the tests workspace

The test-app does not need to lint in order to test

Try to re-gain ember 3.20+ compat

Drop support for ember < 3.28

delete more glint stuff
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.

2 participants