@embroider/compat 3.6.0 → 3.6.2-unstable.2ff89c0

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 (75) hide show
  1. package/babel.js +1 -0
  2. package/package.json +12 -10
  3. package/src/audit/babel-visitor.js +7 -1
  4. package/src/audit/babel-visitor.js.map +1 -1
  5. package/src/audit/build.js.map +1 -1
  6. package/src/audit.d.ts +6 -53
  7. package/src/audit.js +98 -285
  8. package/src/audit.js.map +1 -1
  9. package/src/babel-plugin-adjust-imports.js +2 -2
  10. package/src/babel-plugin-adjust-imports.js.map +1 -1
  11. package/src/babel.d.ts +19 -0
  12. package/src/babel.js +141 -0
  13. package/src/babel.js.map +1 -0
  14. package/src/compat-adapters/@ember-data/store.d.ts +1 -5
  15. package/src/compat-adapters/@ember-data/store.js +3 -15
  16. package/src/compat-adapters/@ember-data/store.js.map +1 -1
  17. package/src/compat-adapters/ember-fetch.d.ts +5 -0
  18. package/src/compat-adapters/ember-fetch.js +19 -0
  19. package/src/compat-adapters/ember-fetch.js.map +1 -0
  20. package/src/compat-adapters/ember-resolver.d.ts +4 -0
  21. package/src/compat-adapters/ember-resolver.js +21 -0
  22. package/src/compat-adapters/ember-resolver.js.map +1 -0
  23. package/src/compat-addons.js +1 -1
  24. package/src/compat-addons.js.map +1 -1
  25. package/src/compat-app-builder.d.ts +8 -53
  26. package/src/compat-app-builder.js +117 -1130
  27. package/src/compat-app-builder.js.map +1 -1
  28. package/src/compat-app.d.ts +4 -22
  29. package/src/compat-app.js +70 -216
  30. package/src/compat-app.js.map +1 -1
  31. package/src/content-for-config.d.ts +11 -0
  32. package/src/content-for-config.js +66 -0
  33. package/src/content-for-config.js.map +1 -0
  34. package/src/default-pipeline.d.ts +2 -2
  35. package/src/default-pipeline.js +21 -0
  36. package/src/default-pipeline.js.map +1 -1
  37. package/src/dependency-rules.js +17 -10
  38. package/src/dependency-rules.js.map +1 -1
  39. package/src/detect-babel-plugins.d.ts +1 -0
  40. package/src/detect-babel-plugins.js +14 -0
  41. package/src/detect-babel-plugins.js.map +1 -1
  42. package/src/http-audit.d.ts +13 -0
  43. package/src/http-audit.js +60 -0
  44. package/src/http-audit.js.map +1 -0
  45. package/src/index.d.ts +1 -2
  46. package/src/index.js +2 -3
  47. package/src/index.js.map +1 -1
  48. package/src/module-visitor.d.ts +52 -0
  49. package/src/module-visitor.js +285 -0
  50. package/src/module-visitor.js.map +1 -0
  51. package/src/options.d.ts +3 -2
  52. package/src/options.js +3 -0
  53. package/src/options.js.map +1 -1
  54. package/src/resolver-transform.js +7 -4
  55. package/src/resolver-transform.js.map +1 -1
  56. package/src/standalone-addon-build.js +6 -15
  57. package/src/standalone-addon-build.js.map +1 -1
  58. package/src/v1-config.d.ts +0 -8
  59. package/src/v1-config.js +1 -51
  60. package/src/v1-config.js.map +1 -1
  61. package/src/compat-adapters/@ember-data/debug.d.ts +0 -6
  62. package/src/compat-adapters/@ember-data/debug.js +0 -22
  63. package/src/compat-adapters/@ember-data/debug.js.map +0 -1
  64. package/src/rename-require-plugin.d.ts +0 -1
  65. package/src/rename-require-plugin.js +0 -15
  66. package/src/rename-require-plugin.js.map +0 -1
  67. package/src/sync-dir.d.ts +0 -8
  68. package/src/sync-dir.js +0 -68
  69. package/src/sync-dir.js.map +0 -1
  70. package/src/template-tag-codemod.d.ts +0 -10
  71. package/src/template-tag-codemod.js +0 -258
  72. package/src/template-tag-codemod.js.map +0 -1
  73. package/src/v1-appboot.d.ts +0 -14
  74. package/src/v1-appboot.js +0 -47
  75. package/src/v1-appboot.js.map +0 -1
package/src/audit.js CHANGED
@@ -10,72 +10,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Audit = exports.AuditResults = exports.isBuildError = exports.BuildError = void 0;
13
- exports.isRootMarker = isRootMarker;
14
13
  const fs_extra_1 = require("fs-extra");
15
14
  const path_1 = require("path");
16
15
  const core_1 = require("@embroider/core");
17
16
  const typescript_memoize_1 = require("typescript-memoize");
18
17
  const chalk_1 = __importDefault(require("chalk"));
19
- const jsdom_1 = __importDefault(require("jsdom"));
20
18
  const groupBy_1 = __importDefault(require("lodash/groupBy"));
21
- const fromPairs_1 = __importDefault(require("lodash/fromPairs"));
22
19
  const babel_visitor_1 = require("./audit/babel-visitor");
23
20
  const build_1 = require("./audit/build");
24
21
  Object.defineProperty(exports, "BuildError", { enumerable: true, get: function () { return build_1.BuildError; } });
25
22
  Object.defineProperty(exports, "isBuildError", { enumerable: true, get: function () { return build_1.isBuildError; } });
26
- const { JSDOM } = jsdom_1.default;
27
- function isResolutionFailure(result) {
28
- return typeof result === 'object' && 'isResolutionFailure' in result;
29
- }
30
- function isResolved(module) {
31
- return Boolean((module === null || module === void 0 ? void 0 : module.parsed) && module.resolved);
32
- }
33
- function isLinked(module) {
34
- return Boolean((module === null || module === void 0 ? void 0 : module.parsed) && module.resolved && module.linked);
35
- }
23
+ const module_visitor_1 = require("./module-visitor");
36
24
  class AuditResults {
37
25
  constructor() {
38
26
  this.modules = {};
39
27
  this.findings = [];
40
28
  }
41
29
  static create(baseDir, findings, modules) {
42
- var _a, _b, _c, _d;
43
30
  let results = new this();
44
- for (let [filename, module] of modules) {
45
- let publicModule = {
46
- appRelativePath: (0, core_1.explicitRelative)(baseDir, filename),
47
- consumedFrom: module.consumedFrom.map(entry => {
48
- if (isRootMarker(entry)) {
49
- return entry;
50
- }
51
- else {
52
- return (0, core_1.explicitRelative)(baseDir, entry);
53
- }
54
- }),
55
- resolutions: module.resolved
56
- ? (0, fromPairs_1.default)([...module.resolved].map(([source, target]) => [
57
- source,
58
- isResolutionFailure(target) ? null : (0, core_1.explicitRelative)(baseDir, target),
59
- ]))
60
- : {},
61
- imports: ((_a = module.parsed) === null || _a === void 0 ? void 0 : _a.imports)
62
- ? module.parsed.imports.map(i => ({
63
- source: i.source,
64
- specifiers: i.specifiers.map(s => ({
65
- name: s.name,
66
- local: s.local,
67
- })),
68
- }))
69
- : [],
70
- exports: ((_b = module.linked) === null || _b === void 0 ? void 0 : _b.exports) ? [...module.linked.exports] : [],
71
- content: ((_c = module.parsed) === null || _c === void 0 ? void 0 : _c.transpiledContent)
72
- ? (_d = module.parsed) === null || _d === void 0 ? void 0 : _d.transpiledContent.toString()
73
- : 'module failed to transpile',
74
- };
75
- results.modules[(0, core_1.explicitRelative)(baseDir, filename)] = publicModule;
76
- }
31
+ results.modules = modules;
77
32
  for (let finding of findings) {
78
- let relFinding = Object.assign({}, finding, { filename: (0, core_1.explicitRelative)(baseDir, finding.filename) });
33
+ const filename = finding.filename.startsWith('./')
34
+ ? finding.filename
35
+ : (0, core_1.explicitRelative)(baseDir, finding.filename);
36
+ let relFinding = Object.assign({}, finding, { filename });
79
37
  results.findings.push(relFinding);
80
38
  }
81
39
  return results;
@@ -95,7 +53,7 @@ class AuditResults {
95
53
  }
96
54
  output.push(indent(chalk_1.default.blueBright(`file was included because:`), 1));
97
55
  let pointer = filename;
98
- while (!isRootMarker(pointer)) {
56
+ while (!(0, module_visitor_1.isRootMarker)(pointer)) {
99
57
  // the zero here means we only display the first path we found. I think
100
58
  // that's a fine tradeoff to keep the output smaller.
101
59
  let nextPointer = (_a = this.modules[pointer]) === null || _a === void 0 ? void 0 : _a.consumedFrom[0];
@@ -103,7 +61,7 @@ class AuditResults {
103
61
  output.push(indent(chalk_1.default.red(`couldn't figure out why this was included. Please file a bug against @embroider/compat.`), 2));
104
62
  break;
105
63
  }
106
- if (isRootMarker(nextPointer)) {
64
+ if ((0, module_visitor_1.isRootMarker)(nextPointer)) {
107
65
  output.push(indent('packageJSON.ember-addon.assets', 2));
108
66
  }
109
67
  else {
@@ -135,22 +93,57 @@ class Audit {
135
93
  await (0, build_1.buildApp)(options);
136
94
  }
137
95
  let audit = new this(options.app, options);
138
- if (options['reuse-build']) {
139
- if (!audit.meta.babel.isParallelSafe) {
140
- throw new build_1.BuildError(`You can't use the ${chalk_1.default.red('--reuse-build')} option because some of your babel or HBS plugins are non-serializable`);
141
- }
142
- }
143
96
  return audit.run();
144
97
  }
145
98
  constructor(originAppRoot, options = {}) {
146
99
  this.originAppRoot = originAppRoot;
147
100
  this.options = options;
148
- this.modules = new Map();
149
101
  this.virtualModules = new Map();
150
- this.moduleQueue = new Set();
151
102
  this.findings = [];
152
103
  this.frames = new babel_visitor_1.CodeFrameStorage();
153
104
  this.resolver = new core_1.Resolver(this.resolverParams);
105
+ this.resolveId = async (specifier, fromFile) => {
106
+ if (['@embroider/macros'].includes(specifier)) {
107
+ // the audit process deliberately removes the @embroider/macros babel
108
+ // plugins, so the imports are still present and should be left alone.
109
+ return undefined;
110
+ }
111
+ if (fromFile.endsWith('.html') && specifier.startsWith(this.meta['root-url'])) {
112
+ // root-relative URLs in HTML are actually relative to the appDir
113
+ specifier = (0, core_1.explicitRelative)((0, path_1.dirname)(fromFile), (0, path_1.resolve)(this.movedAppRoot, specifier.replace(this.meta['root-url'], '')));
114
+ }
115
+ let resolution = await this.resolver.nodeResolve(specifier, fromFile);
116
+ switch (resolution.type) {
117
+ case 'virtual':
118
+ this.virtualModules.set(resolution.filename, resolution.content);
119
+ return resolution.filename;
120
+ case 'not_found':
121
+ return undefined;
122
+ case 'real':
123
+ return resolution.filename;
124
+ }
125
+ };
126
+ this.load = async (id) => {
127
+ let content;
128
+ if (this.virtualModules.has(id)) {
129
+ content = this.virtualModules.get(id);
130
+ }
131
+ else {
132
+ content = (0, fs_extra_1.readFileSync)(id);
133
+ }
134
+ if (id.endsWith('.html')) {
135
+ return { content, type: 'html' };
136
+ }
137
+ else if (id.endsWith('.hbs')) {
138
+ return { content: (0, core_1.hbsToJS)(content.toString('utf8')), type: 'javascript' };
139
+ }
140
+ else if (id.endsWith('.json')) {
141
+ return this.handleJSON(id, content);
142
+ }
143
+ else {
144
+ return { content, type: 'javascript' };
145
+ }
146
+ };
154
147
  }
155
148
  get pkg() {
156
149
  return (0, fs_extra_1.readJSONSync)((0, path_1.join)(this.movedAppRoot, 'package.json'));
@@ -163,12 +156,19 @@ class Audit {
163
156
  return this.pkg['ember-addon'];
164
157
  }
165
158
  get babelConfig() {
166
- // eslint-disable-next-line @typescript-eslint/no-require-imports
167
- let config = require((0, path_1.join)(this.movedAppRoot, this.meta.babel.filename));
168
- config = Object.assign({}, config);
169
- config.plugins = config.plugins.filter((p) => !isMacrosPlugin(p));
170
- config.ast = true;
171
- return config;
159
+ let origCwd = process.cwd();
160
+ process.chdir(this.originAppRoot);
161
+ try {
162
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
163
+ let config = require((0, path_1.join)(this.originAppRoot, 'babel.config.cjs'));
164
+ config = Object.assign({}, config);
165
+ config.plugins = config.plugins.filter((p) => !isMacrosPlugin(p));
166
+ config.ast = true;
167
+ return config;
168
+ }
169
+ finally {
170
+ process.chdir(origCwd);
171
+ }
172
172
  }
173
173
  get resolverParams() {
174
174
  return (0, fs_extra_1.readJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(this.originAppRoot), 'resolver.json'));
@@ -178,64 +178,22 @@ class Audit {
178
178
  console.log(message, ...args);
179
179
  }
180
180
  }
181
- visitorFor(filename) {
182
- if (filename.endsWith('.html')) {
183
- return this.visitHTML;
184
- }
185
- else if (filename.endsWith('.hbs')) {
186
- return this.visitHBS;
187
- }
188
- else if (filename.endsWith('.json')) {
189
- return this.visitJSON;
190
- }
191
- else {
192
- return this.visitJS;
193
- }
194
- }
195
- async drainQueue() {
196
- while (this.moduleQueue.size > 0) {
197
- let filename = this.moduleQueue.values().next().value;
198
- this.moduleQueue.delete(filename);
199
- this.debug('visit', filename);
200
- let visitor = this.visitorFor(filename);
201
- let content;
202
- if (this.virtualModules.has(filename)) {
203
- content = this.virtualModules.get(filename);
204
- }
205
- else {
206
- content = (0, fs_extra_1.readFileSync)(filename);
207
- }
208
- // cast is safe because the only way to get into the queue is to go
209
- // through scheduleVisit, and scheduleVisit creates the entry in
210
- // this.modules.
211
- let module = this.modules.get(filename);
212
- let visitResult = await visitor.call(this, filename, content);
213
- if (Array.isArray(visitResult)) {
214
- // the visitor was unable to figure out the ParseFields and returned
215
- // some number of Findings to us to explain why.
216
- for (let finding of visitResult) {
217
- this.pushFinding(finding);
218
- }
219
- }
220
- else {
221
- module.parsed = visitResult;
222
- module.resolved = await this.resolveDeps(visitResult.dependencies, filename);
223
- }
224
- }
225
- }
226
181
  async run() {
227
182
  globalThis.embroider_audit = this.handleResolverError.bind(this);
228
183
  try {
229
184
  this.debug(`meta`, this.meta);
230
- for (let asset of this.meta.assets) {
231
- if (asset.endsWith('.html')) {
232
- this.scheduleVisit((0, path_1.resolve)(this.movedAppRoot, asset), { isRoot: true });
233
- }
234
- }
235
- await this.drainQueue();
236
- this.linkModules();
237
- this.inspectModules();
238
- return AuditResults.create(this.originAppRoot, this.findings, this.modules);
185
+ let entrypoints = this.meta.assets.filter(a => a.endsWith('html')).map(a => (0, path_1.resolve)(this.movedAppRoot, a));
186
+ let modules = await (0, module_visitor_1.visitModules)({
187
+ base: this.originAppRoot,
188
+ entrypoints,
189
+ resolveId: this.resolveId,
190
+ load: this.load,
191
+ findings: this.findings,
192
+ frames: this.frames,
193
+ babelConfig: this.babelConfig,
194
+ });
195
+ this.inspectModules(modules);
196
+ return AuditResults.create(this.originAppRoot, this.findings, modules);
239
197
  }
240
198
  finally {
241
199
  delete globalThis.embroider_audit;
@@ -249,54 +207,22 @@ class Audit {
249
207
  codeFrame: this.frames.render(this.frames.forSource(msg.source)(msg)),
250
208
  });
251
209
  }
252
- linkModules() {
253
- for (let module of this.modules.values()) {
254
- if (isResolved(module)) {
255
- this.linkModule(module);
210
+ inspectModules(modules) {
211
+ for (let [filename, module] of Object.entries(modules)) {
212
+ if (module.type === 'complete') {
213
+ this.inspectImports(filename, module, modules);
256
214
  }
257
215
  }
258
216
  }
259
- linkModule(module) {
260
- let exports = new Set();
261
- for (let exp of module.parsed.exports) {
262
- if (typeof exp === 'string') {
263
- exports.add(exp);
264
- }
265
- else {
266
- let moduleName = module.resolved.get(exp.all);
267
- if (!isResolutionFailure(moduleName)) {
268
- let target = this.modules.get(moduleName);
269
- if (!isLinked(target) && isResolved(target)) {
270
- this.linkModule(target);
271
- }
272
- if (isLinked(target)) {
273
- for (let innerExp of target.linked.exports) {
274
- exports.add(innerExp);
275
- }
276
- }
277
- else {
278
- // our module doesn't successfully enter linked state because it
279
- // depends on stuff that also couldn't
280
- return;
281
- }
282
- }
283
- }
284
- }
285
- module.linked = {
286
- exports,
287
- };
288
- }
289
- inspectModules() {
290
- for (let [filename, module] of this.modules) {
291
- if (isLinked(module)) {
292
- this.inspectImports(filename, module);
217
+ inspectImports(filename, module, modules) {
218
+ for (let imp of module.imports) {
219
+ // our Audit should always ignore any imports of @embroider/macros because we already ignored them
220
+ // in resolveId above
221
+ if (imp.source === '@embroider/macros') {
222
+ continue;
293
223
  }
294
- }
295
- }
296
- inspectImports(filename, module) {
297
- for (let imp of module.parsed.imports) {
298
- let resolved = module.resolved.get(imp.source);
299
- if (isResolutionFailure(resolved)) {
224
+ let resolved = module.resolutions[imp.source];
225
+ if (!resolved) {
300
226
  this.findings.push({
301
227
  filename,
302
228
  message: 'unable to resolve dependency',
@@ -305,9 +231,9 @@ class Audit {
305
231
  });
306
232
  }
307
233
  else if (resolved) {
308
- let target = this.modules.get(resolved);
234
+ let target = modules[resolved];
309
235
  for (let specifier of imp.specifiers) {
310
- if (isLinked(target) && !this.moduleProvidesName(target, specifier.name)) {
236
+ if (target.type === 'complete' && !this.moduleProvidesName(target, specifier.name)) {
311
237
  if (specifier.name === 'default') {
312
238
  let backtick = '`';
313
239
  this.findings.push({
@@ -334,137 +260,27 @@ class Audit {
334
260
  // any module can provide a namespace.
335
261
  // CJS and AMD are too dynamic to be sure exactly what names are available,
336
262
  // so they always get a pass
337
- return (0, babel_visitor_1.isNamespaceMarker)(name) || target.parsed.isCJS || target.parsed.isAMD || target.linked.exports.has(name);
338
- }
339
- async visitHTML(filename, content) {
340
- let dom = new JSDOM(content);
341
- let scripts = dom.window.document.querySelectorAll('script[type="module"]');
342
- let dependencies = [];
343
- for (let script of scripts) {
344
- let src = script.src;
345
- if (!src) {
346
- continue;
347
- }
348
- if (new URL(src, 'http://example.com:4321').origin !== 'http://example.com:4321') {
349
- // src was absolute, we don't handle it
350
- continue;
351
- }
352
- if (src.startsWith(this.meta['root-url'])) {
353
- // root-relative URLs are actually relative to the appDir
354
- src = (0, core_1.explicitRelative)((0, path_1.dirname)(filename), (0, path_1.resolve)(this.movedAppRoot, src.replace(this.meta['root-url'], '')));
355
- }
356
- dependencies.push(src);
357
- }
358
- return {
359
- imports: [],
360
- exports: new Set(),
361
- isCJS: false,
362
- isAMD: false,
363
- dependencies,
364
- transpiledContent: content,
365
- };
366
- }
367
- async visitJS(filename, content) {
368
- let rawSource = content.toString('utf8');
369
- try {
370
- let result = (0, babel_visitor_1.auditJS)(rawSource, filename, this.babelConfig, this.frames);
371
- for (let problem of result.problems) {
372
- this.pushFinding({
373
- filename,
374
- message: problem.message,
375
- detail: problem.detail,
376
- codeFrame: this.frames.render(problem.codeFrameIndex),
377
- });
378
- }
379
- return {
380
- exports: result.exports,
381
- imports: result.imports,
382
- isCJS: result.isCJS,
383
- isAMD: result.isAMD,
384
- dependencies: result.imports.map(i => i.source),
385
- transpiledContent: result.transpiledContent,
386
- };
387
- }
388
- catch (err) {
389
- if (['BABEL_PARSE_ERROR', 'BABEL_TRANSFORM_ERROR'].includes(err.code)) {
390
- return [
391
- {
392
- filename,
393
- message: `failed to parse`,
394
- detail: err.toString().replace(filename, (0, core_1.explicitRelative)(this.originAppRoot, filename)),
395
- },
396
- ];
397
- }
398
- else {
399
- throw err;
400
- }
401
- }
402
- }
403
- async visitHBS(filename, content) {
404
- let rawSource = content.toString('utf8');
405
- let js = (0, core_1.hbsToJS)(rawSource);
406
- return this.visitJS(filename, js);
263
+ return (0, babel_visitor_1.isNamespaceMarker)(name) || target.isCJS || target.isAMD || target.exports.includes(name);
407
264
  }
408
- async visitJSON(filename, content) {
265
+ handleJSON(filename, content) {
409
266
  let js;
410
267
  try {
411
268
  let structure = JSON.parse(content.toString('utf8'));
412
269
  js = `export default ${JSON.stringify(structure)}`;
413
270
  }
414
271
  catch (err) {
415
- return [
416
- {
417
- filename,
418
- message: `failed to parse JSON`,
419
- detail: err.toString().replace(filename, (0, core_1.explicitRelative)(this.originAppRoot, filename)),
420
- },
421
- ];
272
+ this.findings.push({
273
+ filename,
274
+ message: `failed to parse JSON`,
275
+ detail: err.toString().replace(filename, (0, core_1.explicitRelative)(this.originAppRoot, filename)),
276
+ });
277
+ return;
422
278
  }
423
- return this.visitJS(filename, js);
424
- }
425
- async resolveDeps(deps, fromFile) {
426
- let resolved = new Map();
427
- for (let dep of deps) {
428
- let resolution = await this.resolver.nodeResolve(dep, fromFile);
429
- switch (resolution.type) {
430
- case 'virtual':
431
- this.virtualModules.set(resolution.filename, resolution.content);
432
- resolved.set(dep, resolution.filename);
433
- this.scheduleVisit(resolution.filename, fromFile);
434
- break;
435
- case 'not_found':
436
- if (['@embroider/macros', '@ember/template-factory'].includes(dep)) {
437
- // the audit process deliberately removes the @embroider/macros babel
438
- // plugins, so the imports are still present and should be left alone.
439
- continue;
440
- }
441
- resolved.set(dep, { isResolutionFailure: true });
442
- break;
443
- case 'real':
444
- resolved.set(dep, resolution.filename);
445
- this.scheduleVisit(resolution.filename, fromFile);
446
- break;
447
- }
448
- }
449
- return resolved;
279
+ return { content: js, type: 'javascript' };
450
280
  }
451
281
  pushFinding(finding) {
452
282
  this.findings.push(finding);
453
283
  }
454
- scheduleVisit(filename, parent) {
455
- let record = this.modules.get(filename);
456
- if (!record) {
457
- this.debug(`discovered`, filename);
458
- record = {
459
- consumedFrom: [parent],
460
- };
461
- this.modules.set(filename, record);
462
- this.moduleQueue.add(filename);
463
- }
464
- else {
465
- record.consumedFrom.push(parent);
466
- }
467
- }
468
284
  }
469
285
  exports.Audit = Audit;
470
286
  __decorate([
@@ -490,7 +306,4 @@ function indent(str, level) {
490
306
  .map(line => spaces + line)
491
307
  .join('\n');
492
308
  }
493
- function isRootMarker(value) {
494
- return Boolean(value && typeof value !== 'string' && value.isRoot);
495
- }
496
309
  //# sourceMappingURL=audit.js.map
package/src/audit.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"audit.js","sourceRoot":"","sources":["audit.ts"],"names":[],"mappings":";;;;;;;;;;;;AAwlBA,oCAEC;AA1lBD,uCAAsD;AACtD,+BAA6D;AAE7D,0CAAwH;AACxH,2DAA6C;AAC7C,kDAA0B;AAC1B,kDAA0B;AAC1B,6DAAqC;AACrC,iEAAyC;AAEzC,yDAAqF;AAErF,yCAAmE;AAiBzB,2FAjBvB,kBAAU,OAiBuB;AAAE,6FAjBvB,oBAAY,OAiBuB;AAflE,MAAM,EAAE,KAAK,EAAE,GAAG,eAAK,CAAC;AAqCxB,SAAS,mBAAmB,CAAC,MAA8C;IACzE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,qBAAqB,IAAI,MAAM,CAAC;AACvE,CAAC;AA6BD,SAAS,UAAU,CAAC,MAAkC;IACpD,OAAO,OAAO,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;AACpD,CAAC;AAMD,SAAS,QAAQ,CAAC,MAAkC;IAClD,OAAO,OAAO,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,KAAI,MAAM,CAAC,QAAQ,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC;AAUD,MAAa,YAAY;IAAzB;QACE,YAAO,GAA+B,EAAE,CAAC;QACzC,aAAQ,GAAc,EAAE,CAAC;IA+F3B,CAAC;IA7FC,MAAM,CAAC,MAAM,CAAC,OAAe,EAAE,QAAmB,EAAE,OAAoC;;QACtF,IAAI,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QACzB,KAAK,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC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,CAAC;aACvB,CAAC;YACF,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACnC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QACjC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;CACF;AAxXD,sBAwXC;AA3VC;IADC,IAAA,4BAAO,GAAE;gCAGT;AAGD;IADC,IAAA,4BAAO,GAAE;yCAIT;AAOD;IADC,IAAA,4BAAO,GAAE;wCAST;AAsUH,SAAS,cAAc,CAAC,CAAM;IAC5B,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,2BAA2B,CAAC;AACtE,CAAC;AAED,SAAS,MAAM,CAAC,GAAW,EAAE,KAAa;IACxC,MAAM,cAAc,GAAG,CAAC,CAAC;IACzB,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,GAAG,cAAc,EAAE,CAAC,EAAE,EAAE,CAAC;QAChD,MAAM,IAAI,GAAG,CAAC;IAChB,CAAC;IAED,OAAO,GAAG;SACP,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC;SAC1B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC;AAMD,SAAgB,YAAY,CAAC,KAAsC;IACjE,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC","sourcesContent":["import { readFileSync, readJSONSync } from 'fs-extra';\nimport { dirname, join, resolve as resolvePath } from 'path';\nimport type { AppMeta, ResolverOptions } from '@embroider/core';\nimport { explicitRelative, hbsToJS, locateEmbroiderWorkingDir, Resolver, RewrittenPackageCache } from '@embroider/core';\nimport { Memoize } from 'typescript-memoize';\nimport chalk from 'chalk';\nimport jsdom from 'jsdom';\nimport groupBy from 'lodash/groupBy';\nimport fromPairs from 'lodash/fromPairs';\nimport type { ExportAll, InternalImport, NamespaceMarker } from './audit/babel-visitor';\nimport { auditJS, CodeFrameStorage, isNamespaceMarker } from './audit/babel-visitor';\nimport { AuditBuildOptions, AuditOptions } from './audit/options';\nimport { buildApp, BuildError, isBuildError } from './audit/build';\n\nconst { JSDOM } = jsdom;\n\nexport interface AuditMessage {\n message: string;\n detail: string;\n loc: Loc;\n source: string;\n filename: string;\n}\n\nexport interface Loc {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\nexport { AuditOptions, AuditBuildOptions, BuildError, isBuildError };\n\nexport interface Finding {\n message: string;\n filename: string;\n detail: string;\n codeFrame?: string;\n}\n\nexport interface Module {\n appRelativePath: string;\n consumedFrom: (string | RootMarker)[];\n imports: Import[];\n exports: string[];\n resolutions: { [source: string]: string | null };\n content: string;\n}\n\ninterface ResolutionFailure {\n isResolutionFailure: true;\n}\n\nfunction isResolutionFailure(result: string | ResolutionFailure | undefined): result is ResolutionFailure {\n return typeof result === 'object' && 'isResolutionFailure' in result;\n}\n\ninterface InternalModule {\n consumedFrom: (string | RootMarker)[];\n\n parsed?: {\n imports: InternalImport[];\n exports: Set<string | ExportAll>;\n isCJS: boolean;\n isAMD: boolean;\n dependencies: string[];\n transpiledContent: string | Buffer;\n };\n\n resolved?: Map<string, string | ResolutionFailure>;\n\n linked?: {\n exports: Set<string>;\n };\n}\n\ntype ParsedInternalModule = Omit<InternalModule, 'parsed'> & {\n parsed: NonNullable<InternalModule['parsed']>;\n};\n\ntype ResolvedInternalModule = Omit<ParsedInternalModule, 'resolved'> & {\n resolved: NonNullable<ParsedInternalModule['resolved']>;\n};\n\nfunction isResolved(module: InternalModule | undefined): module is ResolvedInternalModule {\n return Boolean(module?.parsed && module.resolved);\n}\n\ntype LinkedInternalModule = Omit<ResolvedInternalModule, 'linked'> & {\n linked: NonNullable<ResolvedInternalModule['linked']>;\n};\n\nfunction isLinked(module: InternalModule | undefined): module is LinkedInternalModule {\n return Boolean(module?.parsed && module.resolved && module.linked);\n}\n\nexport interface Import {\n source: string;\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 }[];\n}\n\nexport class AuditResults {\n modules: { [file: string]: Module } = {};\n findings: Finding[] = [];\n\n static create(baseDir: string, findings: Finding[], modules: Map<string, InternalModule>) {\n let results = new this();\n for (let [filename, module] of modules) {\n let publicModule: Module = {\n appRelativePath: explicitRelative(baseDir, filename),\n consumedFrom: module.consumedFrom.map(entry => {\n if (isRootMarker(entry)) {\n return entry;\n } else {\n return explicitRelative(baseDir, entry);\n }\n }),\n resolutions: module.resolved\n ? fromPairs(\n [...module.resolved].map(([source, target]) => [\n source,\n isResolutionFailure(target) ? null : explicitRelative(baseDir, target),\n ])\n )\n : {},\n imports: module.parsed?.imports\n ? module.parsed.imports.map(i => ({\n source: i.source,\n specifiers: i.specifiers.map(s => ({\n name: s.name,\n local: s.local,\n })),\n }))\n : [],\n exports: module.linked?.exports ? [...module.linked.exports] : [],\n content: module.parsed?.transpiledContent\n ? module.parsed?.transpiledContent.toString()\n : 'module failed to transpile',\n };\n results.modules[explicitRelative(baseDir, filename)] = publicModule;\n }\n for (let finding of findings) {\n let relFinding = Object.assign({}, finding, { filename: explicitRelative(baseDir, finding.filename) });\n results.findings.push(relFinding);\n }\n return results;\n }\n\n humanReadable(): string {\n let output = [] as string[];\n let findingsByFile = groupBy(this.findings, f => f.filename);\n output.push(`=== Audit Results ===`);\n for (let [filename, findings] of Object.entries(findingsByFile)) {\n output.push(`${chalk.yellow(filename)}`);\n for (let finding of findings) {\n output.push(indent(chalk.red(finding.message) + ': ' + finding.detail, 1));\n if (finding.codeFrame) {\n output.push(indent(finding.codeFrame, 2));\n }\n }\n output.push(indent(chalk.blueBright(`file was included because:`), 1));\n let pointer: string | RootMarker = filename;\n while (!isRootMarker(pointer)) {\n // the zero here means we only display the first path we found. I think\n // that's a fine tradeoff to keep the output smaller.\n let nextPointer: string | RootMarker | undefined = this.modules[pointer]?.consumedFrom[0];\n if (!nextPointer) {\n output.push(\n indent(\n chalk.red(`couldn't figure out why this was included. Please file a bug against @embroider/compat.`),\n 2\n )\n );\n break;\n }\n if (isRootMarker(nextPointer)) {\n output.push(indent('packageJSON.ember-addon.assets', 2));\n } else {\n output.push(indent(nextPointer, 2));\n }\n pointer = nextPointer;\n }\n }\n let summaryColor;\n if (this.perfect) {\n summaryColor = chalk.green;\n } else {\n summaryColor = chalk.yellow;\n }\n output.push(summaryColor(`${this.findings.length} issues found`));\n output.push(`=== End Audit Results ===`);\n output.push(''); // always end with a newline because `yarn run` can overwrite our last line otherwise\n return output.join('\\n');\n }\n\n get perfect() {\n return this.findings.length === 0;\n }\n}\n\nexport class Audit {\n private modules: Map<string, InternalModule> = new Map();\n private virtualModules: Map<string, string> = new Map();\n private moduleQueue = new Set<string>();\n private findings = [] as Finding[];\n\n private frames = new CodeFrameStorage();\n\n static async run(options: AuditBuildOptions): Promise<AuditResults> {\n if (!options['reuse-build']) {\n await buildApp(options);\n }\n\n let audit = new this(options.app, options);\n if (options['reuse-build']) {\n if (!audit.meta.babel.isParallelSafe) {\n throw new BuildError(\n `You can't use the ${chalk.red(\n '--reuse-build'\n )} option because some of your babel or HBS plugins are non-serializable`\n );\n }\n }\n return audit.run();\n }\n\n constructor(private originAppRoot: string, private options: AuditOptions = {}) {}\n\n @Memoize()\n private get pkg() {\n return readJSONSync(join(this.movedAppRoot, 'package.json'));\n }\n\n @Memoize()\n private get movedAppRoot() {\n let cache = RewrittenPackageCache.shared('embroider', this.originAppRoot);\n return cache.maybeMoved(cache.get(this.originAppRoot)).root;\n }\n\n private get meta() {\n return this.pkg['ember-addon'] as AppMeta;\n }\n\n @Memoize()\n private get babelConfig() {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let config = require(join(this.movedAppRoot, this.meta.babel.filename));\n config = Object.assign({}, config);\n config.plugins = config.plugins.filter((p: any) => !isMacrosPlugin(p));\n\n config.ast = true;\n return config;\n }\n\n private get resolverParams(): ResolverOptions {\n return readJSONSync(join(locateEmbroiderWorkingDir(this.originAppRoot), 'resolver.json'));\n }\n\n private resolver = new Resolver(this.resolverParams);\n\n private debug(message: string, ...args: any[]) {\n if (this.options.debug) {\n console.log(message, ...args);\n }\n }\n\n private visitorFor(\n filename: string\n ): (\n this: Audit,\n filename: string,\n content: Buffer | string\n ) => Promise<NonNullable<InternalModule['parsed']> | Finding[]> {\n if (filename.endsWith('.html')) {\n return this.visitHTML;\n } else if (filename.endsWith('.hbs')) {\n return this.visitHBS;\n } else if (filename.endsWith('.json')) {\n return this.visitJSON;\n } else {\n return this.visitJS;\n }\n }\n\n private async drainQueue() {\n while (this.moduleQueue.size > 0) {\n let filename = this.moduleQueue.values().next().value as string;\n this.moduleQueue.delete(filename);\n this.debug('visit', filename);\n let visitor = this.visitorFor(filename);\n let content: string | Buffer;\n if (this.virtualModules.has(filename)) {\n content = this.virtualModules.get(filename)!;\n } else {\n content = readFileSync(filename);\n }\n // cast is safe because the only way to get into the queue is to go\n // through scheduleVisit, and scheduleVisit creates the entry in\n // this.modules.\n let module: InternalModule = this.modules.get(filename)!;\n let visitResult = await visitor.call(this, filename, content);\n if (Array.isArray(visitResult)) {\n // the visitor was unable to figure out the ParseFields and returned\n // some number of Findings to us to explain why.\n for (let finding of visitResult) {\n this.pushFinding(finding);\n }\n } else {\n module.parsed = visitResult;\n module.resolved = await this.resolveDeps(visitResult.dependencies, filename);\n }\n }\n }\n\n async run(): Promise<AuditResults> {\n (globalThis as any).embroider_audit = this.handleResolverError.bind(this);\n\n try {\n this.debug(`meta`, this.meta);\n for (let asset of this.meta.assets) {\n if (asset.endsWith('.html')) {\n this.scheduleVisit(resolvePath(this.movedAppRoot, asset), { isRoot: true });\n }\n }\n await this.drainQueue();\n this.linkModules();\n this.inspectModules();\n\n return AuditResults.create(this.originAppRoot, this.findings, this.modules);\n } finally {\n delete (globalThis as any).embroider_audit;\n }\n }\n\n private handleResolverError(msg: AuditMessage) {\n this.pushFinding({\n message: msg.message,\n filename: msg.filename,\n detail: msg.detail,\n codeFrame: this.frames.render(this.frames.forSource(msg.source)(msg)),\n });\n }\n\n private linkModules() {\n for (let module of this.modules.values()) {\n if (isResolved(module)) {\n this.linkModule(module);\n }\n }\n }\n\n private linkModule(module: ResolvedInternalModule) {\n let exports = new Set<string>();\n for (let exp of module.parsed.exports) {\n if (typeof exp === 'string') {\n exports.add(exp);\n } else {\n let moduleName = module.resolved.get(exp.all)!;\n if (!isResolutionFailure(moduleName)) {\n let target = this.modules.get(moduleName)!;\n if (!isLinked(target) && isResolved(target)) {\n this.linkModule(target);\n }\n if (isLinked(target)) {\n for (let innerExp of target.linked.exports) {\n exports.add(innerExp);\n }\n } else {\n // our module doesn't successfully enter linked state because it\n // depends on stuff that also couldn't\n return;\n }\n }\n }\n }\n module.linked = {\n exports,\n };\n }\n\n private inspectModules() {\n for (let [filename, module] of this.modules) {\n if (isLinked(module)) {\n this.inspectImports(filename, module);\n }\n }\n }\n\n private inspectImports(filename: string, module: LinkedInternalModule) {\n for (let imp of module.parsed.imports) {\n let resolved = module.resolved.get(imp.source);\n if (isResolutionFailure(resolved)) {\n this.findings.push({\n filename,\n message: 'unable to resolve dependency',\n detail: imp.source,\n codeFrame: this.frames.render(imp.codeFrameIndex),\n });\n } else if (resolved) {\n let target = this.modules.get(resolved)!;\n for (let specifier of imp.specifiers) {\n if (isLinked(target) && !this.moduleProvidesName(target, specifier.name)) {\n if (specifier.name === 'default') {\n let backtick = '`';\n this.findings.push({\n filename,\n message: 'importing a non-existent default export',\n detail: `\"${imp.source}\" has no default export. Did you mean ${backtick}import * as ${specifier.local} from \"${imp.source}\"${backtick}?`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n } else {\n this.findings.push({\n filename,\n message: 'importing a non-existent named export',\n detail: `\"${imp.source}\" has no export named \"${specifier.name}\".`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n }\n }\n }\n }\n }\n }\n\n private moduleProvidesName(target: LinkedInternalModule, name: string | NamespaceMarker) {\n // any module can provide a namespace.\n // CJS and AMD are too dynamic to be sure exactly what names are available,\n // so they always get a pass\n return isNamespaceMarker(name) || target.parsed.isCJS || target.parsed.isAMD || target.linked.exports.has(name);\n }\n\n private async visitHTML(filename: string, content: Buffer | string): Promise<ParsedInternalModule['parsed']> {\n let dom = new JSDOM(content);\n let scripts = dom.window.document.querySelectorAll('script[type=\"module\"]') as NodeListOf<HTMLScriptElement>;\n let dependencies = [] as string[];\n for (let script of scripts) {\n let src = script.src;\n if (!src) {\n continue;\n }\n if (new URL(src, 'http://example.com:4321').origin !== 'http://example.com:4321') {\n // src was absolute, we don't handle it\n continue;\n }\n if (src.startsWith(this.meta['root-url'])) {\n // root-relative URLs are actually relative to the appDir\n src = explicitRelative(\n dirname(filename),\n resolvePath(this.movedAppRoot, src.replace(this.meta['root-url'], ''))\n );\n }\n dependencies.push(src);\n }\n\n return {\n imports: [],\n exports: new Set(),\n isCJS: false,\n isAMD: false,\n dependencies,\n transpiledContent: content,\n };\n }\n\n private async visitJS(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let rawSource = content.toString('utf8');\n try {\n let result = auditJS(rawSource, filename, this.babelConfig, this.frames);\n\n for (let problem of result.problems) {\n this.pushFinding({\n filename,\n message: problem.message,\n detail: problem.detail,\n codeFrame: this.frames.render(problem.codeFrameIndex),\n });\n }\n return {\n exports: result.exports,\n imports: result.imports,\n isCJS: result.isCJS,\n isAMD: result.isAMD,\n dependencies: result.imports.map(i => i.source),\n transpiledContent: result.transpiledContent,\n };\n } catch (err) {\n if (['BABEL_PARSE_ERROR', 'BABEL_TRANSFORM_ERROR'].includes(err.code)) {\n return [\n {\n filename,\n message: `failed to parse`,\n detail: err.toString().replace(filename, explicitRelative(this.originAppRoot, filename)),\n },\n ];\n } else {\n throw err;\n }\n }\n }\n\n private async visitHBS(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let rawSource = content.toString('utf8');\n let js = hbsToJS(rawSource);\n return this.visitJS(filename, js);\n }\n\n private async visitJSON(\n filename: string,\n content: Buffer | string\n ): Promise<ParsedInternalModule['parsed'] | Finding[]> {\n let js;\n try {\n let structure = JSON.parse(content.toString('utf8'));\n js = `export default ${JSON.stringify(structure)}`;\n } catch (err) {\n return [\n {\n filename,\n message: `failed to parse JSON`,\n detail: err.toString().replace(filename, explicitRelative(this.originAppRoot, filename)),\n },\n ];\n }\n return this.visitJS(filename, js);\n }\n\n private async resolveDeps(deps: string[], fromFile: string): Promise<InternalModule['resolved']> {\n let resolved = new Map() as NonNullable<InternalModule['resolved']>;\n for (let dep of deps) {\n let resolution = await this.resolver.nodeResolve(dep, fromFile);\n switch (resolution.type) {\n case 'virtual':\n this.virtualModules.set(resolution.filename, resolution.content);\n resolved.set(dep, resolution.filename);\n this.scheduleVisit(resolution.filename, fromFile);\n break;\n case 'not_found':\n if (['@embroider/macros', '@ember/template-factory'].includes(dep)) {\n // the audit process deliberately removes the @embroider/macros babel\n // plugins, so the imports are still present and should be left alone.\n continue;\n }\n resolved.set(dep, { isResolutionFailure: true as true });\n break;\n case 'real':\n resolved.set(dep, resolution.filename);\n this.scheduleVisit(resolution.filename, fromFile);\n break;\n }\n }\n return resolved;\n }\n\n private pushFinding(finding: Finding) {\n this.findings.push(finding);\n }\n\n private scheduleVisit(filename: string, parent: string | RootMarker) {\n let record = this.modules.get(filename);\n if (!record) {\n this.debug(`discovered`, filename);\n record = {\n consumedFrom: [parent],\n };\n this.modules.set(filename, record);\n this.moduleQueue.add(filename);\n } else {\n record.consumedFrom.push(parent);\n }\n }\n}\n\nfunction isMacrosPlugin(p: any) {\n return Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker;\n}\n\nfunction indent(str: string, level: number) {\n const spacesPerLevel = 2;\n let spaces = '';\n for (let i = 0; i < level * spacesPerLevel; i++) {\n spaces += ' ';\n }\n\n return str\n .split('\\n')\n .map(line => spaces + line)\n .join('\\n');\n}\n\nexport interface RootMarker {\n isRoot: true;\n}\n\nexport function isRootMarker(value: string | RootMarker | undefined): value is RootMarker {\n return Boolean(value && typeof value !== 'string' && value.isRoot);\n}\n"]}
1
+ {"version":3,"file":"audit.js","sourceRoot":"","sources":["audit.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAsD;AACtD,+BAA6D;AAE7D,0CAAwH;AACxH,2DAA6C;AAC7C,kDAA0B;AAC1B,6DAAqC;AAErC,yDAA4E;AAE5E,yCAAmE;AAuBzB,2FAvBvB,kBAAU,OAuBuB;AAAE,6FAvBvB,oBAAY,OAuBuB;AAtBlE,qDAO0B;AAwB1B,MAAa,YAAY;IAAzB;QACE,YAAO,GAA+B,EAAE,CAAC;QACzC,aAAQ,GAAc,EAAE,CAAC;IAkE3B,CAAC;IAhEC,MAAM,CAAC,MAAM,CAAC,OAAe,EAAE,QAAmB,EAAE,OAA+B;QACjF,IAAI,OAAO,GAAG,IAAI,IAAI,EAAE,CAAC;QACzB,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC;QAC1B,KAAK,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC;gBAChD,CAAC,CAAC,OAAO,CAAC,QAAQ;gBAClB,CAAC,CAAC,IAAA,uBAAgB,EAAC,OAAO,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;YAEhD,IAAI,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;YAC1D,OAAO,CAAC,QAAQ,CAAC,IAA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AAC;SACX,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC;SAC1B,IAAI,CAAC,IAAI,CAAC,CAAC;AAChB,CAAC","sourcesContent":["import { readFileSync, readJSONSync } from 'fs-extra';\nimport { join, resolve as resolvePath, dirname } from 'path';\nimport type { AppMeta, ResolverOptions } from '@embroider/core';\nimport { explicitRelative, hbsToJS, locateEmbroiderWorkingDir, Resolver, RewrittenPackageCache } from '@embroider/core';\nimport { Memoize } from 'typescript-memoize';\nimport chalk from 'chalk';\nimport groupBy from 'lodash/groupBy';\nimport type { NamespaceMarker } from './audit/babel-visitor';\nimport { CodeFrameStorage, isNamespaceMarker } from './audit/babel-visitor';\nimport { AuditBuildOptions, AuditOptions } from './audit/options';\nimport { buildApp, BuildError, isBuildError } from './audit/build';\nimport {\n type ContentType,\n type Module,\n visitModules,\n type RootMarker,\n isRootMarker,\n type CompleteModule,\n} from './module-visitor';\n\nexport interface AuditMessage {\n message: string;\n detail: string;\n loc: Loc;\n source: string;\n filename: string;\n}\n\nexport interface Loc {\n start: { line: number; column: number };\n end: { line: number; column: number };\n}\n\nexport { AuditOptions, AuditBuildOptions, BuildError, isBuildError };\n\nexport interface Finding {\n message: string;\n filename: string;\n detail: string;\n codeFrame?: string;\n}\n\nexport class AuditResults {\n modules: { [file: string]: Module } = {};\n findings: Finding[] = [];\n\n static create(baseDir: string, findings: Finding[], modules: Record<string, Module>) {\n let results = new this();\n results.modules = modules;\n for (let finding of findings) {\n const filename = finding.filename.startsWith('./')\n ? finding.filename\n : explicitRelative(baseDir, finding.filename);\n\n let relFinding = Object.assign({}, finding, { filename });\n results.findings.push(relFinding);\n }\n return results;\n }\n\n humanReadable(): string {\n let output = [] as string[];\n let findingsByFile = groupBy(this.findings, f => f.filename);\n output.push(`=== Audit Results ===`);\n for (let [filename, findings] of Object.entries(findingsByFile)) {\n output.push(`${chalk.yellow(filename)}`);\n for (let finding of findings) {\n output.push(indent(chalk.red(finding.message) + ': ' + finding.detail, 1));\n if (finding.codeFrame) {\n output.push(indent(finding.codeFrame, 2));\n }\n }\n output.push(indent(chalk.blueBright(`file was included because:`), 1));\n let pointer: string | RootMarker = filename;\n while (!isRootMarker(pointer)) {\n // the zero here means we only display the first path we found. I think\n // that's a fine tradeoff to keep the output smaller.\n let nextPointer: string | RootMarker | undefined = this.modules[pointer]?.consumedFrom[0];\n if (!nextPointer) {\n output.push(\n indent(\n chalk.red(`couldn't figure out why this was included. Please file a bug against @embroider/compat.`),\n 2\n )\n );\n break;\n }\n if (isRootMarker(nextPointer)) {\n output.push(indent('packageJSON.ember-addon.assets', 2));\n } else {\n output.push(indent(nextPointer, 2));\n }\n pointer = nextPointer;\n }\n }\n let summaryColor;\n if (this.perfect) {\n summaryColor = chalk.green;\n } else {\n summaryColor = chalk.yellow;\n }\n output.push(summaryColor(`${this.findings.length} issues found`));\n output.push(`=== End Audit Results ===`);\n output.push(''); // always end with a newline because `yarn run` can overwrite our last line otherwise\n return output.join('\\n');\n }\n\n get perfect() {\n return this.findings.length === 0;\n }\n}\n\nexport class Audit {\n private virtualModules: Map<string, string> = new Map();\n private findings = [] as Finding[];\n\n private frames = new CodeFrameStorage();\n\n static async run(options: AuditBuildOptions): Promise<AuditResults> {\n if (!options['reuse-build']) {\n await buildApp(options);\n }\n\n let audit = new this(options.app, options);\n return audit.run();\n }\n\n constructor(private originAppRoot: string, private options: AuditOptions = {}) {}\n\n @Memoize()\n private get pkg() {\n return readJSONSync(join(this.movedAppRoot, 'package.json'));\n }\n\n @Memoize()\n private get movedAppRoot() {\n let cache = RewrittenPackageCache.shared('embroider', this.originAppRoot);\n return cache.maybeMoved(cache.get(this.originAppRoot)).root;\n }\n\n private get meta() {\n return this.pkg['ember-addon'] as AppMeta;\n }\n\n @Memoize()\n private get babelConfig() {\n let origCwd = process.cwd();\n process.chdir(this.originAppRoot);\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n let config = require(join(this.originAppRoot, 'babel.config.cjs'));\n\n config = Object.assign({}, config);\n config.plugins = config.plugins.filter((p: any) => !isMacrosPlugin(p));\n\n config.ast = true;\n return config;\n } finally {\n process.chdir(origCwd);\n }\n }\n\n private get resolverParams(): ResolverOptions {\n return readJSONSync(join(locateEmbroiderWorkingDir(this.originAppRoot), 'resolver.json'));\n }\n\n private resolver = new Resolver(this.resolverParams);\n\n private debug(message: string, ...args: any[]) {\n if (this.options.debug) {\n console.log(message, ...args);\n }\n }\n\n async run(): Promise<AuditResults> {\n (globalThis as any).embroider_audit = this.handleResolverError.bind(this);\n\n try {\n this.debug(`meta`, this.meta);\n let entrypoints = this.meta.assets.filter(a => a.endsWith('html')).map(a => resolvePath(this.movedAppRoot, a));\n\n let modules = await visitModules({\n base: this.originAppRoot,\n entrypoints,\n resolveId: this.resolveId,\n load: this.load,\n findings: this.findings,\n frames: this.frames,\n babelConfig: this.babelConfig,\n });\n\n this.inspectModules(modules);\n\n return AuditResults.create(this.originAppRoot, this.findings, modules);\n } finally {\n delete (globalThis as any).embroider_audit;\n }\n }\n\n private resolveId = async (specifier: string, fromFile: string): Promise<string | undefined> => {\n if (['@embroider/macros'].includes(specifier)) {\n // the audit process deliberately removes the @embroider/macros babel\n // plugins, so the imports are still present and should be left alone.\n return undefined;\n }\n\n if (fromFile.endsWith('.html') && specifier.startsWith(this.meta['root-url'])) {\n // root-relative URLs in HTML are actually relative to the appDir\n specifier = explicitRelative(\n dirname(fromFile),\n resolvePath(this.movedAppRoot, specifier.replace(this.meta['root-url'], ''))\n );\n }\n\n let resolution = await this.resolver.nodeResolve(specifier, fromFile);\n switch (resolution.type) {\n case 'virtual':\n this.virtualModules.set(resolution.filename, resolution.content);\n return resolution.filename;\n case 'not_found':\n return undefined;\n case 'real':\n return resolution.filename;\n }\n };\n\n private load = async (id: string): Promise<{ content: string | Buffer; type: ContentType } | undefined> => {\n let content: string | Buffer;\n if (this.virtualModules.has(id)) {\n content = this.virtualModules.get(id)!;\n } else {\n content = readFileSync(id);\n }\n\n if (id.endsWith('.html')) {\n return { content, type: 'html' };\n } else if (id.endsWith('.hbs')) {\n return { content: hbsToJS(content.toString('utf8')), type: 'javascript' };\n } else if (id.endsWith('.json')) {\n return this.handleJSON(id, content);\n } else {\n return { content, type: 'javascript' };\n }\n };\n\n private handleResolverError(msg: AuditMessage) {\n this.pushFinding({\n message: msg.message,\n filename: msg.filename,\n detail: msg.detail,\n codeFrame: this.frames.render(this.frames.forSource(msg.source)(msg)),\n });\n }\n\n private inspectModules(modules: Record<string, Module>) {\n for (let [filename, module] of Object.entries(modules)) {\n if (module.type === 'complete') {\n this.inspectImports(filename, module, modules);\n }\n }\n }\n\n private inspectImports(filename: string, module: CompleteModule, modules: Record<string, Module>) {\n for (let imp of module.imports) {\n // our Audit should always ignore any imports of @embroider/macros because we already ignored them\n // in resolveId above\n if (imp.source === '@embroider/macros') {\n continue;\n }\n let resolved = module.resolutions[imp.source];\n if (!resolved) {\n this.findings.push({\n filename,\n message: 'unable to resolve dependency',\n detail: imp.source,\n codeFrame: this.frames.render(imp.codeFrameIndex),\n });\n } else if (resolved) {\n let target = modules[resolved]!;\n for (let specifier of imp.specifiers) {\n if (target.type === 'complete' && !this.moduleProvidesName(target, specifier.name)) {\n if (specifier.name === 'default') {\n let backtick = '`';\n this.findings.push({\n filename,\n message: 'importing a non-existent default export',\n detail: `\"${imp.source}\" has no default export. Did you mean ${backtick}import * as ${specifier.local} from \"${imp.source}\"${backtick}?`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n } else {\n this.findings.push({\n filename,\n message: 'importing a non-existent named export',\n detail: `\"${imp.source}\" has no export named \"${specifier.name}\".`,\n codeFrame: this.frames.render(specifier.codeFrameIndex),\n });\n }\n }\n }\n }\n }\n }\n\n private moduleProvidesName(target: CompleteModule, name: string | NamespaceMarker) {\n // any module can provide a namespace.\n // CJS and AMD are too dynamic to be sure exactly what names are available,\n // so they always get a pass\n return isNamespaceMarker(name) || target.isCJS || target.isAMD || target.exports.includes(name);\n }\n\n private handleJSON(filename: string, content: Buffer | string): { content: string; type: ContentType } | undefined {\n let js;\n try {\n let structure = JSON.parse(content.toString('utf8'));\n js = `export default ${JSON.stringify(structure)}`;\n } catch (err) {\n this.findings.push({\n filename,\n message: `failed to parse JSON`,\n detail: err.toString().replace(filename, explicitRelative(this.originAppRoot, filename)),\n });\n return;\n }\n return { content: js, type: 'javascript' };\n }\n\n private pushFinding(finding: Finding) {\n this.findings.push(finding);\n }\n}\n\nfunction isMacrosPlugin(p: any) {\n return Array.isArray(p) && p[1] && p[1].embroiderMacrosConfigMarker;\n}\n\nfunction indent(str: string, level: number) {\n const spacesPerLevel = 2;\n let spaces = '';\n for (let i = 0; i < level * spacesPerLevel; i++) {\n spaces += ' ';\n }\n\n return str\n .split('\\n')\n .map(line => spaces + line)\n .join('\\n');\n}\n\nexport { Module };\n"]}
@@ -38,7 +38,7 @@ main.baseDir = function () {
38
38
  return (0, path_1.join)(__dirname, '..');
39
39
  };
40
40
  function addExtraImports(t, path, config) {
41
- let filename = path.hub.file.opts.filename;
41
+ let filename = (0, core_1.cleanUrl)(path.hub.file.opts.filename);
42
42
  let entry = config.extraImports[filename];
43
43
  let adder = new babel_import_util_1.ImportUtil(t, path);
44
44
  if (entry) {
@@ -71,7 +71,7 @@ function applyRules(t, path, rules, adder, config, filename) {
71
71
  if (rules.dependsOnComponents) {
72
72
  for (let dasherizedName of rules.dependsOnComponents) {
73
73
  if (lookup.owningEngine) {
74
- path.node.body.unshift(amdDefine(t, adder, path, `#embroider_compat/components/${dasherizedName}`, `${lookup.owningEngine.packageName}/components/${dasherizedName}`));
74
+ path.node.body.unshift(amdDefine(t, adder, path, `@embroider/virtual/components/${dasherizedName}`, `${lookup.owningEngine.packageName}/components/${dasherizedName}`));
75
75
  }
76
76
  }
77
77
  }