@embroider/compat 4.0.0-alpha.6 → 4.0.0-alpha.7
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/compat",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Backward compatibility layer for the Embroider build system.",
|
|
6
6
|
"repository": {
|
|
@@ -91,8 +91,8 @@
|
|
|
91
91
|
"ember-engines": "^0.8.19",
|
|
92
92
|
"scenario-tester": "^4.0.0",
|
|
93
93
|
"typescript": "^5.4.5",
|
|
94
|
-
"@embroider/sample-transforms": "0.0.0",
|
|
95
94
|
"@embroider/core": "^4.0.0-alpha.6",
|
|
95
|
+
"@embroider/sample-transforms": "0.0.0",
|
|
96
96
|
"@embroider/test-support": "0.36.0"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
@@ -103,6 +103,9 @@ class default_1 extends v1_addon_1.default {
|
|
|
103
103
|
// error.
|
|
104
104
|
trees.push(new FixStringLoc([packages]));
|
|
105
105
|
}
|
|
106
|
+
if ((0, semver_1.satisfies)(this.packageJSON.version, '<5.12.0')) {
|
|
107
|
+
trees.push(new FixDeprecateFunction([packages]));
|
|
108
|
+
}
|
|
106
109
|
return (0, broccoli_merge_trees_1.default)(trees, { overwrite: true });
|
|
107
110
|
}
|
|
108
111
|
// We're zeroing out these files in vendor rather than deleting them, because
|
|
@@ -153,6 +156,61 @@ class FixStringLoc extends broccoli_plugin_1.default {
|
|
|
153
156
|
(0, fs_extra_1.outputFileSync)((0, path_1.resolve)(this.outputPath, 'ember', 'index.js'), outSource, 'utf8');
|
|
154
157
|
}
|
|
155
158
|
}
|
|
159
|
+
class FixDeprecateFunction extends broccoli_plugin_1.default {
|
|
160
|
+
build() {
|
|
161
|
+
let inSource = (0, fs_extra_1.readFileSync)((0, path_1.resolve)(this.inputPaths[0], '@ember', 'debug', 'index.js'), 'utf8');
|
|
162
|
+
let outSource = (0, core_1.transform)(inSource, {
|
|
163
|
+
plugins: [fixDeprecate],
|
|
164
|
+
configFile: false,
|
|
165
|
+
}).code;
|
|
166
|
+
(0, fs_extra_1.outputFileSync)((0, path_1.resolve)(this.outputPath, '@ember', 'debug', 'index.js'), outSource, 'utf8');
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function fixDeprecate(babel) {
|
|
170
|
+
const { types: t } = babel;
|
|
171
|
+
return {
|
|
172
|
+
name: 'ast-transform', // not required
|
|
173
|
+
visitor: {
|
|
174
|
+
Program(path) {
|
|
175
|
+
path.node.body.unshift(t.functionDeclaration(t.identifier('newDeprecate'), [t.restElement(t.identifier('rest'))], t.blockStatement([
|
|
176
|
+
t.returnStatement(t.callExpression(t.logicalExpression('??', t.identifier('currentDeprecate'), t.identifier('_deprecate')), [t.spreadElement(t.identifier('rest'))])),
|
|
177
|
+
])));
|
|
178
|
+
},
|
|
179
|
+
AssignmentExpression(path) {
|
|
180
|
+
if (path.node.left.type === 'Identifier' && path.node.left.name === 'deprecate') {
|
|
181
|
+
path.node.left.name = 'currentDeprecate';
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
ReturnStatement(path) {
|
|
185
|
+
var _a;
|
|
186
|
+
if (((_a = path.node.argument) === null || _a === void 0 ? void 0 : _a.type) === 'Identifier' && path.node.argument.name === 'deprecate') {
|
|
187
|
+
path.node.argument.name = 'newDeprecate';
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
CallExpression(path) {
|
|
191
|
+
if (path.node.callee.type === 'Identifier' && path.node.callee.name === 'deprecate') {
|
|
192
|
+
path.node.callee.name = 'newDeprecate';
|
|
193
|
+
}
|
|
194
|
+
if (path.node.callee.type === 'Identifier' &&
|
|
195
|
+
path.node.callee.name === 'setDebugFunction' &&
|
|
196
|
+
path.node.arguments[0].type === 'StringLiteral' &&
|
|
197
|
+
path.node.arguments[0].value === 'deprecate') {
|
|
198
|
+
path.remove();
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
ExportSpecifier(path) {
|
|
202
|
+
if (path.node.local.name === 'deprecate') {
|
|
203
|
+
path.node.local = t.identifier('newDeprecate');
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
VariableDeclarator(path) {
|
|
207
|
+
if (path.node.id.type === 'Identifier' && path.node.id.name === 'deprecate') {
|
|
208
|
+
path.node.id.name = 'currentDeprecate';
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
}
|
|
156
214
|
function fixStringLoc(babel) {
|
|
157
215
|
let t = babel.types;
|
|
158
216
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ember-source.js","sourceRoot":"","sources":["ember-source.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,2DAAkC;AAClC,sEAA0C;AAC1C,gFAA8C;AAC9C,iEAAuC;AACvC,uCAAiF;AACjF,+BAAqC;AACrC,2DAA6C;AAC7C,mCAAmC;AACnC,sCAAwC;AAGxC,sEAAqC;AAErC,2BAAgC;AAEhC,eAAqB,SAAQ,kBAAO;IAClC,IAAI,MAAM;QACR,OAAO,IAAA,8BAAU,EAAC,CAAC,KAAK,CAAC,MAAM,EAAE,IAAA,yBAAW,EAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,iCAAiC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClH,CAAC;IAED,oCAAoC;IACpC,wEAAwE;IACxE,6EAA6E;IAC7E,qEAAqE;IACrE,2EAA2E;IAC3E,yEAAyE;IACzE,6BAA6B;IAC7B,EAAE;IACF,2EAA2E;IAC3E,oEAAoE;IACpE,uEAAuE;IACvE,4EAA4E;IAC5E,2CAA2C;IAE3C,IAAY,oBAAoB;QAC9B,IAAI,MAAM,GAAa,EAAE,CAAC;QA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C5F,IAAI,IAAI,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAC9F,IAAI,KAAK,CAAC,aAAa,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;oBAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import V1Addon from '../v1-addon';\nimport buildFunnel from 'broccoli-funnel';\nimport mergeTrees from 'broccoli-merge-trees';\nimport AddToTree from '../add-to-tree';\nimport { outputFileSync, readFileSync, readdirSync, unlinkSync } from 'fs-extra';\nimport { join, resolve } from 'path';\nimport { Memoize } from 'typescript-memoize';\nimport { satisfies } from 'semver';\nimport { transform } from '@babel/core';\nimport type * as Babel from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\nimport Plugin from 'broccoli-plugin';\nimport type { Node } from 'broccoli-node-api';\nimport { existsSync } from 'fs';\n\nexport default class extends V1Addon {\n get v2Tree() {\n return mergeTrees([super.v2Tree, buildFunnel(this.rootTree, { include: ['dist/ember-template-compiler.js'] })]);\n }\n\n // versions of ember-source prior to\n // https://github.com/emberjs/ember.js/pull/20675 ship dist/packages and\n // dist/dependencies separately and the imports between them are package-name\n // imports. Since many of the dependencies are also true package.json\n // dependencies (in order to get typescript types), and our module-resolver\n // prioritizes true dependencies, it's necessary to detect and remove the\n // package.json dependencies.\n //\n // After the above linked change, ember-source ships only dist/packages and\n // the inter-package imports are all relative. Some of the things in\n // dist/packages are still the rolled-in dependencies, but now that the\n // imports are all relative we need no special handling for them (beyond the\n // normal v2 addon renamed-modules support.\n @Memoize()\n private get includedDependencies() {\n let result: string[] = [];\n let depsDir = resolve(this.root, 'dist', 'dependencies');\n if (!existsSync(depsDir)) {\n return result;\n }\n for (let name of readdirSync(depsDir)) {\n if (name[0] === '@') {\n for (let innerName of readdirSync(resolve(this.root, 'dist', 'dependencies', name))) {\n if (innerName.endsWith('.js')) {\n result.push(name + '/' + innerName.slice(0, -3));\n }\n }\n } else {\n if (name.endsWith('.js')) {\n result.push(name.slice(0, -3));\n }\n }\n }\n return result;\n }\n\n get newPackageJSON() {\n let json = super.newPackageJSON;\n\n for (let name of this.includedDependencies) {\n // weirdly, many of the inlined dependency are still listed as real\n // dependencies too. If we don't delete them here, they will take\n // precedence over the inlined ones, because the embroider module-resolver\n // tries to prioritize real deps.\n delete json.dependencies?.[name];\n }\n\n return json;\n }\n\n customizes(treeName: string) {\n // we are adding custom implementations of these\n return treeName === 'treeForAddon' || treeName === 'treeForVendor' || super.customizes(treeName);\n }\n\n invokeOriginalTreeFor(name: string) {\n if (name === 'addon') {\n return this.customAddonTree();\n }\n if (name === 'vendor') {\n return this.customVendorTree();\n }\n }\n\n // Our addon tree is all of the \"packages\" we share. @embroider/compat already\n // supports that pattern of emitting modules into other package's namespaces.\n private customAddonTree() {\n let packages = buildFunnel(this.rootTree, {\n srcDir: 'dist/packages',\n });\n\n let trees: Node[] = [\n packages,\n buildFunnel(this.rootTree, {\n srcDir: 'dist/dependencies',\n allowEmpty: true,\n }),\n ];\n\n if (satisfies(this.packageJSON.version, '>= 4.0.0-alpha.0 <4.10.0-alpha.0', { includePrerelease: true })) {\n // import { loc } from '@ember/string' was removed in 4.0. but the\n // top-level `ember` package tries to import it until 4.10. A\n // spec-compliant ES modules implementation will treat this as a parse\n // error.\n trees.push(new FixStringLoc([packages]));\n }\n\n return mergeTrees(trees, { overwrite: true });\n }\n\n // We're zeroing out these files in vendor rather than deleting them, because\n // we can't easily intercept the `app.import` that presumably exists for them,\n // so rather than error they will just be empty.\n //\n // The reason we're zeroing these out is that we're going to consume all our\n // modules directly out of treeForAddon instead, as real modules that webpack\n // can see.\n private customVendorTree() {\n return new AddToTree(this.addonInstance._treeFor('vendor'), outputPath => {\n unlinkSync(join(outputPath, 'ember', 'ember.js'));\n outputFileSync(join(outputPath, 'ember', 'ember.js'), '');\n unlinkSync(join(outputPath, 'ember', 'ember-testing.js'));\n outputFileSync(join(outputPath, 'ember', 'ember-testing.js'), '');\n });\n }\n\n get packageMeta() {\n let meta = super.packageMeta;\n\n if (!meta['implicit-modules']) {\n meta['implicit-modules'] = [];\n }\n meta['implicit-modules'].push('./ember/index.js');\n // before 5.6, Ember uses the AMD loader to decide if it's test-only parts\n // are present, so we must ensure they're registered. After that it's\n // enough to evaluate ember-testing, which @embroider/core is hard-coded\n // to do in the backward-compatible tests bundle.\n if (!satisfies(this.packageJSON.version, '>= 5.6.0-alpha.0', { includePrerelease: true })) {\n if (!meta['implicit-test-modules']) {\n meta['implicit-test-modules'] = [];\n }\n meta['implicit-test-modules'].push('./ember-testing/index.js');\n }\n\n return meta;\n }\n}\n\nclass FixStringLoc extends Plugin {\n build() {\n let inSource = readFileSync(resolve(this.inputPaths[0], 'ember', 'index.js'), 'utf8');\n let outSource = transform(inSource, {\n plugins: [fixStringLoc],\n configFile: false,\n })!.code!;\n outputFileSync(resolve(this.outputPath, 'ember', 'index.js'), outSource, 'utf8');\n }\n}\n\nfunction fixStringLoc(babel: typeof Babel) {\n let t = babel.types;\n return {\n visitor: {\n Program(path: NodePath<Babel.types.Program>) {\n path.node.body.unshift(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier('loc'), t.identifier('undefined'))])\n );\n },\n ImportDeclaration: {\n enter(path: NodePath<Babel.types.ImportDeclaration>, state: { inEmberString: boolean }) {\n if (path.node.source.value === '@ember/string') {\n state.inEmberString = true;\n }\n },\n exit(_path: NodePath<Babel.types.ImportDeclaration>, state: { inEmberString: boolean }) {\n state.inEmberString = false;\n },\n },\n ImportSpecifier(path: NodePath<Babel.types.ImportSpecifier>, state: { inEmberString: boolean }) {\n let name = 'value' in path.node.imported ? path.node.imported.value : path.node.imported.name;\n if (state.inEmberString && name === 'loc') {\n path.remove();\n }\n },\n },\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AA8C,EAAE,KAAiC;oBACpF,KAAK,CAAC,aAAa,GAAG,KAAK,CAAC;gBAC9B,CAAC;aACF;YACD,eAAe,CAAC,IAA2C,EAAE,KAAiC;gBAC5F,IAAI,IAAI,GAAG,OAAO,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAC9F,IAAI,KAAK,CAAC,aAAa,IAAI,IAAI,KAAK,KAAK,EAAE,CAAC;oBAC1C,IAAI,CAAC,MAAM,EAAE,CAAC;gBAChB,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC","sourcesContent":["import V1Addon from '../v1-addon';\nimport buildFunnel from 'broccoli-funnel';\nimport mergeTrees from 'broccoli-merge-trees';\nimport AddToTree from '../add-to-tree';\nimport { outputFileSync, readFileSync, readdirSync, unlinkSync } from 'fs-extra';\nimport { join, resolve } from 'path';\nimport { Memoize } from 'typescript-memoize';\nimport { satisfies } from 'semver';\nimport { transform } from '@babel/core';\nimport type * as Babel from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\nimport Plugin from 'broccoli-plugin';\nimport type { Node } from 'broccoli-node-api';\nimport { existsSync } from 'fs';\n\nexport default class extends V1Addon {\n get v2Tree() {\n return mergeTrees([super.v2Tree, buildFunnel(this.rootTree, { include: ['dist/ember-template-compiler.js'] })]);\n }\n\n // versions of ember-source prior to\n // https://github.com/emberjs/ember.js/pull/20675 ship dist/packages and\n // dist/dependencies separately and the imports between them are package-name\n // imports. Since many of the dependencies are also true package.json\n // dependencies (in order to get typescript types), and our module-resolver\n // prioritizes true dependencies, it's necessary to detect and remove the\n // package.json dependencies.\n //\n // After the above linked change, ember-source ships only dist/packages and\n // the inter-package imports are all relative. Some of the things in\n // dist/packages are still the rolled-in dependencies, but now that the\n // imports are all relative we need no special handling for them (beyond the\n // normal v2 addon renamed-modules support.\n @Memoize()\n private get includedDependencies() {\n let result: string[] = [];\n let depsDir = resolve(this.root, 'dist', 'dependencies');\n if (!existsSync(depsDir)) {\n return result;\n }\n for (let name of readdirSync(depsDir)) {\n if (name[0] === '@') {\n for (let innerName of readdirSync(resolve(this.root, 'dist', 'dependencies', name))) {\n if (innerName.endsWith('.js')) {\n result.push(name + '/' + innerName.slice(0, -3));\n }\n }\n } else {\n if (name.endsWith('.js')) {\n result.push(name.slice(0, -3));\n }\n }\n }\n return result;\n }\n\n get newPackageJSON() {\n let json = super.newPackageJSON;\n\n for (let name of this.includedDependencies) {\n // weirdly, many of the inlined dependency are still listed as real\n // dependencies too. If we don't delete them here, they will take\n // precedence over the inlined ones, because the embroider module-resolver\n // tries to prioritize real deps.\n delete json.dependencies?.[name];\n }\n\n return json;\n }\n\n customizes(treeName: string) {\n // we are adding custom implementations of these\n return treeName === 'treeForAddon' || treeName === 'treeForVendor' || super.customizes(treeName);\n }\n\n invokeOriginalTreeFor(name: string) {\n if (name === 'addon') {\n return this.customAddonTree();\n }\n if (name === 'vendor') {\n return this.customVendorTree();\n }\n }\n\n // Our addon tree is all of the \"packages\" we share. @embroider/compat already\n // supports that pattern of emitting modules into other package's namespaces.\n private customAddonTree() {\n let packages = buildFunnel(this.rootTree, {\n srcDir: 'dist/packages',\n });\n\n let trees: Node[] = [\n packages,\n buildFunnel(this.rootTree, {\n srcDir: 'dist/dependencies',\n allowEmpty: true,\n }),\n ];\n\n if (satisfies(this.packageJSON.version, '>= 4.0.0-alpha.0 <4.10.0-alpha.0', { includePrerelease: true })) {\n // import { loc } from '@ember/string' was removed in 4.0. but the\n // top-level `ember` package tries to import it until 4.10. A\n // spec-compliant ES modules implementation will treat this as a parse\n // error.\n trees.push(new FixStringLoc([packages]));\n }\n\n if (satisfies(this.packageJSON.version, '<5.12.0')) {\n trees.push(new FixDeprecateFunction([packages]));\n }\n\n return mergeTrees(trees, { overwrite: true });\n }\n\n // We're zeroing out these files in vendor rather than deleting them, because\n // we can't easily intercept the `app.import` that presumably exists for them,\n // so rather than error they will just be empty.\n //\n // The reason we're zeroing these out is that we're going to consume all our\n // modules directly out of treeForAddon instead, as real modules that webpack\n // can see.\n private customVendorTree() {\n return new AddToTree(this.addonInstance._treeFor('vendor'), outputPath => {\n unlinkSync(join(outputPath, 'ember', 'ember.js'));\n outputFileSync(join(outputPath, 'ember', 'ember.js'), '');\n unlinkSync(join(outputPath, 'ember', 'ember-testing.js'));\n outputFileSync(join(outputPath, 'ember', 'ember-testing.js'), '');\n });\n }\n\n get packageMeta() {\n let meta = super.packageMeta;\n\n if (!meta['implicit-modules']) {\n meta['implicit-modules'] = [];\n }\n meta['implicit-modules'].push('./ember/index.js');\n // before 5.6, Ember uses the AMD loader to decide if it's test-only parts\n // are present, so we must ensure they're registered. After that it's\n // enough to evaluate ember-testing, which @embroider/core is hard-coded\n // to do in the backward-compatible tests bundle.\n if (!satisfies(this.packageJSON.version, '>= 5.6.0-alpha.0', { includePrerelease: true })) {\n if (!meta['implicit-test-modules']) {\n meta['implicit-test-modules'] = [];\n }\n meta['implicit-test-modules'].push('./ember-testing/index.js');\n }\n\n return meta;\n }\n}\n\nclass FixStringLoc extends Plugin {\n build() {\n let inSource = readFileSync(resolve(this.inputPaths[0], 'ember', 'index.js'), 'utf8');\n let outSource = transform(inSource, {\n plugins: [fixStringLoc],\n configFile: false,\n })!.code!;\n outputFileSync(resolve(this.outputPath, 'ember', 'index.js'), outSource, 'utf8');\n }\n}\n\nclass FixDeprecateFunction extends Plugin {\n build() {\n let inSource = readFileSync(resolve(this.inputPaths[0], '@ember', 'debug', 'index.js'), 'utf8');\n let outSource = transform(inSource, {\n plugins: [fixDeprecate],\n configFile: false,\n })!.code!;\n outputFileSync(resolve(this.outputPath, '@ember', 'debug', 'index.js'), outSource, 'utf8');\n }\n}\n\nfunction fixDeprecate(babel: typeof Babel) {\n const { types: t } = babel;\n\n return {\n name: 'ast-transform', // not required\n visitor: {\n Program(path: NodePath<Babel.types.Program>) {\n path.node.body.unshift(\n t.functionDeclaration(\n t.identifier('newDeprecate'),\n [t.restElement(t.identifier('rest'))],\n t.blockStatement([\n t.returnStatement(\n t.callExpression(\n t.logicalExpression('??', t.identifier('currentDeprecate'), t.identifier('_deprecate')),\n [t.spreadElement(t.identifier('rest'))]\n )\n ),\n ])\n )\n );\n },\n AssignmentExpression(path: NodePath<Babel.types.AssignmentExpression>) {\n if (path.node.left.type === 'Identifier' && path.node.left.name === 'deprecate') {\n path.node.left.name = 'currentDeprecate';\n }\n },\n\n ReturnStatement(path: NodePath<Babel.types.ReturnStatement>) {\n if (path.node.argument?.type === 'Identifier' && path.node.argument.name === 'deprecate') {\n path.node.argument.name = 'newDeprecate';\n }\n },\n\n CallExpression(path: NodePath<Babel.types.CallExpression>) {\n if (path.node.callee.type === 'Identifier' && path.node.callee.name === 'deprecate') {\n path.node.callee.name = 'newDeprecate';\n }\n if (\n path.node.callee.type === 'Identifier' &&\n path.node.callee.name === 'setDebugFunction' &&\n path.node.arguments[0].type === 'StringLiteral' &&\n path.node.arguments[0].value === 'deprecate'\n ) {\n path.remove();\n }\n },\n ExportSpecifier(path: NodePath<Babel.types.ExportSpecifier>) {\n if (path.node.local.name === 'deprecate') {\n path.node.local = t.identifier('newDeprecate');\n }\n },\n VariableDeclarator(path: NodePath<Babel.types.VariableDeclarator>) {\n if (path.node.id.type === 'Identifier' && path.node.id.name === 'deprecate') {\n path.node.id.name = 'currentDeprecate';\n }\n },\n },\n };\n}\n\nfunction fixStringLoc(babel: typeof Babel) {\n let t = babel.types;\n return {\n visitor: {\n Program(path: NodePath<Babel.types.Program>) {\n path.node.body.unshift(\n t.variableDeclaration('const', [t.variableDeclarator(t.identifier('loc'), t.identifier('undefined'))])\n );\n },\n ImportDeclaration: {\n enter(path: NodePath<Babel.types.ImportDeclaration>, state: { inEmberString: boolean }) {\n if (path.node.source.value === '@ember/string') {\n state.inEmberString = true;\n }\n },\n exit(_path: NodePath<Babel.types.ImportDeclaration>, state: { inEmberString: boolean }) {\n state.inEmberString = false;\n },\n },\n ImportSpecifier(path: NodePath<Babel.types.ImportSpecifier>, state: { inEmberString: boolean }) {\n let name = 'value' in path.node.imported ? path.node.imported.value : path.node.imported.name;\n if (state.inEmberString && name === 'loc') {\n path.remove();\n }\n },\n },\n };\n}\n"]}
|