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

Convert addon to TypeScript & add glint #581

Merged
merged 35 commits into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a4a0ed2
Convert addon to TS
mkszepp Sep 20, 2024
a0acbec
Convert eslint.. for TS support & update linters
mkszepp Sep 20, 2024
8ba0971
Revert comment inside drag.ts
mkszepp Sep 20, 2024
bdb02d9
Fix missing addon main file
mkszepp Sep 20, 2024
11b78ab
Fix missing addon main file
mkszepp Sep 20, 2024
c6e4a8d
Regenerate lock file
mkszepp Sep 20, 2024
4673459
Add .npmrc & add missing dependencies inside addon
mkszepp Sep 20, 2024
7c41fba
Update some packages to fix tests
mkszepp Sep 20, 2024
b85c399
Import hbs from ember-cli-htmlbars
mkszepp Sep 20, 2024
4f80164
More modernizing test app
mkszepp Sep 20, 2024
2e42bda
Drop more outdated packages from test / docs app
mkszepp Sep 20, 2024
3f8abb7
Sync `@embroider/test-setup` between test-app & docs
mkszepp Sep 20, 2024
1d8b3c8
Remove resolver.js file & add dependency injection also to docs
mkszepp Sep 20, 2024
9fa92ea
Readd lock file
mkszepp Sep 20, 2024
0c2b307
Fix test
mkszepp Sep 20, 2024
43c1bbb
Remove dependency injection in docs (isn't working)
mkszepp Sep 20, 2024
4ec6bf1
Fix lock file
mkszepp Sep 20, 2024
303a12c
Merge branch 'adopted-ember-addons:master' into convert-to-ts
mkszepp Sep 21, 2024
f9557cc
Update `@embroider/test-setup` to latest
mkszepp Sep 21, 2024
d370c9e
Disable prototype extension
mkszepp Sep 21, 2024
4df7737
Fix for ember 6
mkszepp Sep 21, 2024
6107c56
Fix docs for ember 6
mkszepp Sep 21, 2024
a884e45
Add ember-lts-v5.8 in ember-try & add try mode for test-helper v2 & v…
mkszepp Sep 21, 2024
fae3077
Replace ember-modifier-4 with ember-modifier-3 (test-app has now v4 b…
mkszepp Sep 21, 2024
281ed64
Merge branch 'master' into convert-to-ts
mkszepp Sep 21, 2024
a4248d5
Fix lock file
mkszepp Sep 21, 2024
308528e
Revert comment change in reorder test-helper
mkszepp Sep 21, 2024
0e380c5
Fix incorrect merging
mkszepp Sep 21, 2024
fbe6b78
Fix incorrect merge
mkszepp Sep 21, 2024
b895588
Remove new line
mkszepp Sep 21, 2024
5857ad2
Replace npm-run-all with concurrently
mkszepp Sep 21, 2024
84f0053
Readd `eslint-plugin-import` (was removed while merge)
mkszepp Sep 21, 2024
4a2dca2
Fix lint & readd ember-template-lint (dropped while merge)
mkszepp Sep 21, 2024
053b025
Rename `VisualClass` interface to `HandleVisualClass` and make it pub…
mkszepp Sep 21, 2024
2bee092
Improve error handing and fix interface name in template-registry
mkszepp Sep 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addon/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# compiled output
/dist/
/declarations/
/tmp/

# dependencies
Expand Down
89 changes: 89 additions & 0 deletions addon/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
'use strict';

module.exports = {
root: true,
// Only use overrides
// https://github.com/ember-cli/eslint-plugin-ember?tab=readme-ov-file#gtsgjs
overrides: [
{
files: ['**/*.js', '**/*.ts'],
env: { browser: true },
parser: '@typescript-eslint/parser',
parserOptions: {
ecmaVersion: 'latest',
},
plugins: ['ember', 'import'],
extends: ['eslint:recommended', 'plugin:ember/recommended', 'plugin:prettier/recommended'],
rules: {
// require relative imports use full extensions
'import/extensions': ['error', 'always', { ignorePackages: true }],
'ember/no-runloop': 0,
// Add any custom rules here
},
},
// ts files
{
files: ['**/*.ts'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:prettier/recommended',
],
rules: {
// require relative imports use full extensions
'import/extensions': ['error', 'always', { ignorePackages: true }],
'ember/no-runloop': 0,
// Add any custom rules here
},
},
{
files: ['**/*.gts'],
parser: 'ember-eslint-parser',
plugins: ['ember', 'import'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/eslint-recommended',
'plugin:@typescript-eslint/recommended',
'plugin:ember/recommended',
'plugin:ember/recommended-gts',
'plugin:prettier/recommended',
],
rules: {
// require relative imports use full extensions
'import/extensions': ['error', 'always', { ignorePackages: true }],
// Add any custom rules here
},
},
{
files: ['**/*.gjs'],
parser: 'ember-eslint-parser',
plugins: ['ember', 'import'],
extends: [
'eslint:recommended',
'plugin:ember/recommended',
'plugin:ember/recommended-gjs',
'plugin:prettier/recommended',
],
rules: {
// require relative imports use full extensions
'import/extensions': ['error', 'always', { ignorePackages: true }],
// Add any custom rules here
},
},
// node files
{
files: ['./.eslintrc.cjs', './.prettierrc.cjs', './.template-lintrc.cjs', './addon-main.cjs'],
parserOptions: {
sourceType: 'script',
},
env: {
browser: false,
node: true,
},
plugins: ['n'],
extends: ['eslint:recommended', 'plugin:n/recommended', 'plugin:prettier/recommended'],
},
],
};
44 changes: 0 additions & 44 deletions addon/.eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions addon/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ LICENSE.md

# compiled output
/dist/
/declarations/
/tmp/

# dependencies
Expand Down
1 change: 1 addition & 0 deletions addon/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

# compiled output
/dist/
/declarations/
/tmp/

# dependencies
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions addon/addon-main.js → addon/addon-main.cjs
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
'use strict';

const { addonV1Shim } = require('@embroider/addon-shim');
module.exports = addonV1Shim(__dirname);
1 change: 1 addition & 0 deletions addon/babel.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"plugins": [
["@babel/plugin-transform-typescript", { "allExtensions": true, "onlyRemoveTypeImports": true, "allowDeclareFields": true }],
"@embroider/addon-dev/template-colocation-plugin",
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-class-properties"
Expand Down
85 changes: 72 additions & 13 deletions addon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,48 @@
"test": "tests"
},
"exports": {
".": "./dist/index.js",
".": {
"types": "./declarations/index.d.ts",
"default": "./dist/index.js"
},
"./*": {
"types": "./declarations/*.d.ts",
"default": "./dist/*.js"
},
"./_app_/*": "./dist/_app_/*.js",
"./modifiers/*": "./dist/modifiers/*.js",
"./services/*": "./dist/services/*.js",
"./test-support": "./dist/test-support/index.js",
"./addon-main.js": "./addon-main.js"
"./addon-main.js": "./addon-main.cjs"
},
"typesVersions": {
"*": {
"*": [
"declarations/*"
]
}
},
"files": [
"addon-main.js",
"addon-main.cjs",
"declarations",
"dist"
],
"scripts": {
"build": "rollup --config",
"prepack": "rollup --config",
"lint": "npm-run-all --aggregate-output --continue-on-error --parallel \"lint:!(fix)\"",
"build": "concurrently 'pnpm:build:*'",
"build:js": "rollup --config",
"build:types": "glint --declaration",
"lint": "concurrently 'pnpm:lint:*(!fix)' --names 'lint:'",
"lint:fix": "concurrently 'pnpm:lint:*:fix' --names 'fix:'",
"lint:hbs": "ember-template-lint . --no-error-on-unmatched-pattern",
"lint:hbs:fix": "ember-template-lint . --fix --no-error-on-unmatched-pattern",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"start": "rollup --config --watch",
"test": "echo 'Addon does not have tests, run tests in test-app'"
"lint:types": "glint",
"prepack": "concurrently 'pnpm:build:*'",
"start": "concurrently 'pnpm:start:*'",
"start:js": "rollup --config --watch --no-watch.clearScreen",
"start:types": "glint --declaration --watch",
"test": "echo 'A v2 addon does not have tests, run tests in test-app'"
},
"peerDependencies": {
"ember-modifier": "^3.2.0 || >= 4.0.0",
Expand All @@ -41,26 +64,62 @@
"ember-source": "^3.28.0 || >= 4.0.0"
},
"dependencies": {
"@embroider/addon-shim": "^1.8.9"
"@embroider/addon-shim": "^1.8.9",
"@embroider/macros": "^1.16.6",
"@glimmer/env": "^0.1.7",
"rsvp": "^4.8.5"
Comment on lines +68 to +70
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this dependencies were always missed 😁, but used inside addon

},
"devDependencies": {
"@babel/core": "^7.25.2",
"@babel/eslint-parser": "^7.11.0",
"@babel/plugin-proposal-class-properties": "^7.18.6",
"@babel/plugin-proposal-decorators": "^7.24.7",
"@babel/plugin-transform-typescript": "^7.25.2",
"@ember/test-helpers": "^4.0.4",
"@ember/test-waiters": "^3.1.0",
"@embroider/addon-dev": "^5.0.0",
"@glimmer/component": "^1.1.2",
"@glint/core": "^1.4.0",
"@glint/environment-ember-loose": "^1.4.0",
"@glint/environment-ember-template-imports": "^1.4.0",
"@glint/template": "^1.4.0",
"@rollup/plugin-babel": "^6.0.4",
"@babel/eslint-parser": "^7.25.1",
"@tsconfig/ember": "^3.0.8",
"@types/ember": "^4.0.11",
"@types/ember__application": "^4.0.11",
"@types/ember__array": "^4.0.10",
"@types/ember__component": "^4.0.22",
"@types/ember__controller": "^4.0.12",
"@types/ember__debug": "^4.0.8",
"@types/ember__engine": "^4.0.11",
"@types/ember__error": "^4.0.6",
"@types/ember__helper": "^4.0.8",
"@types/ember__modifier": "^4.0.9",
"@types/ember__object": "^4.0.12",
"@types/ember__owner": "^4.0.9",
"@types/ember__polyfills": "^4.0.6",
"@types/ember__routing": "^4.0.22",
"@types/ember__runloop": "^4.0.10",
"@types/ember__service": "^4.0.9",
"@types/ember__string": "^3.16.3",
"@types/ember__template": "^4.0.7",
"@types/ember__test": "^4.0.6",
"@types/ember__utils": "^4.0.7",
"@types/ember__destroyable": "^4.0.5",
"@types/rsvp": "^4.0.9",
"@typescript-eslint/eslint-plugin": "^8.3.0",
"@typescript-eslint/parser": "^8.3.0",
"babel-plugin-ember-template-compilation": "^2.2.5",
"concurrently": "^9.0.1",
"ember-modifier": "^4.2.0",
"ember-template-lint": "^6.0.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-ember": "^12.2.0",
"eslint-plugin-import": "^2.30.0",
"eslint-plugin-n": "^17.10.3",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-qunit": "^8.1.2",
"npm-run-all2": "^6.2.3",
"prettier": "^3.3.3",
"rollup": "^3.29.5",
"rollup-plugin-copy": "^3.5.0",
Expand All @@ -77,9 +136,9 @@
"edition": "octane"
},
"ember-addon": {
"main": "addon-main.js",
"type": "addon",
"version": 2,
"type": "addon",
"main": "addon-main.cjs",
"demoURL": "https://ember-sortable.netlify.app/",
"app-js": {
"./modifiers/sortable-group.js": "./dist/_app_/modifiers/sortable-group.js",
Expand Down
11 changes: 10 additions & 1 deletion addon/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@ export default {
plugins: [
// These are the modules that users should be able to import from your
// addon. Anything not listed here may get optimized away.
addon.publicEntrypoints(['**/*.js']),
addon.publicEntrypoints([
'modifiers/**/*.js',
'services/**/*.js',
'test-support/**/*.js',
'utils/**/*.js',
]),

// These are the modules that should get reexported into the traditional
// "app" tree. Things in here should also be in publicEntrypoints above, but
Expand All @@ -29,6 +34,7 @@ export default {
// By default, this will load the actual babel config from the file
// babel.config.json.
babel({
extensions: ['.js', '.gjs', '.ts', '.gts'],
babelHelpers: 'bundled',
}),

Expand All @@ -40,6 +46,9 @@ export default {
// Ensure that standalone .hbs files are properly integrated as Javascript.
addon.hbs(),

// Ensure that .gjs files are properly integrated as Javascript
addon.gjs(),

// addons are allowed to contain imports of .css files, which we want rollup
// to leave alone and keep in the published output.
addon.keepAssets(['**/*.css']),
Expand Down
Loading
Loading