@embroider/compat 3.5.1-unstable.e01da0a → 3.5.1

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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +13 -13
  3. package/src/audit/babel-visitor.js +3 -5
  4. package/src/audit/babel-visitor.js.map +1 -1
  5. package/src/audit/build.js.map +1 -1
  6. package/src/audit-cli.js.map +1 -1
  7. package/src/audit.d.ts +54 -6
  8. package/src/audit.js +275 -86
  9. package/src/audit.js.map +1 -1
  10. package/src/babel-plugin-adjust-imports.d.ts +1 -2
  11. package/src/babel-plugin-adjust-imports.js +1 -1
  12. package/src/babel-plugin-adjust-imports.js.map +1 -1
  13. package/src/build-compat-addon.js.map +1 -1
  14. package/src/compat-adapters/@ember/test-waiters.js.map +1 -1
  15. package/src/compat-adapters/@ember-data/debug.d.ts +6 -0
  16. package/src/compat-adapters/@ember-data/debug.js +22 -0
  17. package/src/compat-adapters/@ember-data/debug.js.map +1 -0
  18. package/src/compat-adapters/@ember-data/store.d.ts +5 -1
  19. package/src/compat-adapters/@ember-data/store.js +15 -3
  20. package/src/compat-adapters/@ember-data/store.js.map +1 -1
  21. package/src/compat-adapters/ember-asset-loader.js.map +1 -1
  22. package/src/compat-adapters/ember-cli-babel.js.map +1 -1
  23. package/src/compat-adapters/ember-cli-fastboot.js.map +1 -1
  24. package/src/compat-adapters/ember-cli-mirage.js.map +1 -1
  25. package/src/compat-adapters/ember-composable-helpers.js.map +1 -1
  26. package/src/compat-adapters/ember-data.js.map +1 -1
  27. package/src/compat-adapters/ember-engines.js.map +1 -1
  28. package/src/compat-adapters/ember-macro-helpers.js.map +1 -1
  29. package/src/compat-adapters/ember-scroll-modifiers.js.map +1 -1
  30. package/src/compat-adapters/ember-source.js.map +1 -1
  31. package/src/compat-adapters/ember-svg-jar.js.map +1 -1
  32. package/src/compat-addons.js.map +1 -1
  33. package/src/compat-app-builder.d.ts +19 -7
  34. package/src/compat-app-builder.js +667 -73
  35. package/src/compat-app-builder.js.map +1 -1
  36. package/src/compat-app.d.ts +4 -2
  37. package/src/compat-app.js +24 -60
  38. package/src/compat-app.js.map +1 -1
  39. package/src/compat-utils.js.map +1 -1
  40. package/src/dasherize-component-name.js.map +1 -1
  41. package/src/default-pipeline.d.ts +2 -2
  42. package/src/default-pipeline.js +1 -22
  43. package/src/default-pipeline.js.map +1 -1
  44. package/src/dependency-rules.js.map +1 -1
  45. package/src/detect-babel-plugins.js.map +1 -1
  46. package/src/detect-compact-reexports.js.map +1 -1
  47. package/src/dummy-package.js.map +1 -1
  48. package/src/empty-package-tree.js.map +1 -1
  49. package/src/get-real-addon.js.map +1 -1
  50. package/src/hbs-to-js-broccoli-plugin.js.map +1 -1
  51. package/src/index.d.ts +1 -1
  52. package/src/index.js +1 -2
  53. package/src/index.js.map +1 -1
  54. package/src/merges.js.map +1 -1
  55. package/src/options.d.ts +0 -1
  56. package/src/options.js +0 -1
  57. package/src/options.js.map +1 -1
  58. package/src/prepare-htmlbars-ast-plugins.js.map +1 -1
  59. package/src/rename-require-plugin.js.map +1 -1
  60. package/src/resolver-transform.js +0 -3
  61. package/src/resolver-transform.js.map +1 -1
  62. package/src/rewrite-addon-tree.js.map +1 -1
  63. package/src/smoosh-package-json.js.map +1 -1
  64. package/src/snitch.js.map +1 -1
  65. package/src/standalone-addon-build.js.map +1 -1
  66. package/src/sync-dir.js.map +1 -1
  67. package/src/synthesize-template-only-components.js.map +1 -1
  68. package/src/v1-addon.js.map +1 -1
  69. package/src/v1-appboot.js.map +1 -1
  70. package/src/v1-config.js.map +1 -1
  71. package/src/v1-instance-cache.js.map +1 -1
  72. package/src/compat-adapters/ember-fetch.d.ts +0 -5
  73. package/src/compat-adapters/ember-fetch.js +0 -19
  74. package/src/compat-adapters/ember-fetch.js.map +0 -1
  75. package/src/content-for-config.d.ts +0 -11
  76. package/src/content-for-config.js +0 -66
  77. package/src/content-for-config.js.map +0 -1
  78. package/src/http-audit.d.ts +0 -13
  79. package/src/http-audit.js +0 -46
  80. package/src/http-audit.js.map +0 -1
  81. package/src/module-visitor.d.ts +0 -53
  82. package/src/module-visitor.js +0 -286
  83. package/src/module-visitor.js.map +0 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2018 Edward Faulkner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/compat",
3
- "version": "3.5.1-unstable.e01da0a",
3
+ "version": "3.5.1",
4
4
  "private": false,
5
5
  "description": "Backward compatibility layer for the Embroider build system.",
6
6
  "repository": {
@@ -19,9 +19,6 @@
19
19
  "bin": {
20
20
  "embroider-compat-audit": "./src/audit-cli.js"
21
21
  },
22
- "scripts": {
23
- "test": "jest"
24
- },
25
22
  "dependencies": {
26
23
  "@babel/code-frame": "^7.14.5",
27
24
  "@babel/core": "^7.14.5",
@@ -30,7 +27,6 @@
30
27
  "@babel/preset-env": "^7.14.5",
31
28
  "@babel/runtime": "^7.18.6",
32
29
  "@babel/traverse": "^7.14.5",
33
- "@embroider/macros": "1.16.2-unstable.e01da0a",
34
30
  "@types/babel__code-frame": "^7.0.2",
35
31
  "@types/yargs": "^17.0.3",
36
32
  "assert-never": "^1.1.0",
@@ -63,12 +59,10 @@
63
59
  "tree-sync": "^2.1.0",
64
60
  "typescript-memoize": "^1.0.1",
65
61
  "walk-sync": "^3.0.0",
66
- "yargs": "^17.0.1"
62
+ "yargs": "^17.0.1",
63
+ "@embroider/macros": "1.16.2"
67
64
  },
68
65
  "devDependencies": {
69
- "@embroider/core": "3.4.10-unstable.e01da0a",
70
- "@embroider/sample-transforms": "workspace:*",
71
- "@embroider/test-support": "workspace:*",
72
66
  "@glimmer/syntax": "^0.84.3",
73
67
  "@glint/template": "^1.0.0",
74
68
  "@types/babel__core": "^7.1.14",
@@ -87,13 +81,19 @@
87
81
  "broccoli-node-api": "^1.7.0",
88
82
  "code-equality-assertions": "^0.9.0",
89
83
  "ember-engines": "^0.8.19",
90
- "scenario-tester": "^3.0.1",
91
- "typescript": "^5.4.5"
84
+ "scenario-tester": "^2.1.2",
85
+ "typescript": "^5.1.6",
86
+ "@embroider/core": "^3.4.10",
87
+ "@embroider/sample-transforms": "0.0.0",
88
+ "@embroider/test-support": "0.36.0"
92
89
  },
93
90
  "peerDependencies": {
94
- "@embroider/core": "3.4.10-unstable.e01da0a"
91
+ "@embroider/core": "^3.4.10"
95
92
  },
96
93
  "engines": {
97
94
  "node": "12.* || 14.* || >= 16"
95
+ },
96
+ "scripts": {
97
+ "test": "jest"
98
98
  }
99
- }
99
+ }
@@ -14,10 +14,8 @@ function isNamespaceMarker(value) {
14
14
  return typeof value !== 'string';
15
15
  }
16
16
  exports.isNamespaceMarker = isNamespaceMarker;
17
+ // babelConfig must include { ast: true }
17
18
  function auditJS(rawSource, filename, babelConfig, frames) {
18
- if (!babelConfig.ast) {
19
- throw new Error(`module auditing requires a babel config with ast: true`);
20
- }
21
19
  let imports = [];
22
20
  let exports = new Set();
23
21
  let problems = [];
@@ -102,7 +100,7 @@ function auditJS(rawSource, filename, babelConfig, frames) {
102
100
  if (path.parent.type === 'ExportNamedDeclaration' && path.parent.source) {
103
101
  imports[imports.length - 1].specifiers.push({
104
102
  name: name(path.node.local),
105
- local: null, // re-exports don't create local bindings
103
+ local: null,
106
104
  codeFrameIndex: saveCodeFrame(path.node),
107
105
  });
108
106
  }
@@ -112,7 +110,7 @@ function auditJS(rawSource, filename, babelConfig, frames) {
112
110
  if (path.parent.type === 'ExportNamedDeclaration' && path.parent.source) {
113
111
  imports[imports.length - 1].specifiers.push({
114
112
  name: { isNamespace: true },
115
- local: null, // re-exports don't create local bindings
113
+ local: null,
116
114
  codeFrameIndex: saveCodeFrame(path.node),
117
115
  });
118
116
  }
@@ -1 +1 @@
1
- {"version":3,"file":"babel-visitor.js","sourceRoot":"","sources":["babel-visitor.ts"],"names":[],"mappings":";;;;;;AACA,+DAAuC;AAEvC,sCAAwD;AAExD,kDAAqD;AAErD,MAAa,YAAY;CAAG;AAA5B,oCAA4B;AAgB5B,SAAgB,iBAAiB,CAAC,KAA+B;IAC/D,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAFD,8CAEC;AAMD,SAAgB,OAAO,CAAC,SAAiB,EAAE,QAAgB,EAAE,WAA6B,EAAE,MAAwB;IAClH,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAC;IAC5E,CAAC;IAED,IAAI,OAAO,GAAG,EAAsB,CAAC;IACrC,IAAI,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;IAC5C,IAAI,QAAQ,GAAG,EAA+E,CAAC;IAE/F,2DAA2D;IAC3D,4EAA4E;IAC5E,uEAAuE;IACvE,gBAAgB;IAChB,IAAI,SAAS,GAAY,KAAK,CAAC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AAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACjF,KAAK,gBAAgB;YACnB,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACpF,KAAK,mBAAmB;YACtB,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACnF,KAAK,qBAAqB,CAAC;QAC3B,KAAK,kBAAkB;YACrB,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACjF;YACE,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC","sourcesContent":["import type { NodePath, Node } from '@babel/traverse';\nimport traverse from '@babel/traverse';\nimport type { TransformOptions } from '@babel/core';\nimport { transformSync, types as t } from '@babel/core';\nimport type { SourceLocation } from '@babel/code-frame';\nimport { codeFrameColumns } from '@babel/code-frame';\n\nexport class VisitorState {}\n\nexport interface InternalImport {\n source: string;\n codeFrameIndex: number | undefined;\n specifiers: {\n name: string | NamespaceMarker;\n local: string | null; // can be null when re-exporting, because in that case we import `name` from `source` but don't create any local binding for it\n codeFrameIndex: number | undefined;\n }[];\n}\n\nexport interface NamespaceMarker {\n isNamespace: true;\n}\n\nexport function isNamespaceMarker(value: string | NamespaceMarker): value is NamespaceMarker {\n return typeof value !== 'string';\n}\n\nexport interface ExportAll {\n all: string;\n}\n\nexport function auditJS(rawSource: string, filename: string, babelConfig: TransformOptions, frames: CodeFrameStorage) {\n if (!babelConfig.ast) {\n throw new Error(`module auditing requires a babel config with ast: true`);\n }\n\n let imports = [] as InternalImport[];\n let exports = new Set<string | ExportAll>();\n let problems = [] as { message: string; detail: string; codeFrameIndex: number | undefined }[];\n\n /* eslint-disable @typescript-eslint/no-inferrable-types */\n // These are not really inferrable. Without explicit declarations, TS thinks\n // they're always false because it doesn't know the handler methods run\n // synchronously\n let sawModule: boolean = false;\n let sawExports: boolean = false;\n let sawDefine: boolean = false;\n /* eslint-enable @typescript-eslint/no-inferrable-types */\n\n let { ast, code } = transformSync(rawSource, Object.assign({ filename: filename }, babelConfig))!;\n let saveCodeFrame = frames.forSource(rawSource);\n\n traverse(ast!, {\n Identifier(path: NodePath<t.Identifier>) {\n if (path.node.name === 'module' && isFreeVariable(path)) {\n sawModule = true;\n } else if (path.node.name === 'exports' && isFreeVariable(path)) {\n sawExports = true;\n } else if (path.node.name === 'define' && isFreeVariable(path)) {\n sawDefine = true;\n }\n if (inExportDeclarationContext(path)) {\n exports.add(path.node.name);\n }\n },\n CallExpression(path: NodePath<t.CallExpression>) {\n let callee = path.get('callee');\n if (callee.referencesImport('@embroider/macros', 'importSync') || t.isImport(callee.node)) {\n let arg = path.node.arguments[0];\n if (arg.type === 'StringLiteral') {\n imports.push({\n source: arg.value,\n codeFrameIndex: saveCodeFrame(arg),\n specifiers: [],\n });\n } else {\n problems.push({\n message: `audit tool is unable to understand this usage of ${\n t.isImport(callee.node) ? 'import' : 'importSync'\n }`,\n detail: arg.type,\n codeFrameIndex: saveCodeFrame(arg),\n });\n }\n }\n },\n ImportDeclaration(path: NodePath<t.ImportDeclaration>) {\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [],\n });\n },\n ImportDefaultSpecifier(path: NodePath<t.ImportDefaultSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: 'default',\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ImportNamespaceSpecifier(path: NodePath<t.ImportNamespaceSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: { isNamespace: true },\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ImportSpecifier(path: NodePath<t.ImportSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: name(path.node.imported),\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ExportDefaultDeclaration(_path: NodePath<t.ExportDefaultDeclaration>) {\n exports.add('default');\n },\n ExportSpecifier(path: NodePath<t.ExportSpecifier>) {\n exports.add(name(path.node.exported));\n if (path.parent.type === 'ExportNamedDeclaration' && path.parent.source) {\n imports[imports.length - 1].specifiers.push({\n name: name(path.node.local),\n local: null, // re-exports don't create local bindings\n codeFrameIndex: saveCodeFrame(path.node),\n });\n }\n },\n ExportNamespaceSpecifier(path: NodePath<t.ExportNamespaceSpecifier>) {\n exports.add(name(path.node.exported));\n if (path.parent.type === 'ExportNamedDeclaration' && path.parent.source) {\n imports[imports.length - 1].specifiers.push({\n name: { isNamespace: true },\n local: null, // re-exports don't create local bindings\n codeFrameIndex: saveCodeFrame(path.node),\n });\n }\n },\n ExportAllDeclaration(path: NodePath<t.ExportAllDeclaration>) {\n exports.add({ all: path.node.source.value });\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [\n {\n name: { isNamespace: true },\n local: null,\n codeFrameIndex: saveCodeFrame(path.node),\n },\n ],\n });\n },\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\n if (path.node.source) {\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [],\n });\n }\n },\n });\n\n let isCJS = imports.length === 0 && exports.size === 0 && (sawModule || sawExports);\n let isAMD = imports.length === 0 && exports.size === 0 && sawDefine;\n return { imports, exports, isCJS, isAMD, problems, transpiledContent: code! };\n}\n\nexport class CodeFrameStorage {\n private codeFrames = [] as { rawSourceIndex: number; loc: SourceLocation }[];\n private rawSources = [] as string[];\n\n forSource(rawSource: string): (node: { loc?: SourceLocation | null }) => number | undefined {\n let rawSourceIndex: number | undefined;\n return (node: { loc?: SourceLocation | null | undefined }) => {\n let loc = node.loc;\n if (!loc) {\n return;\n }\n if (rawSourceIndex == null) {\n rawSourceIndex = this.rawSources.length;\n this.rawSources.push(rawSource);\n }\n let codeFrameIndex = this.codeFrames.length;\n this.codeFrames.push({\n rawSourceIndex,\n loc,\n });\n return codeFrameIndex;\n };\n }\n\n render(codeFrameIndex: number | undefined): string | undefined {\n if (codeFrameIndex != null) {\n let { loc, rawSourceIndex } = this.codeFrames[codeFrameIndex];\n return codeFrameColumns(this.rawSources[rawSourceIndex], loc, { highlightCode: true });\n }\n }\n}\n\nfunction name(node: t.StringLiteral | t.Identifier): string {\n if (t.isStringLiteral(node)) {\n return node.value;\n } else {\n return node.name;\n }\n}\n\nfunction isFreeVariable(path: NodePath<t.Identifier>) {\n return !path.scope.hasBinding(path.node.name);\n}\n\nconst contextCache: WeakMap<Node, boolean> = new WeakMap();\n\nfunction inExportDeclarationContext(path: NodePath): boolean {\n if (contextCache.has(path.node)) {\n return contextCache.get(path.node)!;\n } else {\n let answer = _inExportDeclarationContext(path);\n contextCache.set(path.node, answer);\n return answer;\n }\n}\n\nfunction _inExportDeclarationContext(path: NodePath): boolean {\n let parent = path.parent;\n switch (parent.type) {\n case 'ExportNamedDeclaration':\n return parent.declaration === path.node;\n case 'VariableDeclaration':\n case 'ObjectPattern':\n case 'ArrayPattern':\n case 'RestElement':\n return inExportDeclarationContext(path.parentPath!);\n case 'VariableDeclarator':\n return parent.id === path.node && inExportDeclarationContext(path.parentPath!);\n case 'ObjectProperty':\n return parent.value === path.node && inExportDeclarationContext(path.parentPath!);\n case 'AssignmentPattern':\n return parent.left === path.node && inExportDeclarationContext(path.parentPath!);\n case 'FunctionDeclaration':\n case 'ClassDeclaration':\n return parent.id === path.node && inExportDeclarationContext(path.parentPath!);\n default:\n return false;\n }\n}\n"]}
1
+ {"version":3,"file":"babel-visitor.js","sourceRoot":"","sources":["babel-visitor.ts"],"names":[],"mappings":";;;;;;AACA,+DAAuC;AAEvC,sCAAwD;AAExD,kDAAqD;AAErD,MAAa,YAAY;CAAG;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AAC,IAAI,CAAC;QAC1C,KAAK,qBAAqB,CAAC;QAC3B,KAAK,eAAe,CAAC;QACrB,KAAK,cAAc,CAAC;QACpB,KAAK,aAAa;YAChB,OAAO,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACtD,KAAK,oBAAoB;YACvB,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACjF,KAAK,gBAAgB;YACnB,OAAO,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACpF,KAAK,mBAAmB;YACtB,OAAO,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACnF,KAAK,qBAAqB,CAAC;QAC3B,KAAK,kBAAkB;YACrB,OAAO,MAAM,CAAC,EAAE,KAAK,IAAI,CAAC,IAAI,IAAI,0BAA0B,CAAC,IAAI,CAAC,UAAW,CAAC,CAAC;QACjF;YACE,OAAO,KAAK,CAAC;KAChB;AACH,CAAC","sourcesContent":["import type { NodePath, Node } from '@babel/traverse';\nimport traverse from '@babel/traverse';\nimport type { TransformOptions } from '@babel/core';\nimport { transformSync, types as t } from '@babel/core';\nimport type { SourceLocation } from '@babel/code-frame';\nimport { codeFrameColumns } from '@babel/code-frame';\n\nexport class VisitorState {}\n\nexport interface InternalImport {\n source: string;\n codeFrameIndex: number | undefined;\n specifiers: {\n name: string | NamespaceMarker;\n local: string | null; // can be null when re-exporting, because in that case we import `name` from `source` but don't create any local binding for it\n codeFrameIndex: number | undefined;\n }[];\n}\n\nexport interface NamespaceMarker {\n isNamespace: true;\n}\n\nexport function isNamespaceMarker(value: string | NamespaceMarker): value is NamespaceMarker {\n return typeof value !== 'string';\n}\n\nexport interface ExportAll {\n all: string;\n}\n\n// babelConfig must include { ast: true }\nexport function auditJS(rawSource: string, filename: string, babelConfig: TransformOptions, frames: CodeFrameStorage) {\n let imports = [] as InternalImport[];\n let exports = new Set<string | ExportAll>();\n let problems = [] as { message: string; detail: string; codeFrameIndex: number | undefined }[];\n\n /* eslint-disable @typescript-eslint/no-inferrable-types */\n // These are not really inferrable. Without explicit declarations, TS thinks\n // they're always false because it doesn't know the handler methods run\n // synchronously\n let sawModule: boolean = false;\n let sawExports: boolean = false;\n let sawDefine: boolean = false;\n /* eslint-enable @typescript-eslint/no-inferrable-types */\n\n let { ast, code } = transformSync(rawSource, Object.assign({ filename: filename }, babelConfig))!;\n let saveCodeFrame = frames.forSource(rawSource);\n\n traverse(ast!, {\n Identifier(path: NodePath<t.Identifier>) {\n if (path.node.name === 'module' && isFreeVariable(path)) {\n sawModule = true;\n } else if (path.node.name === 'exports' && isFreeVariable(path)) {\n sawExports = true;\n } else if (path.node.name === 'define' && isFreeVariable(path)) {\n sawDefine = true;\n }\n if (inExportDeclarationContext(path)) {\n exports.add(path.node.name);\n }\n },\n CallExpression(path: NodePath<t.CallExpression>) {\n let callee = path.get('callee');\n if (callee.referencesImport('@embroider/macros', 'importSync') || t.isImport(callee.node)) {\n let arg = path.node.arguments[0];\n if (arg.type === 'StringLiteral') {\n imports.push({\n source: arg.value,\n codeFrameIndex: saveCodeFrame(arg),\n specifiers: [],\n });\n } else {\n problems.push({\n message: `audit tool is unable to understand this usage of ${\n t.isImport(callee.node) ? 'import' : 'importSync'\n }`,\n detail: arg.type,\n codeFrameIndex: saveCodeFrame(arg),\n });\n }\n }\n },\n ImportDeclaration(path: NodePath<t.ImportDeclaration>) {\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [],\n });\n },\n ImportDefaultSpecifier(path: NodePath<t.ImportDefaultSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: 'default',\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ImportNamespaceSpecifier(path: NodePath<t.ImportNamespaceSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: { isNamespace: true },\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ImportSpecifier(path: NodePath<t.ImportSpecifier>) {\n imports[imports.length - 1].specifiers.push({\n name: name(path.node.imported),\n local: path.node.local.name,\n codeFrameIndex: saveCodeFrame(path.node),\n });\n },\n ExportDefaultDeclaration(_path: NodePath<t.ExportDefaultDeclaration>) {\n exports.add('default');\n },\n ExportSpecifier(path: NodePath<t.ExportSpecifier>) {\n exports.add(name(path.node.exported));\n if (path.parent.type === 'ExportNamedDeclaration' && path.parent.source) {\n imports[imports.length - 1].specifiers.push({\n name: name(path.node.local),\n local: null, // re-exports don't create local bindings\n codeFrameIndex: saveCodeFrame(path.node),\n });\n }\n },\n ExportNamespaceSpecifier(path: NodePath<t.ExportNamespaceSpecifier>) {\n exports.add(name(path.node.exported));\n if (path.parent.type === 'ExportNamedDeclaration' && path.parent.source) {\n imports[imports.length - 1].specifiers.push({\n name: { isNamespace: true },\n local: null, // re-exports don't create local bindings\n codeFrameIndex: saveCodeFrame(path.node),\n });\n }\n },\n ExportAllDeclaration(path: NodePath<t.ExportAllDeclaration>) {\n exports.add({ all: path.node.source.value });\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [\n {\n name: { isNamespace: true },\n local: null,\n codeFrameIndex: saveCodeFrame(path.node),\n },\n ],\n });\n },\n ExportNamedDeclaration(path: NodePath<t.ExportNamedDeclaration>) {\n if (path.node.source) {\n imports.push({\n source: path.node.source.value,\n codeFrameIndex: saveCodeFrame(path.node.source),\n specifiers: [],\n });\n }\n },\n });\n\n let isCJS = imports.length === 0 && exports.size === 0 && (sawModule || sawExports);\n let isAMD = imports.length === 0 && exports.size === 0 && sawDefine;\n return { imports, exports, isCJS, isAMD, problems, transpiledContent: code! };\n}\n\nexport class CodeFrameStorage {\n private codeFrames = [] as { rawSourceIndex: number; loc: SourceLocation }[];\n private rawSources = [] as string[];\n\n forSource(rawSource: string): (node: { loc?: SourceLocation | null }) => number | undefined {\n let rawSourceIndex: number | undefined;\n return (node: { loc?: SourceLocation | null | undefined }) => {\n let loc = node.loc;\n if (!loc) {\n return;\n }\n if (rawSourceIndex == null) {\n rawSourceIndex = this.rawSources.length;\n this.rawSources.push(rawSource);\n }\n let codeFrameIndex = this.codeFrames.length;\n this.codeFrames.push({\n rawSourceIndex,\n loc,\n });\n return codeFrameIndex;\n };\n }\n\n render(codeFrameIndex: number | undefined): string | undefined {\n if (codeFrameIndex != null) {\n let { loc, rawSourceIndex } = this.codeFrames[codeFrameIndex];\n return codeFrameColumns(this.rawSources[rawSourceIndex], loc, { highlightCode: true });\n }\n }\n}\n\nfunction name(node: t.StringLiteral | t.Identifier): string {\n if (t.isStringLiteral(node)) {\n return node.value;\n } else {\n return node.name;\n }\n}\n\nfunction isFreeVariable(path: NodePath<t.Identifier>) {\n return !path.scope.hasBinding(path.node.name);\n}\n\nconst contextCache: WeakMap<Node, boolean> = new WeakMap();\n\nfunction inExportDeclarationContext(path: NodePath): boolean {\n if (contextCache.has(path.node)) {\n return contextCache.get(path.node)!;\n } else {\n let answer = _inExportDeclarationContext(path);\n contextCache.set(path.node, answer);\n return answer;\n }\n}\n\nfunction _inExportDeclarationContext(path: NodePath): boolean {\n let parent = path.parent;\n switch (parent.type) {\n case 'ExportNamedDeclaration':\n return parent.declaration === path.node;\n case 'VariableDeclaration':\n case 'ObjectPattern':\n case 'ArrayPattern':\n case 'RestElement':\n return inExportDeclarationContext(path.parentPath!);\n case 'VariableDeclarator':\n return parent.id === path.node && inExportDeclarationContext(path.parentPath!);\n case 'ObjectProperty':\n return parent.value === path.node && inExportDeclarationContext(path.parentPath!);\n case 'AssignmentPattern':\n return parent.left === path.node && inExportDeclarationContext(path.parentPath!);\n case 'FunctionDeclaration':\n case 'ClassDeclaration':\n return parent.id === path.node && inExportDeclarationContext(path.parentPath!);\n default:\n return false;\n }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,EAAE,IAAI;QACX,GAAG;KACJ,CAAC,CAAC;IACH,IAAI,YAAY,GAAa,EAAE,CAAC;IAChC,IAAI,YAAY,GAAa,EAAE,CAAC;IAChC,IAAI,cAAc,GAAa,EAAE,CAAC;IAClC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;QAC7B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;QAC7B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxB,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,QAAgB,EAAE,EAAE;YACrC,OAAO,CAAC;gBACN,QAAQ;gBACR,IAAI,MAAM;oBACR,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/B,CAAC;gBACD,IAAI,MAAM;oBACR,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/B,CAAC;gBACD,IAAI,MAAM;oBACR,OAAO,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACjC,CAAC;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import chalk from 'chalk';\nimport type { AuditBuildOptions } from '../audit';\nimport { spawn } from 'child_process';\n\nexport async function buildApp(options: AuditBuildOptions): Promise<void> {\n let result = await execute(`node node_modules/ember-cli/bin/ember build`, {\n pwd: options.app,\n env: {\n STAGE2_ONLY: 'true',\n },\n });\n\n if (result.exitCode !== 0) {\n throw new BuildError(\n `${chalk.yellow('Unable to begin audit')} because the build failed. Build output follows:\\n${result.output}`\n );\n }\n}\n\nexport class BuildError extends Error {\n isBuildError = true;\n constructor(buildOutput: string) {\n super(buildOutput);\n }\n}\n\nexport function isBuildError(err: any): err is BuildError {\n return err?.isBuildError;\n}\n\nasync function execute(\n shellCommand: string,\n opts?: { env?: Record<string, string>; pwd?: string }\n): Promise<{\n exitCode: number;\n stderr: string;\n stdout: string;\n output: string;\n}> {\n let env: Record<string, string | undefined> | undefined;\n if (opts?.env) {\n env = { ...process.env, ...opts.env };\n }\n let child = spawn(shellCommand, {\n stdio: ['inherit', 'pipe', 'pipe'],\n cwd: opts?.pwd,\n shell: true,\n env,\n });\n let stderrBuffer: string[] = [];\n let stdoutBuffer: string[] = [];\n let combinedBuffer: string[] = [];\n child.stderr.on('data', data => {\n stderrBuffer.push(data);\n combinedBuffer.push(data);\n });\n child.stdout.on('data', data => {\n stdoutBuffer.push(data);\n combinedBuffer.push(data);\n });\n return new Promise(resolve => {\n child.on('close', (exitCode: number) => {\n resolve({\n exitCode,\n get stdout() {\n return stdoutBuffer.join('');\n },\n get stderr() {\n return stderrBuffer.join('');\n },\n get output() {\n return combinedBuffer.join('');\n },\n });\n });\n });\n}\n"]}
1
+ {"version":3,"file":"build.js","sourceRoot":"","sources":["build.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B,iDAAsC;AAE/B,KAAK,UAAU,QAAQ,CAAC,OAA0B;IACvD,IAAI,MAAM,GAAG,MAAM,OAAO,CAAC,6CAA6C,EAAE;QACxE,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,GAAG,EAAE;YACH,WAAW,EAAE,MAAM;SACpB;KACF,CAAC,CAAC;IAEH,IAAI,MAAM,CAAC,QAAQ,KAAK,CAAC,EAAE;QACzB,MAAM,IAAI,UAAU,CAClB,GAAG,eAAK,CAAC,MAAM,CAAC,uBAAuB,CAAC,qDAAqD,MAAM,CAAC,MAAM,EAAE,CAC7G,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C,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;QAC3B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,QAAgB,EAAE,EAAE;YACrC,OAAO,CAAC;gBACN,QAAQ;gBACR,IAAI,MAAM;oBACR,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/B,CAAC;gBACD,IAAI,MAAM;oBACR,OAAO,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/B,CAAC;gBACD,IAAI,MAAM;oBACR,OAAO,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACjC,CAAC;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import chalk from 'chalk';\nimport type { AuditBuildOptions } from '../audit';\nimport { spawn } from 'child_process';\n\nexport async function buildApp(options: AuditBuildOptions): Promise<void> {\n let result = await execute(`node node_modules/ember-cli/bin/ember build`, {\n pwd: options.app,\n env: {\n STAGE2_ONLY: 'true',\n },\n });\n\n if (result.exitCode !== 0) {\n throw new BuildError(\n `${chalk.yellow('Unable to begin audit')} because the build failed. Build output follows:\\n${result.output}`\n );\n }\n}\n\nexport class BuildError extends Error {\n isBuildError = true;\n constructor(buildOutput: string) {\n super(buildOutput);\n }\n}\n\nexport function isBuildError(err: any): err is BuildError {\n return err?.isBuildError;\n}\n\nasync function execute(\n shellCommand: string,\n opts?: { env?: Record<string, string>; pwd?: string }\n): Promise<{\n exitCode: number;\n stderr: string;\n stdout: string;\n output: string;\n}> {\n let env: Record<string, string | undefined> | undefined;\n if (opts?.env) {\n env = { ...process.env, ...opts.env };\n }\n let child = spawn(shellCommand, {\n stdio: ['inherit', 'pipe', 'pipe'],\n cwd: opts?.pwd,\n shell: true,\n env,\n });\n let stderrBuffer: string[] = [];\n let stdoutBuffer: string[] = [];\n let combinedBuffer: string[] = [];\n child.stderr.on('data', data => {\n stderrBuffer.push(data);\n combinedBuffer.push(data);\n });\n child.stdout.on('data', data => {\n stdoutBuffer.push(data);\n combinedBuffer.push(data);\n });\n return new Promise(resolve => {\n child.on('close', (exitCode: number) => {\n resolve({\n exitCode,\n get stdout() {\n return stdoutBuffer.join('');\n },\n get stderr() {\n return stderrBuffer.join('');\n },\n get output() {\n return combinedBuffer.join('');\n },\n });\n });\n });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"audit-cli.js","sourceRoot":"","sources":["audit-cli.ts"],"names":[],"mappings":";;;;;;AAEA,uCAAqE;AACrE,+BAA+B;AAC/B,wDAAgC;AAEhC,mCAA4D;AAE5D,gFAAgF;AAChF,2DAA2D;AAC3D,MAAM,EAAE,OAAO,EAAE,GAAG,eAEnB,CAAC;AAEF,SAAS,MAAM;IACb,OAAO,IAAA,eAAK,EAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAChC,OAAO,CACN,IAAI,EACJ,qDAAqD,EACrD,KAAK,CAAC,EAAE;QACN,OAAO,KAAK;aACT,MAAM,CAAC,OAAO,EAAE;YACf,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,0CAA0C;YACvD,OAAO,EAAE,KAAK;SACf,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACd,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,8BAA8B;YAC3C,OAAO,EAAE,KAAK;SACf,CAAC;aACD,MAAM,CAAC,aAAa,EAAE;YACrB,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,SAAS;YACf,WAAW,EAAE,sBAAsB;YACnC,OAAO,EAAE,KAAK;SACf,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACd,KAAK,EAAE,GAAG;YACV,IAAI,EAAE,QAAQ;YACd,WAAW,EAAE,6EAA6E;SAC3F,CAAC;aACD,MAAM,CAAC,MAAM,EAAE;YACd,KAAK,EA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A0B,EAAE,OAAqB;IACpE,IAAI,MAAM,EAAE,CAAC;QACX,OAAO,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;YACnD,OAAO,CAAC,MAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;gBACvC,OAAO,CACL,QAAQ,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO;oBACpC,QAAQ,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM;oBAClC,QAAQ,CAAC,QAAQ,KAAK,OAAO,CAAC,QAAQ,CACvC,CAAC;YACJ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,QAAgB,EAAE,OAAqB;IAC3D,IAAI,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACxC,QAAQ,EAAE,CAAC,CAAC,QAAQ;QACpB,OAAO,EAAE,CAAC,CAAC,OAAO;QAClB,MAAM,EAAE,CAAC,CAAC,MAAM;KACjB,CAAC,CAAC,CAAC;IACJ,IAAA,wBAAa,EAAC,QAAQ,EAAE,oBAAoB,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync, readJSONSync, writeFileSync } from 'fs-extra';\nimport { resolve } from 'path';\nimport yargs from 'yargs/yargs';\nimport type { Finding } from './audit';\nimport { Audit, AuditResults, isBuildError } from './audit';\n\n// slightly wacky because yargs types don't cover this, but you can't access the\n// other documented place to find `hideBin` on node < 12.17\nconst { hideBin } = yargs as any as {\n hideBin(argv: readonly string[]): readonly string[];\n};\n\nfunction runCLI() {\n return yargs(hideBin(process.argv))\n .command(\n '$0',\n 'audit your app for embroider compatibility problems',\n yargs => {\n return yargs\n .option('debug', {\n alias: 'd',\n type: 'boolean',\n description: 'Add debug logging about the audit itself',\n default: false,\n })\n .option('json', {\n alias: 'j',\n type: 'boolean',\n description: 'Print results in JSON format',\n default: false,\n })\n .option('reuse-build', {\n alias: 'r',\n type: 'boolean',\n description: 'Reuse previous build',\n default: false,\n })\n .option('load', {\n alias: 'l',\n type: 'string',\n description: 'Load previous audit results from a JSON file instead of running a new audit',\n })\n .option('save', {\n alias: 's',\n type: 'string',\n description: 'Save audit results as a JSON file.',\n })\n .option('app', {\n type: 'string',\n description: 'Path to your app',\n default: process.cwd(),\n })\n .option('filter', {\n type: 'string',\n description:\n 'Path to a JS file that describes which findings to silence. Generate the initial file using `--create-filter`.',\n })\n .option('create-filter', {\n type: 'string',\n description:\n 'Path to a JS file where we will create a filter that will silence all your current findings. Pass it back into future audits via --filter',\n })\n .fail(function (_, err, _yargs) {\n if (isBuildError(err)) {\n process.stderr.write(err.message + '\\n');\n } else {\n console.error(err);\n }\n process.exit(1);\n });\n },\n async options => {\n let filter = loadFilter(options);\n let results: AuditResults;\n if (options.load) {\n results = new AuditResults();\n Object.assign(results, readJSONSync(options.load));\n } else {\n results = await Audit.run(options);\n }\n if (options.save) {\n writeFileSync(options.save, JSON.stringify(results, null, 2));\n }\n applyFilter(filter, results);\n if (options.json) {\n process.stdout.write(JSON.stringify(results, null, 2) + '\\n');\n } else {\n process.stdout.write(results.humanReadable());\n }\n if (options['create-filter']) {\n createFilter(options['create-filter'], results);\n }\n process.exit(results.perfect ? 0 : 1);\n }\n )\n .command(\n 'pretty',\n 'format JSON audit results as pretty human-readable results',\n yargs => {\n return yargs.option('filter', {\n type: 'string',\n description:\n 'Path to a JS file that describes which findings to silence. Generate the file using `embroider-compat-audit acknowledge`',\n });\n },\n async options => {\n let filter = loadFilter(options);\n let results = new AuditResults();\n // process.stdin.fd is a documented public API. The Node typings don't\n // seem to know about it.\n Object.assign(results, JSON.parse(readFileSync((process.stdin as any).fd, 'utf8')));\n applyFilter(filter, results);\n process.stdout.write(results.humanReadable());\n process.exit(0);\n }\n )\n .command(\n 'acknowledge',\n 'Pipe your audit JSON to this command to generate a filter file that will silence the current issues. Pass the filter file into your next audit via --filter. Delete findings out of the filter file as you address them.',\n yargs => yargs,\n async () => {\n let results = new AuditResults();\n // process.stdin.fd is a documented public API. The Node typings don't\n // seem to know about it.\n Object.assign(results, JSON.parse(readFileSync((process.stdin as any).fd, 'utf8')));\n let findings = results.findings.map(f => ({\n filename: f.filename,\n message: f.message,\n detail: f.detail,\n }));\n process.stdout.write(`module.exports = ${JSON.stringify({ findings }, null, 2)};\\n`);\n process.exit(0);\n }\n ).argv;\n}\n\nif (require.main === module) {\n runCLI();\n}\n\ntype Filter = { findings: Omit<Finding, 'codeFrame'>[] };\n\nfunction loadFilter(options: { filter: string | undefined }): Filter | undefined {\n if (options.filter) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(resolve(options.filter));\n }\n}\n\nfunction applyFilter(filter: Filter | undefined, results: AuditResults) {\n if (filter) {\n results.findings = results.findings.filter(finding => {\n return !filter!.findings.find(filtered => {\n return (\n filtered.message === finding.message &&\n filtered.detail === finding.detail &&\n filtered.filename === finding.filename\n );\n });\n });\n }\n}\n\nfunction createFilter(filename: string, results: AuditResults) {\n let findings = results.findings.map(f => ({\n filename: f.filename,\n message: f.message,\n detail: f.detail,\n }));\n writeFileSync(filename, `module.exports = ${JSON.stringify({ findings }, null, 2)};\\n`);\n}\n"]}
1
+ {"version":3,"file":"audit-cli.js","sourceRoot":"","sources":["audit-cli.ts"],"names":[],"mappings":";;;;;;AAEA,uCAAqE;AACrE,+BAA+B;AAC/B,wDAAgC;AAEhC,mCAA4D;AAE5D,gFAAgF;AAChF,2DAA2D;AAC3D,MAAM,EAAE,OAAO,EAAE,GAAG,eAEnB,CAAC;AAEF,SAAS,MAAM;IACb,OAAO,IAAA,eAAK,EAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;SAChC,OAAO,CACN,IAAI,E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,EAAC,QAAQ,EAAE,oBAAoB,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { readFileSync, readJSONSync, writeFileSync } from 'fs-extra';\nimport { resolve } from 'path';\nimport yargs from 'yargs/yargs';\nimport type { Finding } from './audit';\nimport { Audit, AuditResults, isBuildError } from './audit';\n\n// slightly wacky because yargs types don't cover this, but you can't access the\n// other documented place to find `hideBin` on node < 12.17\nconst { hideBin } = yargs as any as {\n hideBin(argv: readonly string[]): readonly string[];\n};\n\nfunction runCLI() {\n return yargs(hideBin(process.argv))\n .command(\n '$0',\n 'audit your app for embroider compatibility problems',\n yargs => {\n return yargs\n .option('debug', {\n alias: 'd',\n type: 'boolean',\n description: 'Add debug logging about the audit itself',\n default: false,\n })\n .option('json', {\n alias: 'j',\n type: 'boolean',\n description: 'Print results in JSON format',\n default: false,\n })\n .option('reuse-build', {\n alias: 'r',\n type: 'boolean',\n description: 'Reuse previous build',\n default: false,\n })\n .option('load', {\n alias: 'l',\n type: 'string',\n description: 'Load previous audit results from a JSON file instead of running a new audit',\n })\n .option('save', {\n alias: 's',\n type: 'string',\n description: 'Save audit results as a JSON file.',\n })\n .option('app', {\n type: 'string',\n description: 'Path to your app',\n default: process.cwd(),\n })\n .option('filter', {\n type: 'string',\n description:\n 'Path to a JS file that describes which findings to silence. Generate the initial file using `--create-filter`.',\n })\n .option('create-filter', {\n type: 'string',\n description:\n 'Path to a JS file where we will create a filter that will silence all your current findings. Pass it back into future audits via --filter',\n })\n .fail(function (_, err, _yargs) {\n if (isBuildError(err)) {\n process.stderr.write(err.message + '\\n');\n } else {\n console.error(err);\n }\n process.exit(1);\n });\n },\n async options => {\n let filter = loadFilter(options);\n let results: AuditResults;\n if (options.load) {\n results = new AuditResults();\n Object.assign(results, readJSONSync(options.load));\n } else {\n results = await Audit.run(options);\n }\n if (options.save) {\n writeFileSync(options.save, JSON.stringify(results, null, 2));\n }\n applyFilter(filter, results);\n if (options.json) {\n process.stdout.write(JSON.stringify(results, null, 2) + '\\n');\n } else {\n process.stdout.write(results.humanReadable());\n }\n if (options['create-filter']) {\n createFilter(options['create-filter'], results);\n }\n process.exit(results.perfect ? 0 : 1);\n }\n )\n .command(\n 'pretty',\n 'format JSON audit results as pretty human-readable results',\n yargs => {\n return yargs.option('filter', {\n type: 'string',\n description:\n 'Path to a JS file that describes which findings to silence. Generate the file using `embroider-compat-audit acknowledge`',\n });\n },\n async options => {\n let filter = loadFilter(options);\n let results = new AuditResults();\n // process.stdin.fd is a documented public API. The Node typings don't\n // seem to know about it.\n Object.assign(results, JSON.parse(readFileSync((process.stdin as any).fd, 'utf8')));\n applyFilter(filter, results);\n process.stdout.write(results.humanReadable());\n process.exit(0);\n }\n )\n .command(\n 'acknowledge',\n 'Pipe your audit JSON to this command to generate a filter file that will silence the current issues. Pass the filter file into your next audit via --filter. Delete findings out of the filter file as you address them.',\n yargs => yargs,\n async () => {\n let results = new AuditResults();\n // process.stdin.fd is a documented public API. The Node typings don't\n // seem to know about it.\n Object.assign(results, JSON.parse(readFileSync((process.stdin as any).fd, 'utf8')));\n let findings = results.findings.map(f => ({\n filename: f.filename,\n message: f.message,\n detail: f.detail,\n }));\n process.stdout.write(`module.exports = ${JSON.stringify({ findings }, null, 2)};\\n`);\n process.exit(0);\n }\n ).argv;\n}\n\nif (require.main === module) {\n runCLI();\n}\n\ntype Filter = { findings: Omit<Finding, 'codeFrame'>[] };\n\nfunction loadFilter(options: { filter: string | undefined }): Filter | undefined {\n if (options.filter) {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n return require(resolve(options.filter));\n }\n}\n\nfunction applyFilter(filter: Filter | undefined, results: AuditResults) {\n if (filter) {\n results.findings = results.findings.filter(finding => {\n return !filter!.findings.find(filtered => {\n return (\n filtered.message === finding.message &&\n filtered.detail === finding.detail &&\n filtered.filename === finding.filename\n );\n });\n });\n }\n}\n\nfunction createFilter(filename: string, results: AuditResults) {\n let findings = results.findings.map(f => ({\n filename: f.filename,\n message: f.message,\n detail: f.detail,\n }));\n writeFileSync(filename, `module.exports = ${JSON.stringify({ findings }, null, 2)};\\n`);\n}\n"]}
package/src/audit.d.ts CHANGED
@@ -1,6 +1,7 @@
1
+ /// <reference types="node" />
2
+ import type { ExportAll, InternalImport, NamespaceMarker } from './audit/babel-visitor';
1
3
  import { AuditBuildOptions, AuditOptions } from './audit/options';
2
4
  import { BuildError, isBuildError } from './audit/build';
3
- import { type Module } from './module-visitor';
4
5
  export interface AuditMessage {
5
6
  message: string;
6
7
  detail: string;
@@ -25,19 +26,56 @@ export interface Finding {
25
26
  detail: string;
26
27
  codeFrame?: string;
27
28
  }
29
+ export interface Module {
30
+ appRelativePath: string;
31
+ consumedFrom: (string | RootMarker)[];
32
+ imports: Import[];
33
+ exports: string[];
34
+ resolutions: {
35
+ [source: string]: string | null;
36
+ };
37
+ content: string;
38
+ }
39
+ interface ResolutionFailure {
40
+ isResolutionFailure: true;
41
+ }
42
+ interface InternalModule {
43
+ consumedFrom: (string | RootMarker)[];
44
+ parsed?: {
45
+ imports: InternalImport[];
46
+ exports: Set<string | ExportAll>;
47
+ isCJS: boolean;
48
+ isAMD: boolean;
49
+ dependencies: string[];
50
+ transpiledContent: string | Buffer;
51
+ };
52
+ resolved?: Map<string, string | ResolutionFailure>;
53
+ linked?: {
54
+ exports: Set<string>;
55
+ };
56
+ }
57
+ export interface Import {
58
+ source: string;
59
+ specifiers: {
60
+ name: string | NamespaceMarker;
61
+ local: string | null;
62
+ }[];
63
+ }
28
64
  export declare class AuditResults {
29
65
  modules: {
30
66
  [file: string]: Module;
31
67
  };
32
68
  findings: Finding[];
33
- static create(baseDir: string, findings: Finding[], modules: Record<string, Module>): AuditResults;
69
+ static create(baseDir: string, findings: Finding[], modules: Map<string, InternalModule>): AuditResults;
34
70
  humanReadable(): string;
35
71
  get perfect(): boolean;
36
72
  }
37
73
  export declare class Audit {
38
74
  private originAppRoot;
39
75
  private options;
76
+ private modules;
40
77
  private virtualModules;
78
+ private moduleQueue;
41
79
  private findings;
42
80
  private frames;
43
81
  static run(options: AuditBuildOptions): Promise<AuditResults>;
@@ -49,14 +87,24 @@ export declare class Audit {
49
87
  private get resolverParams();
50
88
  private resolver;
51
89
  private debug;
90
+ private visitorFor;
91
+ private drainQueue;
52
92
  run(): Promise<AuditResults>;
53
- private resolveId;
54
- private load;
55
93
  private handleResolverError;
94
+ private linkModules;
95
+ private linkModule;
56
96
  private inspectModules;
57
97
  private inspectImports;
58
98
  private moduleProvidesName;
59
- private handleJSON;
99
+ private visitHTML;
100
+ private visitJS;
101
+ private visitHBS;
102
+ private visitJSON;
103
+ private resolveDeps;
60
104
  private pushFinding;
105
+ private scheduleVisit;
106
+ }
107
+ export interface RootMarker {
108
+ isRoot: true;
61
109
  }
62
- export { Module };
110
+ export declare function isRootMarker(value: string | RootMarker | undefined): value is RootMarker;