ember-service-import-polyfill 0.0.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,26 @@
1
+ {
2
+ "solution": {
3
+ "ember-service-import-polyfill": {
4
+ "impact": "major",
5
+ "oldVersion": "0.0.0",
6
+ "newVersion": "1.0.0",
7
+ "tagName": "latest",
8
+ "constraints": [
9
+ {
10
+ "impact": "major",
11
+ "reason": "Appears in changelog section :boom: Breaking Change"
12
+ },
13
+ {
14
+ "impact": "patch",
15
+ "reason": "Appears in changelog section :memo: Documentation"
16
+ },
17
+ {
18
+ "impact": "patch",
19
+ "reason": "Appears in changelog section :house: Internal"
20
+ }
21
+ ],
22
+ "pkgJSONPath": "./package.json"
23
+ }
24
+ },
25
+ "description": "## Release (2026-07-21)\n\n* ember-service-import-polyfill 1.0.0 (major)\n\n#### :boom: Breaking Change\n* `ember-service-import-polyfill`\n * [#2](https://github.com/mansona/ember-service-import-polyfill/pull/2) add babel-plugin for old Ember versions ([@mansona](https://github.com/mansona))\n\n#### :memo: Documentation\n* `ember-service-import-polyfill`\n * [#3](https://github.com/mansona/ember-service-import-polyfill/pull/3) add a readme ([@mansona](https://github.com/mansona))\n\n#### :house: Internal\n* `ember-service-import-polyfill`\n * [#6](https://github.com/mansona/ember-service-import-polyfill/pull/6) ignore CHANGELOG in prettier ([@mansona](https://github.com/mansona))\n * [#4](https://github.com/mansona/ember-service-import-polyfill/pull/4) add release-plan ([@mansona](https://github.com/mansona))\n * [#1](https://github.com/mansona/ember-service-import-polyfill/pull/1) Basic test setup ([@mansona](https://github.com/mansona))\n\n#### Committers: 1\n- Chris Manson ([@mansona](https://github.com/mansona))\n"
26
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ ## Release (2026-07-21)
4
+
5
+ * ember-service-import-polyfill 1.0.0 (major)
6
+
7
+ #### :boom: Breaking Change
8
+ * `ember-service-import-polyfill`
9
+ * [#2](https://github.com/mansona/ember-service-import-polyfill/pull/2) add babel-plugin for old Ember versions ([@mansona](https://github.com/mansona))
10
+
11
+ #### :memo: Documentation
12
+ * `ember-service-import-polyfill`
13
+ * [#3](https://github.com/mansona/ember-service-import-polyfill/pull/3) add a readme ([@mansona](https://github.com/mansona))
14
+
15
+ #### :house: Internal
16
+ * `ember-service-import-polyfill`
17
+ * [#6](https://github.com/mansona/ember-service-import-polyfill/pull/6) ignore CHANGELOG in prettier ([@mansona](https://github.com/mansona))
18
+ * [#4](https://github.com/mansona/ember-service-import-polyfill/pull/4) add release-plan ([@mansona](https://github.com/mansona))
19
+ * [#1](https://github.com/mansona/ember-service-import-polyfill/pull/1) Basic test setup ([@mansona](https://github.com/mansona))
20
+
21
+ #### Committers: 1
22
+ - Chris Manson ([@mansona](https://github.com/mansona))
package/README.md CHANGED
@@ -1,12 +1,26 @@
1
1
  # ember-service-import-polyfill
2
2
 
3
- [Short description of the addon.]
3
+ This is a simple babel polyfill that adds backwards compatibility for the new service import so that addons can support a range of Ember.js that is < v4.1 and > 7.0.
4
+
5
+ If you are on an old enough version of Ember this addon will automatically install a babel plugin that rewrites:
6
+
7
+ ```js
8
+ import { service } from "@ember/service";
9
+ ```
10
+
11
+ to
12
+
13
+ ```js
14
+ import { inject as service } from "@ember/service";
15
+ ```
16
+
17
+ This allows addon authors to write their code in the new style without dropping support for older Ember versions 🎉 If you are developing a v1 addon and want to continue to support Ember < 4.1 then you can add this addon to your **dependencies**.
4
18
 
5
19
  ## Compatibility
6
20
 
7
- - Ember.js v5.8 or above
8
- - Ember CLI v5.8 or above
9
- - Node.js v20 or above
21
+ This addon is inert in Ember versions >= 4.1
22
+
23
+ This addon is tested in Node.js v20 - it will likely will work on older versions, we just don't test it
10
24
 
11
25
  ## Installation
12
26
 
@@ -14,10 +28,6 @@
14
28
  ember install ember-service-import-polyfill
15
29
  ```
16
30
 
17
- ## Usage
18
-
19
- [Longer description of how to use the addon in apps.]
20
-
21
31
  ## Contributing
22
32
 
23
33
  See the [Contributing](CONTRIBUTING.md) guide for details.
package/RELEASE.md ADDED
@@ -0,0 +1,27 @@
1
+ # Release Process
2
+
3
+ Releases in this repo are mostly automated using [release-plan](https://github.com/embroider-build/release-plan/). Once you label all your PRs correctly (see below) you will have an automatically generated PR that updates your CHANGELOG.md file and a `.release-plan.json` that is used to prepare the release once the PR is merged.
4
+
5
+ ## Preparation
6
+
7
+ Since the majority of the actual release process is automated, the remaining tasks before releasing are:
8
+
9
+ - correctly labeling **all** pull requests that have been merged since the last release
10
+ - updating pull request titles so they make sense to our users
11
+
12
+ Some great information on why this is important can be found at [keepachangelog.com](https://keepachangelog.com/en/1.1.0/), but the overall
13
+ guiding principle here is that changelogs are for humans, not machines.
14
+
15
+ When reviewing merged PR's the labels to be used are:
16
+
17
+ - breaking - Used when the PR is considered a breaking change.
18
+ - enhancement - Used when the PR adds a new feature or enhancement.
19
+ - bug - Used when the PR fixes a bug included in a previous release.
20
+ - documentation - Used when the PR adds or updates documentation.
21
+ - internal - Internal changes or things that don't fit in any other category.
22
+
23
+ **Note:** `release-plan` requires that **all** PRs are labeled. If a PR doesn't fit in a category it's fine to label it as `internal`
24
+
25
+ ## Release
26
+
27
+ Once the prep work is completed, the actual release is straight forward: you just need to merge the open [Plan Release](https://github.com/mansona/ember-service-import-polyfill/pulls?q=is%3Apr+is%3Aopen+%22Prepare+Release%22+in%3Atitle) PR
@@ -0,0 +1,19 @@
1
+ module.exports = function () {
2
+ return {
3
+ name: 'undeprecate-inject-from-at-ember-service',
4
+ visitor: {
5
+ ImportDeclaration(path) {
6
+ if (path.node.source.value === '@ember/service') {
7
+ for (let specifier of path.node.specifiers) {
8
+ if (
9
+ specifier.type === 'ImportSpecifier' &&
10
+ specifier.imported.name === 'service'
11
+ ) {
12
+ specifier.imported.name = 'inject';
13
+ }
14
+ }
15
+ }
16
+ },
17
+ },
18
+ };
19
+ };
package/index.js CHANGED
@@ -1,5 +1,22 @@
1
1
  'use strict';
2
2
 
3
+ var VersionChecker = require('ember-cli-version-checker');
4
+
3
5
  module.exports = {
4
6
  name: require('./package').name,
7
+
8
+ included: function (app) {
9
+ this._super.included.apply(this, arguments);
10
+
11
+ let checker = new VersionChecker(this.project);
12
+ let dep = checker.for('ember-source');
13
+
14
+ if (dep.lt('4.1.0')) {
15
+ app.options = app.options || {};
16
+ app.options.babel = app.options.babel || {};
17
+ app.options.babel.plugins = app.options.babel.plugins || [];
18
+
19
+ app.options.babel.plugins.push(require.resolve('./babel-plugin.js'));
20
+ }
21
+ },
5
22
  };
@@ -0,0 +1,72 @@
1
+ import babel from '@babel/core';
2
+ import plugin from '../babel-plugin.js';
3
+ import { describe, it, expect } from 'vitest';
4
+
5
+ function verify(input, expectedOutput) {
6
+ const result = babel.transformSync(input, {
7
+ plugins: [plugin],
8
+ parserOpts: {
9
+ sourceType: 'module',
10
+ },
11
+ }).code;
12
+
13
+ expect(result).toBe(expectedOutput);
14
+ }
15
+
16
+ describe('babel plugin', () => {
17
+ it('transforms service import', () => {
18
+ verify(
19
+ "import { service } from '@ember/service';",
20
+ "import { inject as service } from '@ember/service';",
21
+ );
22
+ });
23
+
24
+ it('transforms multi inject import', () => {
25
+ verify(
26
+ "import { inject, service } from '@ember/service';",
27
+ "import { inject, inject as service } from '@ember/service';",
28
+ );
29
+ });
30
+
31
+ it('transforms mixed imports with inject', () => {
32
+ verify(
33
+ "import { service, getOwner } from '@ember/service';",
34
+ "import { inject as service, getOwner } from '@ember/service';",
35
+ );
36
+ });
37
+
38
+ it('doesnt transform inject as service with other imports', () => {
39
+ verify(
40
+ "import { inject as service, getOwner } from '@ember/service';",
41
+ "import { inject as service, getOwner } from '@ember/service';",
42
+ );
43
+ });
44
+
45
+ it('leaves other imports unchanged', () => {
46
+ verify(
47
+ "import { getOwner } from '@ember/service';",
48
+ "import { getOwner } from '@ember/service';",
49
+ );
50
+ });
51
+
52
+ it('leaves inject import unchanged', () => {
53
+ verify(
54
+ "import { inject } from '@ember/service';",
55
+ "import { inject } from '@ember/service';",
56
+ );
57
+ });
58
+
59
+ it('ignores imports from other modules', () => {
60
+ verify(
61
+ "import { inject, service } from '@ember/object';",
62
+ "import { inject, service } from '@ember/object';",
63
+ );
64
+ });
65
+
66
+ it('handles default imports alongside named imports', () => {
67
+ verify(
68
+ "import Service, { service } from '@ember/service';",
69
+ "import Service, { inject as service } from '@ember/service';",
70
+ );
71
+ });
72
+ });
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "ember-service-import-polyfill",
3
- "version": "0.0.0",
3
+ "version": "1.0.0",
4
4
  "description": "The default blueprint for ember-cli addons.",
5
5
  "keywords": [
6
6
  "ember-addon"
7
7
  ],
8
- "repository": "",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git@github.com:mansona/ember-service-import-polyfill.git"
11
+ },
9
12
  "license": "MIT",
10
13
  "author": "",
11
14
  "directories": {
@@ -15,8 +18,7 @@
15
18
  "dependencies": {
16
19
  "@babel/core": "^7.29.7",
17
20
  "ember-cli-babel": "^8.3.1",
18
- "ember-cli-htmlbars": "^7.0.1",
19
- "ember-template-imports": "^4.4.0"
21
+ "ember-cli-version-checker": "^5.1.2"
20
22
  },
21
23
  "devDependencies": {
22
24
  "@babel/eslint-parser": "^7.29.7",
@@ -35,6 +37,7 @@
35
37
  "ember-cli-clean-css": "^3.0.0",
36
38
  "ember-cli-dependency-checker": "^3.4.0",
37
39
  "ember-cli-deprecation-workflow": "^4.0.1",
40
+ "ember-cli-htmlbars": "^7.0.1",
38
41
  "ember-cli-inject-live-reload": "^2.1.0",
39
42
  "ember-cli-sri": "^2.1.1",
40
43
  "ember-cli-terser": "^4.0.2",
@@ -57,8 +60,10 @@
57
60
  "prettier-plugin-ember-template-tag": "^2.1.6",
58
61
  "qunit": "^2.26.0",
59
62
  "qunit-dom": "^3.5.1",
63
+ "release-plan": "^0.18.0",
60
64
  "stylelint": "^16.26.1",
61
65
  "stylelint-config-standard": "^36.0.1",
66
+ "vitest": "^4.1.10",
62
67
  "webpack": "^5.107.2"
63
68
  },
64
69
  "peerDependencies": {
@@ -86,8 +91,8 @@
86
91
  "lint:js": "eslint . --cache",
87
92
  "lint:js:fix": "eslint . --fix",
88
93
  "start": "ember serve",
89
- "test": "concurrently \"pnpm:lint\" \"pnpm:test:*\" --names \"lint,test:\" --prefixColors auto",
94
+ "test": "concurrently \"pnpm:test:*(!fix)\" --names \"test:\" --prefixColors auto",
90
95
  "test:ember": "ember test",
91
- "test:ember-compatibility": "ember try:each"
96
+ "test:node": "vitest"
92
97
  }
93
98
  }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ include: 'node-tests/**/*.js',
6
+ },
7
+ });