Skip to content

Commit

Permalink
Fix fixtures for Embroider + TypeScript
Browse files Browse the repository at this point in the history
Fixes after review

Fixes after Dan's review

Fixes after rebase

Add declarations to gitignore
  • Loading branch information
simonihmig committed Jun 29, 2023
1 parent d337b6f commit 7710aa0
Show file tree
Hide file tree
Showing 20 changed files with 254 additions and 81 deletions.
6 changes: 5 additions & 1 deletion blueprints/addon/files/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
'use strict';

module.exports = {
name: require('./package').name,
name: require('./package').name,<% if (typescript) {%>

options: {
'ember-cli-babel': { enableTypeScriptTransform: true },
},<% } %>
};
6 changes: 3 additions & 3 deletions blueprints/addon/files/tsconfig.declarations.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"compilerOptions": {
"declarationDir": "declarations",
"emitDeclarationOnly": true,
"isolatedModules": false,
"noEmit": false
"noEmit": false,
"rootDir": "."
},
"include": ["addon/**/*", "types/**/*", "addon-test-support/**/*"]
"include": ["addon", "addon-test-support"]
}
18 changes: 5 additions & 13 deletions blueprints/addon/files/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,11 @@
"paths": {
"dummy/tests/*": ["tests/*"],
"dummy/*": ["tests/dummy/app/*", "app/*"],
"my-addon": ["addon"],
"my-addon/*": ["addon/*"],
"my-addon/test-support": ["addon-test-support"],
"my-addon/test-support/*": ["addon-test-support/*"],
"<%= addonName %>": ["addon"],
"<%= addonName %>/*": ["addon/*"],
"<%= addonName %>/test-support": ["addon-test-support"],
"<%= addonName %>/test-support/*": ["addon-test-support/*"],
"*": ["types/*"]
}
},
"include": [
"app/**/*",
"addon/**/*",
"tests/**/*",
"types/**/*",
"test-support/**/*",
"addon-test-support/**/*"
]
}
}
7 changes: 5 additions & 2 deletions blueprints/addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,16 @@ module.exports = {

// add scripts to build type declarations for TypeScript addons
if (this.options.typescript) {
contents.devDependencies.rimraf = '^5.0.1';

contents.scripts.prepack = 'tsc --project tsconfig.declarations.json';
contents.scripts.postpack = 'rimraf declarations';

contents.typesVersions = {
'*': {
'test-support/*': ['declarations/addon-test-support/*'],
'*': ['declarations/addon/*'],
'test-support': ['declarations/addon-test-support/index.d.ts'],
'test-support/*': ['declarations/addon-test-support/*', 'declarations/addon-test-support/*/index.d.ts'],
'*': ['declarations/addon/*', 'declarations/addon/*/index.d.ts'],
},
};
}
Expand Down
1 change: 1 addition & 0 deletions blueprints/app/files/gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# compiled output
/dist/
/declarations/

# dependencies
/node_modules/
Expand Down
1 change: 0 additions & 1 deletion blueprints/app/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"@embroider/webpack": "^3.0.0<% } %>",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2<% if (typescript) { %>",
"@glint/core": "^1.0.2",
"@glint/environment-ember-loose": "^1.0.2",
"@glint/template": "^1.0.2",
"@tsconfig/ember": "^2.0.0",
Expand Down
3 changes: 1 addition & 2 deletions blueprints/app/files/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,5 @@
"<%= name %>/*": ["app/*"],
"*": ["types/*"]
}
},
"include": ["app/**/*", "tests/**/*", "types/**/*"]
}
}
1 change: 1 addition & 0 deletions tests/acceptance/new-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,7 @@ describe('Acceptance: ember new', function () {
// check fixtures
[
'.ember-cli',
'index.js',
'tests/helpers/index.ts',
'tsconfig.json',
'tsconfig.declarations.json',
Expand Down
9 changes: 9 additions & 0 deletions tests/fixtures/addon/typescript/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

module.exports = {
name: require('./package').name,

options: {
'ember-cli-babel': { enableTypeScriptTransform: true },
},
};
48 changes: 27 additions & 21 deletions tests/fixtures/addon/typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,16 @@
"author": "",
"typesVersions": {
"*": {
"test-support": [
"declarations/addon-test-support/index.d.ts"
],
"test-support/*": [
"declarations/addon-test-support/*"
"declarations/addon-test-support/*",
"declarations/addon-test-support/*/index.d.ts"
],
"*": [
"declarations/addon/*"
"declarations/addon/*",
"declarations/addon/*/index.d.ts"
]
}
},
Expand Down Expand Up @@ -46,12 +51,11 @@
},
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@ember/string": "^3.0.1",
"@ember/test-helpers": "^2.9.3",
"@embroider/test-setup": "^2.1.1",
"@ember/string": "^3.1.1",
"@ember/test-helpers": "^3.1.0",
"@embroider/test-setup": "^3.0.1",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@glint/core": "^1.0.2",
"@glint/environment-ember-loose": "^1.0.2",
"@glint/template": "^1.0.2",
"@tsconfig/ember": "^2.0.0",
Expand All @@ -78,39 +82,41 @@
"@types/ember__utils": "^4.0.2",
"@types/qunit": "^2.19.5",
"@types/rsvp": "^4.0.4",
"@typescript-eslint/eslint-plugin": "^5.59.8",
"@typescript-eslint/parser": "^5.59.8",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"broccoli-asset-rev": "^3.0.0",
"concurrently": "^8.0.1",
"concurrently": "^8.2.0",
"ember-auto-import": "^2.6.3",
"ember-cli": "~<%= emberCLIVersion %>",
"ember-cli-dependency-checker": "^3.3.1",
"ember-cli-clean-css": "^2.0.0",
"ember-cli-dependency-checker": "^3.3.2",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-cli-sri": "^2.1.1",
"ember-cli-terser": "^4.0.2",
"ember-load-initializers": "^2.1.2",
"ember-page-title": "^7.0.0",
"ember-qunit": "^6.2.0",
"ember-resolver": "^10.0.0",
"ember-source": "~4.12.0",
"ember-qunit": "^7.0.0",
"ember-resolver": "^10.1.1",
"ember-source": "~5.1.0-beta.1",
"ember-source-channel-url": "^3.0.0",
"ember-template-lint": "^5.7.2",
"ember-template-lint": "^5.10.3",
"ember-try": "^2.0.0",
"eslint": "^8.37.0",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-ember": "^11.5.0",
"eslint-plugin-n": "^15.7.0",
"eslint-plugin-ember": "^11.8.0",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-qunit": "^7.3.4",
"loader.js": "^4.7.0",
"prettier": "^2.8.7",
"prettier": "^2.8.8",
"qunit": "^2.19.4",
"qunit-dom": "^2.0.0",
"stylelint": "^15.4.0",
"stylelint-config-standard": "^32.0.0",
"rimraf": "^5.0.1",
"stylelint": "^15.8.0",
"stylelint-config-standard": "^33.0.0",
"stylelint-prettier": "^3.0.0",
"typescript": "^5.0.4",
"webpack": "^5.78.0"
"webpack": "^5.87.0"
},
"peerDependencies": {
"ember-source": ">= 4.0.0"
Expand Down
6 changes: 3 additions & 3 deletions tests/fixtures/addon/typescript/tsconfig.declarations.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"compilerOptions": {
"declarationDir": "declarations",
"emitDeclarationOnly": true,
"isolatedModules": false,
"noEmit": false
"noEmit": false,
"rootDir": "."
},
"include": ["addon/**/*", "types/**/*", "addon-test-support/**/*"]
"include": ["addon", "addon-test-support"]
}
18 changes: 5 additions & 13 deletions tests/fixtures/addon/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,11 @@
"paths": {
"dummy/tests/*": ["tests/*"],
"dummy/*": ["tests/dummy/app/*", "app/*"],
"my-addon": ["addon"],
"my-addon/*": ["addon/*"],
"my-addon/test-support": ["addon-test-support"],
"my-addon/test-support/*": ["addon-test-support/*"],
"foo": ["addon"],
"foo/*": ["addon/*"],
"foo/test-support": ["addon-test-support"],
"foo/test-support/*": ["addon-test-support/*"],
"*": ["types/*"]
}
},
"include": [
"app/**/*",
"addon/**/*",
"tests/**/*",
"types/**/*",
"test-support/**/*",
"addon-test-support/**/*"
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Type declarations for
* import config from 'foo/config/environment'
*/
declare const config: {
environment: string;
modulePrefix: string;
podModulePrefix: string;
locationType: 'history' | 'hash' | 'none' | 'auto';
rootURL: string;
APP: Record<string, unknown>;
};

export default config;
20 changes: 20 additions & 0 deletions tests/fixtures/app/typescript-embroider/ember-cli-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

const EmberApp = require('ember-cli/lib/broccoli/ember-app');

module.exports = function (defaults) {
const app = new EmberApp(defaults, {
'ember-cli-babel': { enableTypeScriptTransform: true },

// Add options here
});

const { Webpack } = require('@embroider/webpack');
return require('@embroider/compat').compatBuild(app, Webpack, {
skipBabel: [
{
package: 'qunit',
},
],
});
};
113 changes: 113 additions & 0 deletions tests/fixtures/app/typescript-embroider/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"name": "foo",
"version": "0.0.0",
"private": true,
"description": "Small description for foo goes here",
"repository": "",
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build --environment=production",
"lint": "concurrently \"npm:lint:*(!fix)\" --names \"lint:\"",
"lint:css": "stylelint \"**/*.css\"",
"lint:css:fix": "concurrently \"npm:lint:css -- --fix\"",
"lint:fix": "concurrently \"npm:lint:*:fix\" --names \"fix:\"",
"lint:hbs": "ember-template-lint .",
"lint:hbs:fix": "ember-template-lint . --fix",
"lint:js": "eslint . --cache",
"lint:js:fix": "eslint . --fix",
"lint:types": "tsc --noEmit",
"start": "ember serve",
"test": "concurrently \"npm:lint\" \"npm:test:*\" --names \"lint,test:\"",
"test:ember": "ember test"
},
"devDependencies": {
"@ember/optional-features": "^2.0.0",
"@ember/string": "^3.1.1",
"@ember/test-helpers": "^3.1.0",
"@embroider/compat": "^2.1.1",
"@embroider/core": "^2.1.1",
"@embroider/webpack": "^2.1.1",
"@glimmer/component": "^1.1.2",
"@glimmer/tracking": "^1.1.2",
"@glint/environment-ember-loose": "^1.0.2",
"@glint/template": "^1.0.2",
"@tsconfig/ember": "^2.0.0",
"@types/ember": "^4.0.3",
"@types/ember-data": "^4.4.10",
"@types/ember-data__adapter": "^4.0.1",
"@types/ember-data__model": "^4.0.0",
"@types/ember-data__serializer": "^4.0.1",
"@types/ember-data__store": "^4.0.2",
"@types/ember__application": "^4.0.5",
"@types/ember__array": "^4.0.3",
"@types/ember__component": "^4.0.13",
"@types/ember__controller": "^4.0.4",
"@types/ember__debug": "^4.0.3",
"@types/ember__destroyable": "^4.0.1",
"@types/ember__engine": "^4.0.4",
"@types/ember__error": "^4.0.2",
"@types/ember__helper": "^4.0.1",
"@types/ember__modifier": "^4.0.3",
"@types/ember__object": "^4.0.5",
"@types/ember__owner": "^4.0.3",
"@types/ember__polyfills": "^4.0.1",
"@types/ember__routing": "^4.0.12",
"@types/ember__runloop": "^4.0.2",
"@types/ember__service": "^4.0.2",
"@types/ember__string": "^3.0.10",
"@types/ember__template": "^4.0.1",
"@types/ember__test": "^4.0.1",
"@types/ember__utils": "^4.0.2",
"@types/qunit": "^2.19.5",
"@types/rsvp": "^4.0.4",
"@typescript-eslint/eslint-plugin": "^5.60.0",
"@typescript-eslint/parser": "^5.60.0",
"broccoli-asset-rev": "^3.0.0",
"concurrently": "^8.2.0",
"ember-auto-import": "^2.6.3",
"ember-cli": "~<%= emberCLIVersion %>",
"ember-cli-app-version": "^6.0.1",
"ember-cli-babel": "^7.26.11",
"ember-cli-clean-css": "^2.0.0",
"ember-cli-dependency-checker": "^3.3.2",
"ember-cli-htmlbars": "^6.2.0",
"ember-cli-inject-live-reload": "^2.1.0",
"ember-data": "~5.1.0-beta.0",
"ember-fetch": "^8.1.2",
"ember-load-initializers": "^2.1.2",
"ember-modifier": "^4.1.0",
"ember-page-title": "^7.0.0",
"ember-qunit": "^7.0.0",
"ember-resolver": "^10.1.1",
"ember-source": "~5.1.0-beta.1",
"ember-template-lint": "^5.10.3",
"ember-welcome-page": "^7.0.2",
"eslint": "^8.43.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-ember": "^11.8.0",
"eslint-plugin-n": "^16.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-qunit": "^7.3.4",
"loader.js": "^4.7.0",
"prettier": "^2.8.8",
"qunit": "^2.19.4",
"qunit-dom": "^2.0.0",
"stylelint": "^15.8.0",
"stylelint-config-standard": "^33.0.0",
"stylelint-prettier": "^3.0.0",
"tracked-built-ins": "^3.1.1",
"typescript": "^5.0.4",
"webpack": "^5.87.0"
},
"engines": {
"node": "16.* || >= 18"
},
"ember": {
"edition": "octane"
}
}
Loading

0 comments on commit 7710aa0

Please sign in to comment.