@embroider/compat 3.5.1 → 3.5.2-unstable.217e7a8

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/package.json +13 -13
  2. package/src/audit/babel-visitor.js +5 -3
  3. package/src/audit/babel-visitor.js.map +1 -1
  4. package/src/audit/build.js.map +1 -1
  5. package/src/audit-cli.js.map +1 -1
  6. package/src/audit.d.ts +6 -54
  7. package/src/audit.js +93 -277
  8. package/src/audit.js.map +1 -1
  9. package/src/babel-plugin-adjust-imports.d.ts +2 -1
  10. package/src/babel-plugin-adjust-imports.js +1 -1
  11. package/src/babel-plugin-adjust-imports.js.map +1 -1
  12. package/src/build-compat-addon.js.map +1 -1
  13. package/src/compat-adapters/@ember/test-waiters.js.map +1 -1
  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-asset-loader.js.map +1 -1
  18. package/src/compat-adapters/ember-cli-babel.js.map +1 -1
  19. package/src/compat-adapters/ember-cli-fastboot.js.map +1 -1
  20. package/src/compat-adapters/ember-cli-mirage.js.map +1 -1
  21. package/src/compat-adapters/ember-composable-helpers.js.map +1 -1
  22. package/src/compat-adapters/ember-data.js.map +1 -1
  23. package/src/compat-adapters/ember-engines.js.map +1 -1
  24. package/src/compat-adapters/ember-fetch.d.ts +5 -0
  25. package/src/compat-adapters/ember-fetch.js +19 -0
  26. package/src/compat-adapters/ember-fetch.js.map +1 -0
  27. package/src/compat-adapters/ember-macro-helpers.js.map +1 -1
  28. package/src/compat-adapters/ember-scroll-modifiers.js.map +1 -1
  29. package/src/compat-adapters/ember-source.js.map +1 -1
  30. package/src/compat-adapters/ember-svg-jar.js.map +1 -1
  31. package/src/compat-addons.js.map +1 -1
  32. package/src/compat-app-builder.d.ts +9 -31
  33. package/src/compat-app-builder.js +75 -858
  34. package/src/compat-app-builder.js.map +1 -1
  35. package/src/compat-app.d.ts +2 -8
  36. package/src/compat-app.js +54 -49
  37. package/src/compat-app.js.map +1 -1
  38. package/src/compat-utils.js.map +1 -1
  39. package/src/content-for-config.d.ts +11 -0
  40. package/src/content-for-config.js +66 -0
  41. package/src/content-for-config.js.map +1 -0
  42. package/src/dasherize-component-name.js.map +1 -1
  43. package/src/default-pipeline.d.ts +2 -2
  44. package/src/default-pipeline.js +22 -1
  45. package/src/default-pipeline.js.map +1 -1
  46. package/src/dependency-rules.js.map +1 -1
  47. package/src/detect-babel-plugins.js.map +1 -1
  48. package/src/detect-compact-reexports.js.map +1 -1
  49. package/src/dummy-package.js.map +1 -1
  50. package/src/empty-package-tree.js.map +1 -1
  51. package/src/get-real-addon.js.map +1 -1
  52. package/src/hbs-to-js-broccoli-plugin.js.map +1 -1
  53. package/src/http-audit.d.ts +13 -0
  54. package/src/http-audit.js +46 -0
  55. package/src/http-audit.js.map +1 -0
  56. package/src/index.d.ts +1 -1
  57. package/src/index.js +2 -1
  58. package/src/index.js.map +1 -1
  59. package/src/merges.js.map +1 -1
  60. package/src/module-visitor.d.ts +53 -0
  61. package/src/module-visitor.js +286 -0
  62. package/src/module-visitor.js.map +1 -0
  63. package/src/options.d.ts +1 -0
  64. package/src/options.js +1 -0
  65. package/src/options.js.map +1 -1
  66. package/src/prepare-htmlbars-ast-plugins.js.map +1 -1
  67. package/src/rename-require-plugin.js.map +1 -1
  68. package/src/resolver-transform.js +3 -0
  69. package/src/resolver-transform.js.map +1 -1
  70. package/src/rewrite-addon-tree.js.map +1 -1
  71. package/src/smoosh-package-json.js.map +1 -1
  72. package/src/snitch.js.map +1 -1
  73. package/src/standalone-addon-build.js.map +1 -1
  74. package/src/sync-dir.js.map +1 -1
  75. package/src/synthesize-template-only-components.js.map +1 -1
  76. package/src/v1-addon.js.map +1 -1
  77. package/src/v1-appboot.js.map +1 -1
  78. package/src/v1-config.js.map +1 -1
  79. package/src/v1-instance-cache.js.map +1 -1
  80. package/LICENSE +0 -21
  81. package/src/compat-adapters/@ember-data/debug.d.ts +0 -6
  82. package/src/compat-adapters/@ember-data/debug.js +0 -22
  83. package/src/compat-adapters/@ember-data/debug.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"empty-package-tree.js","sourceRoot":"","sources":["empty-package-tree.ts"],"names":[],"mappings":";;;;;AACA,sEAAqC;AACrC,uCAAyC;AACzC,+BAA4B;AAE5B,eAAqB,SAAQ,yBAAM;IAGjC,YAAoB,eAAwB;QAC1C,KAAK,CAAC,EAAE,EAAE;YACR,UAAU,EAAE,oBAAoB;YAChC,gBAAgB,EAAE,IAAI;YACtB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;QALe,oBAAe,GAAf,eAAe,CAAS;QAFpC,UAAK,GAAG,KAAK,CAAC;IAQtB,CAAC;IACD,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,IAAA,wBAAa,EAAC,IAAA,WAAI,EAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,EAAE;gBACnD,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;gBAC/B,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,OAAO;gBACrC,IAAI,EAAE,sIAAsI;aAC7I,CAAC,CAAC;SACJ;IACH,CAAC;CACF;AAnBD,4BAmBC","sourcesContent":["import type { Package } from '@embroider/core';\nimport Plugin from 'broccoli-plugin';\nimport { writeJSONSync } from 'fs-extra';\nimport { join } from 'path';\n\nexport default class extends Plugin {\n private built = false;\n\n constructor(private originalPackage: Package) {\n super([], {\n annotation: 'empty-package-tree',\n persistentOutput: true,\n needsCache: false,\n });\n }\n build() {\n if (!this.built) {\n writeJSONSync(join(this.outputPath, 'package.json'), {\n name: this.originalPackage.name,\n version: this.originalPackage.version,\n '//': 'This empty package was created by embroider. See https://github.com/embroider-build/embroider/blob/main/docs/empty-package-output.md',\n });\n }\n }\n}\n"]}
1
+ {"version":3,"file":"empty-package-tree.js","sourceRoot":"","sources":["empty-package-tree.ts"],"names":[],"mappings":";;;;;AACA,sEAAqC;AACrC,uCAAyC;AACzC,+BAA4B;AAE5B,eAAqB,SAAQ,yBAAM;IAGjC,YAAoB,eAAwB;QAC1C,KAAK,CAAC,EAAE,EAAE;YACR,UAAU,EAAE,oBAAoB;YAChC,gBAAgB,EAAE,IAAI;YACtB,UAAU,EAAE,KAAK;SAClB,CAAC,CAAC;QALe,oBAAe,GAAf,eAAe,CAAS;QAFpC,UAAK,GAAG,KAAK,CAAC;IAQtB,CAAC;IACD,KAAK;QACH,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,IAAA,wBAAa,EAAC,IAAA,WAAI,EAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,EAAE;gBACnD,IAAI,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI;gBAC/B,OAAO,EAAE,IAAI,CAAC,eAAe,CAAC,OAAO;gBACrC,IAAI,EAAE,sIAAsI;aAC7I,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF;AAnBD,4BAmBC","sourcesContent":["import type { Package } from '@embroider/core';\nimport Plugin from 'broccoli-plugin';\nimport { writeJSONSync } from 'fs-extra';\nimport { join } from 'path';\n\nexport default class extends Plugin {\n private built = false;\n\n constructor(private originalPackage: Package) {\n super([], {\n annotation: 'empty-package-tree',\n persistentOutput: true,\n needsCache: false,\n });\n }\n build() {\n if (!this.built) {\n writeJSONSync(join(this.outputPath, 'package.json'), {\n name: this.originalPackage.name,\n version: this.originalPackage.version,\n '//': 'This empty package was created by embroider. See https://github.com/embroider-build/embroider/blob/main/docs/empty-package-output.md',\n });\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"get-real-addon.js","sourceRoot":"","sources":["get-real-addon.ts"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,2EAA2E;AAC3E,wDAAwD;;AAExD,IAAI,sBAA2B,CAAC;AAEhC,IAAI;IACF,iEAAiE;IACjE,MAAM,oBAAoB,GAAG,OAAO,CAAC,6DAA6D,CAAC,CAAC;IAEpG,IAAI,oBAAoB,EAAE;QACxB,sBAAsB,GAAG,oBAAoB,CAAC,eAAe,CAAC;KAC/D;CACF;AAAC,OAAO,CAAC,EAAE;IACV,uEAAuE;IACvE,4EAA4E;IAC5E,+BAA+B;IAC/B,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,EAAE;QACvC,MAAM,CAAC,CAAC;KACT;CACF;AAED;;;;GAIG;AACH,SAAwB,YAAY,CAAC,eAAoB;IACvD,OAAO,CAAC,sBAAsB,IAAI,eAAe,CAAC,sBAAsB,CAAC,CAAC,IAAI,eAAe,CAAC;AAChG,CAAC;AAFD,+BAEC","sourcesContent":["// As of ember-cli@3.28, addon instances _may_ be proxied. This can become a\n// problem when patching (setting/restoring) methods on the addon instance or\n// comparing with the addon `__proto__`. The purpose of this util method is to\n// correctly return the _real_ (original) addon instance and not the proxy.\n// @see https://github.com/ember-cli/ember-cli/pull/9487\n\nlet TARGET_INSTANCE_SYMBOL: any;\n\ntry {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const targetInstanceModule = require('ember-cli/lib/models/per-bundle-addon-cache/target-instance');\n\n if (targetInstanceModule) {\n TARGET_INSTANCE_SYMBOL = targetInstanceModule.TARGET_INSTANCE;\n }\n} catch (e) {\n // we only want to handle the error when this module isn't found; i.e.,\n // when a consumer of `ember-engines` is using an old version of `ember-cli`\n // (less than `ember-cli` 3.28)\n if (!e || e.code !== 'MODULE_NOT_FOUND') {\n throw e;\n }\n}\n\n/**\n * Given an addon instance, gets the _real_ addon instance\n * @param maybeProxyAddon - the addon instance, which may be a proxy\n * @returns the _real_ (not proxied) addon instance\n */\nexport default function getRealAddon(maybeProxyAddon: any): any {\n return (TARGET_INSTANCE_SYMBOL && maybeProxyAddon[TARGET_INSTANCE_SYMBOL]) || maybeProxyAddon;\n}\n"]}
1
+ {"version":3,"file":"get-real-addon.js","sourceRoot":"","sources":["get-real-addon.ts"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,2EAA2E;AAC3E,wDAAwD;;AAExD,IAAI,sBAA2B,CAAC;AAEhC,IAAI,CAAC;IACH,iEAAiE;IACjE,MAAM,oBAAoB,GAAG,OAAO,CAAC,6DAA6D,CAAC,CAAC;IAEpG,IAAI,oBAAoB,EAAE,CAAC;QACzB,sBAAsB,GAAG,oBAAoB,CAAC,eAAe,CAAC;IAChE,CAAC;AACH,CAAC;AAAC,OAAO,CAAC,EAAE,CAAC;IACX,uEAAuE;IACvE,4EAA4E;IAC5E,+BAA+B;IAC/B,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,kBAAkB,EAAE,CAAC;QACxC,MAAM,CAAC,CAAC;IACV,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,SAAwB,YAAY,CAAC,eAAoB;IACvD,OAAO,CAAC,sBAAsB,IAAI,eAAe,CAAC,sBAAsB,CAAC,CAAC,IAAI,eAAe,CAAC;AAChG,CAAC;AAFD,+BAEC","sourcesContent":["// As of ember-cli@3.28, addon instances _may_ be proxied. This can become a\n// problem when patching (setting/restoring) methods on the addon instance or\n// comparing with the addon `__proto__`. The purpose of this util method is to\n// correctly return the _real_ (original) addon instance and not the proxy.\n// @see https://github.com/ember-cli/ember-cli/pull/9487\n\nlet TARGET_INSTANCE_SYMBOL: any;\n\ntry {\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const targetInstanceModule = require('ember-cli/lib/models/per-bundle-addon-cache/target-instance');\n\n if (targetInstanceModule) {\n TARGET_INSTANCE_SYMBOL = targetInstanceModule.TARGET_INSTANCE;\n }\n} catch (e) {\n // we only want to handle the error when this module isn't found; i.e.,\n // when a consumer of `ember-engines` is using an old version of `ember-cli`\n // (less than `ember-cli` 3.28)\n if (!e || e.code !== 'MODULE_NOT_FOUND') {\n throw e;\n }\n}\n\n/**\n * Given an addon instance, gets the _real_ addon instance\n * @param maybeProxyAddon - the addon instance, which may be a proxy\n * @returns the _real_ (not proxied) addon instance\n */\nexport default function getRealAddon(maybeProxyAddon: any): any {\n return (TARGET_INSTANCE_SYMBOL && maybeProxyAddon[TARGET_INSTANCE_SYMBOL]) || maybeProxyAddon;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"hbs-to-js-broccoli-plugin.js","sourceRoot":"","sources":["hbs-to-js-broccoli-plugin.ts"],"names":[],"mappings":";;;;;AACA,4FAAgD;AAChD,0CAA0C;AAC1C,+BAA4B;AAE5B,MAAqB,mBAAoB,SAAQ,oCAAM;IACrD,YAAY,SAAe;QACzB,KAAK,CAAC,SAAS,EAAE;YACf,IAAI,EAAE,mCAAmC;YACzC,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,YAAoB,EAAE,KAA+C;QACnF,IAAI,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE;YACzC,OAAO,IAAI,CAAC;SACb;QACD,KAAK,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE;YACrC,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,EAAE;gBACrD,2EAA2E;gBAC3E,2EAA2E;gBAC3E,0BAA0B;gBAC1B,OAAO,YAAY,GAAG,KAAK,CAAC;aAC7B;SACF;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,MAAc,EAAE,YAAoB;QAChD,OAAO,IAAA,cAAO,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO;QACL,OAAO,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AA9BD,sCA8BC","sourcesContent":["import type { Node } from 'broccoli-node-api';\nimport Filter from 'broccoli-persistent-filter';\nimport { hbsToJS } from '@embroider/core';\nimport { join } from 'path';\n\nexport default class TemplateCompileTree extends Filter {\n constructor(inputTree: Node) {\n super(inputTree, {\n name: `embroider-template-compile-stage1`,\n persist: true,\n extensions: ['hbs', 'handlebars'],\n });\n }\n\n getDestFilePath(relativePath: string, entry: Parameters<Filter['getDestFilePath']>[1]) {\n if (this.isDirectory(relativePath, entry)) {\n return null;\n }\n for (let ext of ['hbs', 'handlebars']) {\n if (relativePath.slice(-ext.length - 1) === '.' + ext) {\n // we deliberately don't chop off the .hbs before appending .js, because if\n // the user has both .js` and .hbs` side-by-side we don't want our new file\n // to collide with theirs.\n return relativePath + '.js';\n }\n }\n return null;\n }\n\n processString(source: string, relativePath: string) {\n return hbsToJS(source, { filename: relativePath });\n }\n baseDir() {\n return join(__dirname, '..');\n }\n}\n"]}
1
+ {"version":3,"file":"hbs-to-js-broccoli-plugin.js","sourceRoot":"","sources":["hbs-to-js-broccoli-plugin.ts"],"names":[],"mappings":";;;;;AACA,4FAAgD;AAChD,0CAA0C;AAC1C,+BAA4B;AAE5B,MAAqB,mBAAoB,SAAQ,oCAAM;IACrD,YAAY,SAAe;QACzB,KAAK,CAAC,SAAS,EAAE;YACf,IAAI,EAAE,mCAAmC;YACzC,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC;SAClC,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,YAAoB,EAAE,KAA+C;QACnF,IAAI,IAAI,CAAC,WAAW,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC;YAC1C,OAAO,IAAI,CAAC;QACd,CAAC;QACD,KAAK,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,YAAY,CAAC,EAAE,CAAC;YACtC,IAAI,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,GAAG,GAAG,GAAG,EAAE,CAAC;gBACtD,2EAA2E;gBAC3E,2EAA2E;gBAC3E,0BAA0B;gBAC1B,OAAO,YAAY,GAAG,KAAK,CAAC;YAC9B,CAAC;QACH,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,MAAc,EAAE,YAAoB;QAChD,OAAO,IAAA,cAAO,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO;QACL,OAAO,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC/B,CAAC;CACF;AA9BD,sCA8BC","sourcesContent":["import type { Node } from 'broccoli-node-api';\nimport Filter from 'broccoli-persistent-filter';\nimport { hbsToJS } from '@embroider/core';\nimport { join } from 'path';\n\nexport default class TemplateCompileTree extends Filter {\n constructor(inputTree: Node) {\n super(inputTree, {\n name: `embroider-template-compile-stage1`,\n persist: true,\n extensions: ['hbs', 'handlebars'],\n });\n }\n\n getDestFilePath(relativePath: string, entry: Parameters<Filter['getDestFilePath']>[1]) {\n if (this.isDirectory(relativePath, entry)) {\n return null;\n }\n for (let ext of ['hbs', 'handlebars']) {\n if (relativePath.slice(-ext.length - 1) === '.' + ext) {\n // we deliberately don't chop off the .hbs before appending .js, because if\n // the user has both .js` and .hbs` side-by-side we don't want our new file\n // to collide with theirs.\n return relativePath + '.js';\n }\n }\n return null;\n }\n\n processString(source: string, relativePath: string) {\n return hbsToJS(source, { filename: relativePath });\n }\n baseDir() {\n return join(__dirname, '..');\n }\n}\n"]}
@@ -0,0 +1,13 @@
1
+ import type { Finding } from './audit';
2
+ import { type Module } from './module-visitor';
3
+ export interface HTTPAuditOptions {
4
+ appURL: string;
5
+ startingFrom: string[];
6
+ fetch?: typeof fetch;
7
+ }
8
+ export declare function httpAudit(options: HTTPAuditOptions): Promise<{
9
+ modules: {
10
+ [file: string]: Module;
11
+ };
12
+ findings: Finding[];
13
+ }>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.httpAudit = void 0;
4
+ const babel_visitor_1 = require("./audit/babel-visitor");
5
+ const module_visitor_1 = require("./module-visitor");
6
+ async function httpAudit(options) {
7
+ let findings = [];
8
+ async function resolveId(specifier, fromFile) {
9
+ return new URL(specifier, fromFile).href;
10
+ }
11
+ async function load(id) {
12
+ var _a;
13
+ let response = await ((_a = options.fetch) !== null && _a !== void 0 ? _a : globalThis.fetch)(id);
14
+ let content = await response.text();
15
+ let type;
16
+ if (response.status !== 200) {
17
+ throw new Error(`oops status code ${response.status} - ${response.statusText} for ${id}: ${content}`);
18
+ }
19
+ switch (response.headers.get('content-type')) {
20
+ case 'text/javascript':
21
+ type = 'javascript';
22
+ break;
23
+ case 'text/html':
24
+ type = 'html';
25
+ break;
26
+ default:
27
+ throw new Error(`oops content type ${response.headers.get('content-type')} for ${id}`);
28
+ }
29
+ return { content, type };
30
+ }
31
+ let modules = await (0, module_visitor_1.visitModules)({
32
+ base: options.appURL,
33
+ entrypoints: options.startingFrom.map(s => new URL(s, options.appURL).href),
34
+ babelConfig: { ast: true },
35
+ frames: new babel_visitor_1.CodeFrameStorage(),
36
+ findings,
37
+ resolveId,
38
+ load,
39
+ });
40
+ return {
41
+ modules,
42
+ findings,
43
+ };
44
+ }
45
+ exports.httpAudit = httpAudit;
46
+ //# sourceMappingURL=http-audit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http-audit.js","sourceRoot":"","sources":["http-audit.ts"],"names":[],"mappings":";;;AACA,yDAAyD;AACzD,qDAA+E;AAQxE,KAAK,UAAU,SAAS,CAC7B,OAAyB;IAEzB,IAAI,QAAQ,GAAc,EAAE,CAAC;IAE7B,KAAK,UAAU,SAAS,CAAC,SAAiB,EAAE,QAAgB;QAC1D,OAAO,IAAI,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC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AAO;QACL,OAAO;QACP,QAAQ;KACT,CAAC;AACJ,CAAC;AA3CD,8BA2CC","sourcesContent":["import type { Finding } from './audit';\nimport { CodeFrameStorage } from './audit/babel-visitor';\nimport { type Module, visitModules, type ContentType } from './module-visitor';\n\nexport interface HTTPAuditOptions {\n appURL: string;\n startingFrom: string[];\n fetch?: typeof fetch;\n}\n\nexport async function httpAudit(\n options: HTTPAuditOptions\n): Promise<{ modules: { [file: string]: Module }; findings: Finding[] }> {\n let findings: Finding[] = [];\n\n async function resolveId(specifier: string, fromFile: string): Promise<string | undefined> {\n return new URL(specifier, fromFile).href;\n }\n\n async function load(id: string): Promise<{ content: string | Buffer; type: ContentType }> {\n let response = await (options.fetch ?? globalThis.fetch)(id);\n let content = await response.text();\n let type: ContentType;\n if (response.status !== 200) {\n throw new Error(`oops status code ${response.status} - ${response.statusText} for ${id}: ${content}`);\n }\n switch (response.headers.get('content-type')) {\n case 'text/javascript':\n type = 'javascript';\n break;\n case 'text/html':\n type = 'html';\n break;\n default:\n throw new Error(`oops content type ${response.headers.get('content-type')} for ${id}`);\n }\n return { content, type };\n }\n\n let modules = await visitModules({\n base: options.appURL,\n entrypoints: options.startingFrom.map(s => new URL(s, options.appURL).href),\n babelConfig: { ast: true },\n frames: new CodeFrameStorage(),\n findings,\n resolveId,\n load,\n });\n\n return {\n modules,\n findings,\n };\n}\n"]}
package/src/index.d.ts CHANGED
@@ -2,5 +2,5 @@ export { default as App } from './compat-app';
2
2
  export { default as Addons } from './compat-addons';
3
3
  export { default as Options, recommendedOptions } from './options';
4
4
  export { default as V1Addon } from './v1-addon';
5
- export { default as compatBuild, PipelineOptions } from './default-pipeline';
5
+ export { default as compatBuild, prebuild, PipelineOptions } from './default-pipeline';
6
6
  export { PackageRules, ModuleRules } from './dependency-rules';
package/src/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.compatBuild = exports.V1Addon = exports.recommendedOptions = exports.Addons = exports.App = void 0;
6
+ exports.prebuild = exports.compatBuild = exports.V1Addon = exports.recommendedOptions = exports.Addons = exports.App = void 0;
7
7
  var compat_app_1 = require("./compat-app");
8
8
  Object.defineProperty(exports, "App", { enumerable: true, get: function () { return __importDefault(compat_app_1).default; } });
9
9
  var compat_addons_1 = require("./compat-addons");
@@ -14,4 +14,5 @@ var v1_addon_1 = require("./v1-addon");
14
14
  Object.defineProperty(exports, "V1Addon", { enumerable: true, get: function () { return __importDefault(v1_addon_1).default; } });
15
15
  var default_pipeline_1 = require("./default-pipeline");
16
16
  Object.defineProperty(exports, "compatBuild", { enumerable: true, get: function () { return __importDefault(default_pipeline_1).default; } });
17
+ Object.defineProperty(exports, "prebuild", { enumerable: true, get: function () { return default_pipeline_1.prebuild; } });
17
18
  //# sourceMappingURL=index.js.map
package/src/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAA8C;AAArC,kHAAA,OAAO,OAAO;AACvB,iDAAoD;AAA3C,wHAAA,OAAO,OAAU;AAC1B,qCAAmE;AAAtC,6GAAA,kBAAkB,OAAA;AAC/C,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,uDAA6E;AAApE,gIAAA,OAAO,OAAe","sourcesContent":["export { default as App } from './compat-app';\nexport { default as Addons } from './compat-addons';\nexport { default as Options, recommendedOptions } from './options';\nexport { default as V1Addon } from './v1-addon';\nexport { default as compatBuild, PipelineOptions } from './default-pipeline';\nexport { PackageRules, ModuleRules } from './dependency-rules';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA,2CAA8C;AAArC,kHAAA,OAAO,OAAO;AACvB,iDAAoD;AAA3C,wHAAA,OAAO,OAAU;AAC1B,qCAAmE;AAAtC,6GAAA,kBAAkB,OAAA;AAC/C,uCAAgD;AAAvC,oHAAA,OAAO,OAAW;AAC3B,uDAAuF;AAA9E,gIAAA,OAAO,OAAe;AAAE,4GAAA,QAAQ,OAAA","sourcesContent":["export { default as App } from './compat-app';\nexport { default as Addons } from './compat-addons';\nexport { default as Options, recommendedOptions } from './options';\nexport { default as V1Addon } from './v1-addon';\nexport { default as compatBuild, prebuild, PipelineOptions } from './default-pipeline';\nexport { PackageRules, ModuleRules } from './dependency-rules';\n"]}
package/src/merges.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"merges.js","sourceRoot":"","sources":["merges.ts"],"names":[],"mappings":";;;;;;AAAA,iEAAyC;AACzC,uDAA+B;AAE/B,SAAgB,eAAe,CAAC,IAAY,EAAE,GAAG,IAAc;IAC7D,OAAO,IAAA,mBAAS,EAAC,IAAI,EAAE,GAAG,IAAI,EAAE,YAAY,CAAC,CAAC;AAChD,CAAC;AAFD,0CAEC;AAED,SAAgB,aAAa,CAAC,IAAY,EAAE,GAAG,IAAc;IAC3D,OAAO,IAAA,mBAAS,EAAC,IAAI,EAAE,GAAG,IAAI,EAAE,gBAAgB,CAAC,CAAC;AACpD,CAAC;AAFD,sCAEC;AAED,SAAS,YAAY,CAAC,QAAa,EAAE,QAAa;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,OAAO,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;KAClC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAa,EAAE,QAAa;IACpD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC3B,OAAO,IAAA,cAAI,EAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;KACxC;AACH,CAAC","sourcesContent":["import mergeWith from 'lodash/mergeWith';\nimport uniq from 'lodash/uniq';\n\nexport function mergeWithAppend(dest: object, ...srcs: object[]) {\n return mergeWith(dest, ...srcs, appendArrays);\n}\n\nexport function mergeWithUniq(dest: object, ...srcs: object[]) {\n return mergeWith(dest, ...srcs, appendArraysUniq);\n}\n\nfunction appendArrays(objValue: any, srcValue: any) {\n if (Array.isArray(objValue)) {\n return objValue.concat(srcValue);\n }\n}\n\nfunction appendArraysUniq(objValue: any, srcValue: any) {\n if (Array.isArray(objValue)) {\n return uniq(objValue.concat(srcValue));\n }\n}\n"]}
1
+ {"version":3,"file":"merges.js","sourceRoot":"","sources":["merges.ts"],"names":[],"mappings":";;;;;;AAAA,iEAAyC;AACzC,uDAA+B;AAE/B,SAAgB,eAAe,CAAC,IAAY,EAAE,GAAG,IAAc;IAC7D,OAAO,IAAA,mBAAS,EAAC,IAAI,EAAE,GAAG,IAAI,EAAE,YAAY,CAAC,CAAC;AAChD,CAAC;AAFD,0CAEC;AAED,SAAgB,aAAa,CAAC,IAAY,EAAE,GAAG,IAAc;IAC3D,OAAO,IAAA,mBAAS,EAAC,IAAI,EAAE,GAAG,IAAI,EAAE,gBAAgB,CAAC,CAAC;AACpD,CAAC;AAFD,sCAEC;AAED,SAAS,YAAY,CAAC,QAAa,EAAE,QAAa;IAChD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACnC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAa,EAAE,QAAa;IACpD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,OAAO,IAAA,cAAI,EAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IACzC,CAAC;AACH,CAAC","sourcesContent":["import mergeWith from 'lodash/mergeWith';\nimport uniq from 'lodash/uniq';\n\nexport function mergeWithAppend(dest: object, ...srcs: object[]) {\n return mergeWith(dest, ...srcs, appendArrays);\n}\n\nexport function mergeWithUniq(dest: object, ...srcs: object[]) {\n return mergeWith(dest, ...srcs, appendArraysUniq);\n}\n\nfunction appendArrays(objValue: any, srcValue: any) {\n if (Array.isArray(objValue)) {\n return objValue.concat(srcValue);\n }\n}\n\nfunction appendArraysUniq(objValue: any, srcValue: any) {\n if (Array.isArray(objValue)) {\n return uniq(objValue.concat(srcValue));\n }\n}\n"]}
@@ -0,0 +1,53 @@
1
+ /// <reference types="node" />
2
+ import { type CodeFrameStorage, type NamespaceMarker } from './audit/babel-visitor';
3
+ import type { Finding } from './audit';
4
+ import type { TransformOptions } from '@babel/core';
5
+ export type Module = CompleteModule | ParsedModule | UnparseableModule;
6
+ export interface UnparseableModule {
7
+ type: 'unparseable';
8
+ appRelativePath: string;
9
+ consumedFrom: (string | RootMarker)[];
10
+ }
11
+ export interface ParsedModule extends Omit<UnparseableModule, 'type'> {
12
+ type: 'parsed';
13
+ imports: Import[];
14
+ resolutions: {
15
+ [source: string]: string | null;
16
+ };
17
+ content: string;
18
+ isCJS: boolean;
19
+ isAMD: boolean;
20
+ }
21
+ export interface CompleteModule extends Omit<ParsedModule, 'type'> {
22
+ type: 'complete';
23
+ exports: string[];
24
+ }
25
+ export interface Import {
26
+ source: string;
27
+ specifiers: {
28
+ name: string | NamespaceMarker;
29
+ local: string | null;
30
+ codeFrameIndex: number | undefined;
31
+ }[];
32
+ codeFrameIndex: number | undefined;
33
+ }
34
+ interface VisitorParams {
35
+ base: string;
36
+ resolveId: (specifier: string, fromFile: string) => Promise<string | undefined>;
37
+ load: (id: string) => Promise<{
38
+ content: string | Buffer;
39
+ type: ContentType;
40
+ } | undefined>;
41
+ entrypoints: string[];
42
+ debug?: boolean;
43
+ findings: Finding[];
44
+ frames: CodeFrameStorage;
45
+ babelConfig: TransformOptions;
46
+ }
47
+ export declare function visitModules(params: VisitorParams): Promise<Record<string, Module>>;
48
+ export type ContentType = 'javascript' | 'html';
49
+ export interface RootMarker {
50
+ isRoot: true;
51
+ }
52
+ export declare function isRootMarker(value: string | RootMarker | undefined): value is RootMarker;
53
+ export {};
@@ -0,0 +1,286 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isRootMarker = exports.visitModules = void 0;
7
+ const core_1 = require("@embroider/core");
8
+ const babel_visitor_1 = require("./audit/babel-visitor");
9
+ const fromPairs_1 = __importDefault(require("lodash/fromPairs"));
10
+ const assert_never_1 = __importDefault(require("assert-never"));
11
+ const jsdom_1 = require("jsdom");
12
+ function isResolved(module) {
13
+ return Boolean((module === null || module === void 0 ? void 0 : module.parsed) && module.resolved);
14
+ }
15
+ function isLinked(module) {
16
+ return Boolean((module === null || module === void 0 ? void 0 : module.parsed) && module.resolved && module.linked);
17
+ }
18
+ async function visitModules(params) {
19
+ let visitor = new ModuleVisitor(params);
20
+ return await visitor.run();
21
+ }
22
+ exports.visitModules = visitModules;
23
+ class ModuleVisitor {
24
+ constructor(params) {
25
+ this.params = params;
26
+ this.modules = new Map();
27
+ this.moduleQueue = new Set();
28
+ this.base = params.base;
29
+ this.debugEnabled = Boolean(params.debug);
30
+ this.resolveId = params.resolveId;
31
+ this.load = params.load;
32
+ this.entrypoints = params.entrypoints;
33
+ }
34
+ async run() {
35
+ for (let entry of this.entrypoints) {
36
+ this.scheduleVisit(entry, { isRoot: true });
37
+ }
38
+ await this.drainQueue();
39
+ this.linkModules();
40
+ return this.buildResults();
41
+ }
42
+ async drainQueue() {
43
+ while (this.moduleQueue.size > 0) {
44
+ let id = this.moduleQueue.values().next().value;
45
+ this.moduleQueue.delete(id);
46
+ this.debug('visit', id);
47
+ let loaded = await this.load(id);
48
+ if (Array.isArray(loaded)) {
49
+ for (let finding of loaded) {
50
+ this.params.findings.push(finding);
51
+ }
52
+ continue;
53
+ }
54
+ // if the load hook returned undefined we need to just skip it
55
+ if (loaded === undefined) {
56
+ continue;
57
+ }
58
+ let { content, type } = loaded;
59
+ let visitor = this.visitorFor(type);
60
+ // cast is safe because the only way to get into the queue is to go
61
+ // through scheduleVisit, and scheduleVisit creates the entry in
62
+ // this.modules.
63
+ let module = this.modules.get(id);
64
+ let visitResult = await visitor.call(this, id, content);
65
+ if (Array.isArray(visitResult)) {
66
+ // the visitor was unable to figure out the ParseFields and returned
67
+ // some number of Findings to us to explain why.
68
+ for (let finding of visitResult) {
69
+ this.params.findings.push(finding);
70
+ }
71
+ }
72
+ else {
73
+ module.parsed = visitResult;
74
+ module.resolved = await this.resolveDeps(visitResult.dependencies, id);
75
+ }
76
+ }
77
+ }
78
+ linkModules() {
79
+ for (let module of this.modules.values()) {
80
+ if (isResolved(module)) {
81
+ this.linkModule(module);
82
+ }
83
+ }
84
+ }
85
+ linkModule(module) {
86
+ let exports = new Set();
87
+ for (let exp of module.parsed.exports) {
88
+ if (typeof exp === 'string') {
89
+ exports.add(exp);
90
+ }
91
+ else {
92
+ let moduleName = module.resolved.get(exp.all);
93
+ if (!isResolutionFailure(moduleName)) {
94
+ let target = this.modules.get(moduleName);
95
+ if (!isLinked(target) && isResolved(target)) {
96
+ this.linkModule(target);
97
+ }
98
+ if (isLinked(target)) {
99
+ for (let innerExp of target.linked.exports) {
100
+ exports.add(innerExp);
101
+ }
102
+ }
103
+ else {
104
+ // our module doesn't successfully enter linked state because it
105
+ // depends on stuff that also couldn't
106
+ return;
107
+ }
108
+ }
109
+ }
110
+ }
111
+ module.linked = {
112
+ exports,
113
+ };
114
+ }
115
+ async resolveDeps(deps, fromFile) {
116
+ let resolved = new Map();
117
+ for (let dep of deps) {
118
+ if (['@embroider/macros'].includes(dep)) {
119
+ // the audit process deliberately removes the @embroider/macros babel
120
+ // plugins, so the imports are still present and should be left alone.
121
+ continue;
122
+ }
123
+ let resolution = await this.resolveId(dep, fromFile);
124
+ if (resolution) {
125
+ resolved.set(dep, resolution);
126
+ this.scheduleVisit(resolution, fromFile);
127
+ continue;
128
+ }
129
+ else {
130
+ resolved.set(dep, { isResolutionFailure: true });
131
+ continue;
132
+ }
133
+ }
134
+ return resolved;
135
+ }
136
+ scheduleVisit(id, parent) {
137
+ let record = this.modules.get(id);
138
+ if (!record) {
139
+ this.debug(`discovered`, id);
140
+ record = {
141
+ consumedFrom: [parent],
142
+ };
143
+ this.modules.set(id, record);
144
+ this.moduleQueue.add(id);
145
+ }
146
+ else {
147
+ record.consumedFrom.push(parent);
148
+ }
149
+ }
150
+ visitorFor(type) {
151
+ switch (type) {
152
+ case 'html':
153
+ return this.visitHTML;
154
+ case 'javascript':
155
+ return this.visitJS;
156
+ default:
157
+ throw (0, assert_never_1.default)(type);
158
+ }
159
+ }
160
+ async visitHTML(_filename, content) {
161
+ let dom = new jsdom_1.JSDOM(content);
162
+ let scripts = dom.window.document.querySelectorAll('script[type="module"]');
163
+ let dependencies = [];
164
+ for (let script of scripts) {
165
+ let src = script.src;
166
+ if (!src) {
167
+ continue;
168
+ }
169
+ if (new URL(src, 'http://example.com:4321').origin !== 'http://example.com:4321') {
170
+ // src was absolute, we don't handle it
171
+ continue;
172
+ }
173
+ dependencies.push(src);
174
+ }
175
+ return {
176
+ imports: [],
177
+ exports: new Set(),
178
+ isCJS: false,
179
+ isAMD: false,
180
+ dependencies,
181
+ transpiledContent: content,
182
+ };
183
+ }
184
+ async visitJS(filename, content) {
185
+ let rawSource = content.toString('utf8');
186
+ try {
187
+ let result = (0, babel_visitor_1.auditJS)(rawSource, filename, this.params.babelConfig, this.params.frames);
188
+ for (let problem of result.problems) {
189
+ this.params.findings.push({
190
+ filename,
191
+ message: problem.message,
192
+ detail: problem.detail,
193
+ codeFrame: this.params.frames.render(problem.codeFrameIndex),
194
+ });
195
+ }
196
+ return {
197
+ exports: result.exports,
198
+ imports: result.imports,
199
+ isCJS: result.isCJS,
200
+ isAMD: result.isAMD,
201
+ dependencies: result.imports.map(i => i.source),
202
+ transpiledContent: result.transpiledContent,
203
+ };
204
+ }
205
+ catch (err) {
206
+ if (['BABEL_PARSE_ERROR', 'BABEL_TRANSFORM_ERROR'].includes(err.code)) {
207
+ return [
208
+ {
209
+ filename,
210
+ message: `failed to parse`,
211
+ detail: err.toString().replace(filename, (0, core_1.explicitRelative)(this.base, filename)),
212
+ },
213
+ ];
214
+ }
215
+ else {
216
+ throw err;
217
+ }
218
+ }
219
+ }
220
+ debug(message, ...args) {
221
+ if (this.debugEnabled) {
222
+ console.log(message, ...args);
223
+ }
224
+ }
225
+ toPublicModule(filename, module) {
226
+ let result = {
227
+ type: 'unparseable',
228
+ appRelativePath: (0, core_1.explicitRelative)(this.base, filename),
229
+ consumedFrom: module.consumedFrom.map(entry => {
230
+ if (isRootMarker(entry)) {
231
+ return entry;
232
+ }
233
+ else {
234
+ return (0, core_1.explicitRelative)(this.base, entry);
235
+ }
236
+ }),
237
+ };
238
+ if (!module.parsed || !module.resolved) {
239
+ return result;
240
+ }
241
+ let parsedResult = {
242
+ ...result,
243
+ type: 'parsed',
244
+ resolutions: (0, fromPairs_1.default)([...module.resolved].map(([source, target]) => [
245
+ source,
246
+ isResolutionFailure(target) ? null : (0, core_1.explicitRelative)(this.base, target),
247
+ ])),
248
+ imports: module.parsed.imports.map(i => ({
249
+ source: i.source,
250
+ specifiers: i.specifiers.map(s => ({
251
+ name: s.name,
252
+ local: s.local,
253
+ codeFrameIndex: s.codeFrameIndex,
254
+ })),
255
+ codeFrameIndex: i.codeFrameIndex,
256
+ })),
257
+ content: module.parsed.transpiledContent.toString(),
258
+ isAMD: Boolean(module.parsed.isAMD),
259
+ isCJS: Boolean(module.parsed.isCJS),
260
+ };
261
+ if (!module.linked) {
262
+ return parsedResult;
263
+ }
264
+ return {
265
+ ...parsedResult,
266
+ type: 'complete',
267
+ exports: [...module.linked.exports],
268
+ };
269
+ }
270
+ buildResults() {
271
+ let publicModules = {};
272
+ for (let [filename, module] of this.modules) {
273
+ let publicModule = this.toPublicModule(filename, module);
274
+ publicModules[(0, core_1.explicitRelative)(this.base, filename)] = publicModule;
275
+ }
276
+ return publicModules;
277
+ }
278
+ }
279
+ function isRootMarker(value) {
280
+ return Boolean(value && typeof value !== 'string' && value.isRoot);
281
+ }
282
+ exports.isRootMarker = isRootMarker;
283
+ function isResolutionFailure(result) {
284
+ return typeof result === 'object' && 'isResolutionFailure' in result;
285
+ }
286
+ //# sourceMappingURL=module-visitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"module-visitor.js","sourceRoot":"","sources":["module-visitor.ts"],"names":[],"mappings":";;;;;;AAAA,0CAAmD;AACnD,yDAM+B;AAC/B,iEAAyC;AACzC,gEAAuC;AACvC,iCAA8B;AAsD9B,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;AAwBM,KAAK,UAAU,YAAY,CAAC,MAAqB;IACtD,IAAI,OAAO,GAAG,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;IACxC,OAAO,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC;AAC7B,CAAC;AAHD,oCAGC;AAID,MAAM,aAAa;IAUjB,YAAoB,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;QATjC,YAAO,GAAgC,IAAI,GAAG,EAAE,CAAC;QAEjD,gBAAW,GAAG,IAAI,GAAG,EAAU,CAAC;QAQtC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;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CAAC,MAAM,CAAC,OAAO,CAAC;SACpC,CAAC;IACJ,CAAC;IAEO,YAAY;QAClB,IAAI,aAAa,GAA2B,EAAE,CAAC;QAC/C,KAAK,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC5C,IAAI,YAAY,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACzD,aAAa,CAAC,IAAA,uBAAgB,EAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,GAAG,YAAY,CAAC;QACtE,CAAC;QACD,OAAO,aAAa,CAAC;IACvB,CAAC;CACF;AAMD,SAAgB,YAAY,CAAC,KAAsC;IACjE,OAAO,OAAO,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;AACrE,CAAC;AAFD,oCAEC;AAMD,SAAS,mBAAmB,CAAC,MAA8C;IACzE,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,qBAAqB,IAAI,MAAM,CAAC;AACvE,CAAC","sourcesContent":["import { explicitRelative } from '@embroider/core';\nimport {\n type CodeFrameStorage,\n auditJS,\n type ExportAll,\n type InternalImport,\n type NamespaceMarker,\n} from './audit/babel-visitor';\nimport fromPairs from 'lodash/fromPairs';\nimport assertNever from 'assert-never';\nimport { JSDOM } from 'jsdom';\n\nimport type { Finding } from './audit';\nimport type { TransformOptions } from '@babel/core';\n\nexport type Module = CompleteModule | ParsedModule | UnparseableModule;\n\nexport interface UnparseableModule {\n type: 'unparseable';\n appRelativePath: string;\n consumedFrom: (string | RootMarker)[];\n}\n\nexport interface ParsedModule extends Omit<UnparseableModule, 'type'> {\n type: 'parsed';\n imports: Import[];\n resolutions: { [source: string]: string | null };\n content: string;\n isCJS: boolean;\n isAMD: boolean;\n}\n\nexport interface CompleteModule extends Omit<ParsedModule, 'type'> {\n type: 'complete';\n exports: string[];\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 codeFrameIndex: number | undefined;\n }[];\n codeFrameIndex: number | undefined;\n}\n\ninterface VisitorParams {\n base: string;\n resolveId: (specifier: string, fromFile: string) => Promise<string | undefined>;\n load: (id: string) => Promise<{ content: string | Buffer; type: ContentType } | undefined>;\n entrypoints: string[];\n debug?: boolean;\n\n findings: Finding[];\n frames: CodeFrameStorage;\n babelConfig: TransformOptions;\n}\n\nexport async function visitModules(params: VisitorParams): Promise<Record<string, Module>> {\n let visitor = new ModuleVisitor(params);\n return await visitor.run();\n}\n\nexport type ContentType = 'javascript' | 'html';\n\nclass ModuleVisitor {\n private modules: Map<string, InternalModule> = new Map();\n\n private moduleQueue = new Set<string>();\n private base: string;\n private debugEnabled: boolean;\n private resolveId: (specifier: string, fromFile: string) => Promise<string | undefined>;\n private load: (id: string) => Promise<{ content: string | Buffer; type: ContentType } | undefined>;\n private entrypoints: string[];\n\n constructor(private params: VisitorParams) {\n this.base = params.base;\n this.debugEnabled = Boolean(params.debug);\n this.resolveId = params.resolveId;\n this.load = params.load;\n this.entrypoints = params.entrypoints;\n }\n\n async run(): Promise<Record<string, Module>> {\n for (let entry of this.entrypoints) {\n this.scheduleVisit(entry, { isRoot: true });\n }\n await this.drainQueue();\n this.linkModules();\n return this.buildResults();\n }\n\n private async drainQueue() {\n while (this.moduleQueue.size > 0) {\n let id = this.moduleQueue.values().next().value as string;\n this.moduleQueue.delete(id);\n this.debug('visit', id);\n let loaded = await this.load(id);\n if (Array.isArray(loaded)) {\n for (let finding of loaded) {\n this.params.findings.push(finding);\n }\n continue;\n }\n // if the load hook returned undefined we need to just skip it\n if (loaded === undefined) {\n continue;\n }\n let { content, type } = loaded;\n\n let visitor = this.visitorFor(type);\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(id)!;\n let visitResult = await visitor.call(this, id, 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.params.findings.push(finding);\n }\n } else {\n module.parsed = visitResult;\n module.resolved = await this.resolveDeps(visitResult.dependencies, id);\n }\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 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 if (['@embroider/macros'].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\n let resolution = await this.resolveId(dep, fromFile);\n if (resolution) {\n resolved.set(dep, resolution);\n this.scheduleVisit(resolution, fromFile);\n continue;\n } else {\n resolved.set(dep, { isResolutionFailure: true as true });\n continue;\n }\n }\n return resolved;\n }\n\n private scheduleVisit(id: string, parent: string | RootMarker) {\n let record = this.modules.get(id);\n if (!record) {\n this.debug(`discovered`, id);\n record = {\n consumedFrom: [parent],\n };\n this.modules.set(id, record);\n this.moduleQueue.add(id);\n } else {\n record.consumedFrom.push(parent);\n }\n }\n\n private visitorFor(\n type: ContentType\n ): (\n this: ModuleVisitor,\n filename: string,\n content: Buffer | string\n ) => Promise<NonNullable<InternalModule['parsed'] | Finding[]>> {\n switch (type) {\n case 'html':\n return this.visitHTML;\n case 'javascript':\n return this.visitJS;\n default:\n throw assertNever(type);\n }\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 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.params.babelConfig, this.params.frames);\n\n for (let problem of result.problems) {\n this.params.findings.push({\n filename,\n message: problem.message,\n detail: problem.detail,\n codeFrame: this.params.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.base, filename)),\n },\n ];\n } else {\n throw err;\n }\n }\n }\n\n private debug(message: string, ...args: any[]) {\n if (this.debugEnabled) {\n console.log(message, ...args);\n }\n }\n\n private toPublicModule(filename: string, module: InternalModule): Module {\n let result: UnparseableModule = {\n type: 'unparseable',\n appRelativePath: explicitRelative(this.base, filename),\n consumedFrom: module.consumedFrom.map(entry => {\n if (isRootMarker(entry)) {\n return entry;\n } else {\n return explicitRelative(this.base, entry);\n }\n }),\n };\n\n if (!module.parsed || !module.resolved) {\n return result;\n }\n\n let parsedResult: ParsedModule = {\n ...result,\n type: 'parsed',\n resolutions: fromPairs(\n [...module.resolved].map(([source, target]) => [\n source,\n isResolutionFailure(target) ? null : explicitRelative(this.base, target),\n ])\n ),\n imports: module.parsed.imports.map(i => ({\n source: i.source,\n specifiers: i.specifiers.map(s => ({\n name: s.name,\n local: s.local,\n codeFrameIndex: s.codeFrameIndex,\n })),\n codeFrameIndex: i.codeFrameIndex,\n })),\n content: module.parsed.transpiledContent.toString(),\n isAMD: Boolean(module.parsed.isAMD),\n isCJS: Boolean(module.parsed.isCJS),\n };\n\n if (!module.linked) {\n return parsedResult;\n }\n\n return {\n ...parsedResult,\n type: 'complete',\n exports: [...module.linked.exports],\n };\n }\n\n private buildResults() {\n let publicModules: Record<string, Module> = {};\n for (let [filename, module] of this.modules) {\n let publicModule = this.toPublicModule(filename, module);\n publicModules[explicitRelative(this.base, filename)] = publicModule;\n }\n return publicModules;\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\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"]}
package/src/options.d.ts CHANGED
@@ -10,6 +10,7 @@ export default interface Options extends CoreOptions {
10
10
  extraPublicTrees?: Node[];
11
11
  packageRules?: PackageRules[];
12
12
  allowUnsafeDynamicComponents?: boolean;
13
+ availableContentForTypes?: string[];
13
14
  }
14
15
  export declare function optionsWithDefaults(options?: Options): Required<Options>;
15
16
  export declare const recommendedOptions: {
package/src/options.js CHANGED
@@ -11,6 +11,7 @@ const defaults = Object.assign((0, core_1.optionsWithDefaults)(), {
11
11
  workspaceDir: null,
12
12
  packageRules: [],
13
13
  allowUnsafeDynamicComponents: false,
14
+ availableContentForTypes: [],
14
15
  });
15
16
  function optionsWithDefaults(options) {
16
17
  return Object.assign({}, defaults, options);
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AAGA,0CAA0E;AAgG1E,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAA,0BAAgB,GAAE,EAAE;IACjD,gBAAgB,EAAE,KAAK;IACvB,2BAA2B,EAAE,KAAK;IAClC,iBAAiB,EAAE,KAAK;IACxB,cAAc,EAAE,IAAI,GAAG,EAAE;IACzB,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,EAAE;IAChB,4BAA4B,EAAE,KAAK;CACpC,CAAC,CAAC;AAEH,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAFD,kDAEC;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,cAAc;AACD,QAAA,kBAAkB,GAAgC,MAAM,CAAC,MAAM,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE,IAAI;QACtB,2BAA2B,EAAE,IAAI;QACjC,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAI;QACrB,gBAAgB,EAAE,IAAI;QACtB,iBAAiB,EAAE,IAAI;QACvB,4BAA4B,EAAE,KAAK;KACpC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { V1AddonConstructor } from './v1-addon';\nimport type { Node } from 'broccoli-node-api';\nimport type { Options as CoreOptions } from '@embroider/core';\nimport { optionsWithDefaults as coreWithDefaults } from '@embroider/core';\nimport type { PackageRules } from './dependency-rules';\n\n// These options control how hard we will try to achieve compatibility with v1\n// addons. The defaults are conservative and try to maximize compatibility, at\n// the cost of slower or bigger builds. As you eliminate sources of legacy\n// behavior you can benefit from the more aggressive modes.\nexport default interface Options extends CoreOptions {\n // Controls whether your addon's \"addon\" trees should be resolved statically\n // at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. In this mode, we force every file into the Ember app,\n // which is the legacy behavior.\n //\n // true: produces smaller builds. The addon files must be imported from\n // somewhere we can statically see during the build. In this mode, your app\n // will only include files that are actually imported from somewhere.\n //\n // Commentary: most v1 addons already work well with this set to true, because\n // they tend to either offer Javascript that users are supposed to directly\n // `import` or components / helpers / services that get directly imported and\n // re-exported by code in App Javascript. The exceptions are addons that do\n // runtime shenanigans with `require` or scoped runtime resolutions.\n //\n // To workaround an addon that is preventing you from enabling this flag, you\n // can use addonDependencyRules.\n staticAddonTrees?: boolean;\n\n // Controls whether your addon's \"addonTestSupport\" trees should be resolved\n // statically at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. All test support files will be forced into your Ember\n // app, which is the legacy behavior.\n //\n // true: produces smaller builds. Only files that are explicitly imported\n // will end up in your app.\n //\n // Commentary: this is analogous to staticAddonTrees and the same guidelines\n // apply.\n staticAddonTestSupportTrees?: boolean;\n\n // when true, we will load ember-source as ES modules. This means unused parts\n // of ember-source won't be included. But it also means that addons using old\n // APIs to try to `require()` things from Ember -- particularly from within\n // vendor.js -- cannot do that anymore.\n //\n // When false (the default) we load ember-source the traditional way, which is\n // that a big ol' script gets smooshed into vendor.js, and none of ember's\n // public module API actually exists as modules at build time.\n staticEmberSource?: boolean;\n\n // Allows you to override how specific addons will build. Like:\n //\n // import V1Addon from '@embroider/compat'; let compatAdapters = new Map();\n // compatAdapters.set('some-addon', class extends V1Addon {// do stuff here:\n // see examples in ./compat-adapters\n // });\n //\n // This should be understood as a temporary way to keep yourself from getting\n // stuck, not an alternative to actually fixing upstream. For the most part,\n // the real solution will be converting the addon in question to natively\n // publish as v2.\n //\n // We ship with some default compatAdapters to fix otherwise incompatible\n // behaviors in popular addons. You can override the default adapters by\n // setting your own value here (including null to completely disable it).\n compatAdapters?: Map<string, V1AddonConstructor | null>;\n\n // optional list of additional broccoli trees that should be incorporated into\n // the final build. This exists because the classic `app.toTree()` method\n // accepts an optional tree argument that has the same purpose.\n extraPublicTrees?: Node[];\n\n // Allows you to tell Embroider about otherwise dynamic dependencies within\n // your app and addons that it can't figure out on its own. These are combined\n // with the default rules that ship with Embroider. Your own rules take\n // precedence over the built-ins. Order matters, first matching rule will\n // apply to any given addon.\n //\n // See the addon-dependency-rules directory in the @embroider/compat package\n // for the built-in rules.\n //\n // These ONLY APPLY to v1-formatted addons. An addon that ships as native v2\n // is expected to do the right thing on its own.\n //\n // Follow to the definition of PackageRules for more info.\n packageRules?: PackageRules[];\n\n // This turns build errors into runtime errors. It is not a good idea to keep\n // it on in production. But it can be helpful when testing how much of your\n // app is able to work with staticComponents enabled.\n allowUnsafeDynamicComponents?: boolean;\n}\n\nconst defaults = Object.assign(coreWithDefaults(), {\n staticAddonTrees: false,\n staticAddonTestSupportTrees: false,\n staticEmberSource: false,\n compatAdapters: new Map(),\n extraPublicTrees: [],\n workspaceDir: null,\n packageRules: [],\n allowUnsafeDynamicComponents: false,\n});\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n return Object.assign({}, defaults, options);\n}\n\n// These are recommended configurations for addons to test themselves under. By\n// keeping them here, it's easier to do ecosystem-wide compatibility testing.\n// See the `@embroider/test-setup` package which can help consume these to test\n// them in CI.\nexport const recommendedOptions: { [name: string]: Options } = Object.freeze({\n safe: Object.freeze({}),\n optimized: Object.freeze({\n staticAddonTrees: true,\n staticAddonTestSupportTrees: true,\n staticHelpers: true,\n staticModifiers: true,\n staticComponents: true,\n staticEmberSource: true,\n allowUnsafeDynamicComponents: false,\n }),\n});\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;;AAGA,0CAA0E;AAuG1E,MAAM,QAAQ,GAAG,MAAM,CAAC,MAAM,CAAC,IAAA,0BAAgB,GAAE,EAAE;IACjD,gBAAgB,EAAE,KAAK;IACvB,2BAA2B,EAAE,KAAK;IAClC,iBAAiB,EAAE,KAAK;IACxB,cAAc,EAAE,IAAI,GAAG,EAAE;IACzB,gBAAgB,EAAE,EAAE;IACpB,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,EAAE;IAChB,4BAA4B,EAAE,KAAK;IACnC,wBAAwB,EAAE,EAAE;CAC7B,CAAC,CAAC;AAEH,SAAgB,mBAAmB,CAAC,OAAiB;IACnD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAC9C,CAAC;AAFD,kDAEC;AAED,+EAA+E;AAC/E,6EAA6E;AAC7E,+EAA+E;AAC/E,cAAc;AACD,QAAA,kBAAkB,GAAgC,MAAM,CAAC,MAAM,CAAC;IAC3E,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC;QACvB,gBAAgB,EAAE,IAAI;QACtB,2BAA2B,EAAE,IAAI;QACjC,aAAa,EAAE,IAAI;QACnB,eAAe,EAAE,IAAI;QACrB,gBAAgB,EAAE,IAAI;QACtB,iBAAiB,EAAE,IAAI;QACvB,4BAA4B,EAAE,KAAK;KACpC,CAAC;CACH,CAAC,CAAC","sourcesContent":["import type { V1AddonConstructor } from './v1-addon';\nimport type { Node } from 'broccoli-node-api';\nimport type { Options as CoreOptions } from '@embroider/core';\nimport { optionsWithDefaults as coreWithDefaults } from '@embroider/core';\nimport type { PackageRules } from './dependency-rules';\n\n// These options control how hard we will try to achieve compatibility with v1\n// addons. The defaults are conservative and try to maximize compatibility, at\n// the cost of slower or bigger builds. As you eliminate sources of legacy\n// behavior you can benefit from the more aggressive modes.\nexport default interface Options extends CoreOptions {\n // Controls whether your addon's \"addon\" trees should be resolved statically\n // at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. In this mode, we force every file into the Ember app,\n // which is the legacy behavior.\n //\n // true: produces smaller builds. The addon files must be imported from\n // somewhere we can statically see during the build. In this mode, your app\n // will only include files that are actually imported from somewhere.\n //\n // Commentary: most v1 addons already work well with this set to true, because\n // they tend to either offer Javascript that users are supposed to directly\n // `import` or components / helpers / services that get directly imported and\n // re-exported by code in App Javascript. The exceptions are addons that do\n // runtime shenanigans with `require` or scoped runtime resolutions.\n //\n // To workaround an addon that is preventing you from enabling this flag, you\n // can use addonDependencyRules.\n staticAddonTrees?: boolean;\n\n // Controls whether your addon's \"addonTestSupport\" trees should be resolved\n // statically at build time.\n //\n // false (the default): implies maximum backward compatibility at the cost\n // of bigger builds. All test support files will be forced into your Ember\n // app, which is the legacy behavior.\n //\n // true: produces smaller builds. Only files that are explicitly imported\n // will end up in your app.\n //\n // Commentary: this is analogous to staticAddonTrees and the same guidelines\n // apply.\n staticAddonTestSupportTrees?: boolean;\n\n // when true, we will load ember-source as ES modules. This means unused parts\n // of ember-source won't be included. But it also means that addons using old\n // APIs to try to `require()` things from Ember -- particularly from within\n // vendor.js -- cannot do that anymore.\n //\n // When false (the default) we load ember-source the traditional way, which is\n // that a big ol' script gets smooshed into vendor.js, and none of ember's\n // public module API actually exists as modules at build time.\n staticEmberSource?: boolean;\n\n // Allows you to override how specific addons will build. Like:\n //\n // import V1Addon from '@embroider/compat'; let compatAdapters = new Map();\n // compatAdapters.set('some-addon', class extends V1Addon {// do stuff here:\n // see examples in ./compat-adapters\n // });\n //\n // This should be understood as a temporary way to keep yourself from getting\n // stuck, not an alternative to actually fixing upstream. For the most part,\n // the real solution will be converting the addon in question to natively\n // publish as v2.\n //\n // We ship with some default compatAdapters to fix otherwise incompatible\n // behaviors in popular addons. You can override the default adapters by\n // setting your own value here (including null to completely disable it).\n compatAdapters?: Map<string, V1AddonConstructor | null>;\n\n // optional list of additional broccoli trees that should be incorporated into\n // the final build. This exists because the classic `app.toTree()` method\n // accepts an optional tree argument that has the same purpose.\n extraPublicTrees?: Node[];\n\n // Allows you to tell Embroider about otherwise dynamic dependencies within\n // your app and addons that it can't figure out on its own. These are combined\n // with the default rules that ship with Embroider. Your own rules take\n // precedence over the built-ins. Order matters, first matching rule will\n // apply to any given addon.\n //\n // See the addon-dependency-rules directory in the @embroider/compat package\n // for the built-in rules.\n //\n // These ONLY APPLY to v1-formatted addons. An addon that ships as native v2\n // is expected to do the right thing on its own.\n //\n // Follow to the definition of PackageRules for more info.\n packageRules?: PackageRules[];\n\n // This turns build errors into runtime errors. It is not a good idea to keep\n // it on in production. But it can be helpful when testing how much of your\n // app is able to work with staticComponents enabled.\n allowUnsafeDynamicComponents?: boolean;\n\n // Allows you to customize the list of content types addons use to provide HTML\n // to {{content-for}}. By default, the following content types are expected:\n // 'head', 'test-head', 'head-footer', 'test-head-footer', 'body', 'test-body',\n // 'body-footer', 'test-body-footer'. You need to use this config only to extend\n // this list.\n availableContentForTypes?: string[];\n}\n\nconst defaults = Object.assign(coreWithDefaults(), {\n staticAddonTrees: false,\n staticAddonTestSupportTrees: false,\n staticEmberSource: false,\n compatAdapters: new Map(),\n extraPublicTrees: [],\n workspaceDir: null,\n packageRules: [],\n allowUnsafeDynamicComponents: false,\n availableContentForTypes: [],\n});\n\nexport function optionsWithDefaults(options?: Options): Required<Options> {\n return Object.assign({}, defaults, options);\n}\n\n// These are recommended configurations for addons to test themselves under. By\n// keeping them here, it's easier to do ecosystem-wide compatibility testing.\n// See the `@embroider/test-setup` package which can help consume these to test\n// them in CI.\nexport const recommendedOptions: { [name: string]: Options } = Object.freeze({\n safe: Object.freeze({}),\n optimized: Object.freeze({\n staticAddonTrees: true,\n staticAddonTestSupportTrees: true,\n staticHelpers: true,\n staticModifiers: true,\n staticComponents: true,\n staticEmberSource: true,\n allowUnsafeDynamicComponents: false,\n }),\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"prepare-htmlbars-ast-plugins.js","sourceRoot":"","sources":["prepare-htmlbars-ast-plugins.ts"],"names":[],"mappings":";;AACA,+BAA4B;AAE5B,SAAwB,cAAc,CAAC,QAAa;IAClD,IAAI,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACpD,KAAK,IAAI,OAAO,IAAI,QAAQ,EAAE;QAC5B,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAC7D,IAAI,MAAM,EAAE;YACV,sFAAsF;YACtF,IAAI,aAAa,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE;gBAC1C,MAAM,CAAC,aAAa,GAAG;oBACrB,WAAW,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,uBAAuB,CAAC;oBACrD,UAAU,EAAE,cAAc;oBAC1B,MAAM,EAAE,aAAa;iBACtB,CAAC;aACH;YAED,wFAAwF;YACxF,IAAI,MAAM,CAAC,aAAa,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;gBAClD,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC;aAC9C;YAED,sEAAsE;YACtE,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;gBAC9B,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;aAC1B;YAED,uEAAuE;YACvE,IAAI,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;gBAChC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;aAC5B;SACF;KACF;IACD,IAAI,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE7D,2EAA2E;IAC3E,8EAA8E;IAC9E,wBAAwB;IACxB,OAAO,CAAC,OAAO,EAAE,CAAC;IAClB,OAAO,OAAO,CAAC;AACjB,CAAC;AArCD,iCAqCC","sourcesContent":["import type { Transform } from 'babel-plugin-ember-template-compilation';\nimport { join } from 'path';\n\nexport default function loadAstPlugins(registry: any): Transform[] {\n let wrappers = registry.load('htmlbars-ast-plugin');\n for (let wrapper of wrappers) {\n const { plugin, parallelBabel, baseDir, cacheKey } = wrapper;\n if (plugin) {\n // if the parallelBabel options were set on the wrapper, but not on the plugin, add it\n if (parallelBabel && !plugin.parallelBabel) {\n plugin.parallelBabel = {\n requireFile: join(__dirname, 'htmlbars-unwrapper.js'),\n buildUsing: 'unwrapPlugin',\n params: parallelBabel,\n };\n }\n\n // NOTE: `_parallelBabel` (not `parallelBabel`) is expected by broccoli-babel-transpiler\n if (plugin.parallelBabel && !plugin._parallelBabel) {\n plugin._parallelBabel = plugin.parallelBabel;\n }\n\n // if the baseDir is set on the wrapper, but not on the plugin, add it\n if (baseDir && !plugin.baseDir) {\n plugin.baseDir = baseDir;\n }\n\n // if the cacheKey is set on the wrapper, but not on the plugin, add it\n if (cacheKey && !plugin.cacheKey) {\n plugin.cacheKey = cacheKey;\n }\n }\n }\n let plugins = wrappers.map((wrapper: any) => wrapper.plugin);\n\n // the plugins in the registry historically run in backwards order for dumb\n // reasons. Embroider keeps them in sensible order, so here is where we do the\n // compatibility switch.\n plugins.reverse();\n return plugins;\n}\n"]}
1
+ {"version":3,"file":"prepare-htmlbars-ast-plugins.js","sourceRoot":"","sources":["prepare-htmlbars-ast-plugins.ts"],"names":[],"mappings":";;AACA,+BAA4B;AAE5B,SAAwB,cAAc,CAAC,QAAa;IAClD,IAAI,QAAQ,GAAG,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACpD,KAAK,IAAI,OAAO,IAAI,QAAQ,EAAE,CAAC;QAC7B,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;QAC7D,IAAI,MAAM,EAAE,CAAC;YACX,sFAAsF;YACtF,IAAI,aAAa,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC;gBAC3C,MAAM,CAAC,aAAa,GAAG;oBACrB,WAAW,EAAE,IAAA,WAAI,EAAC,SAAS,EAAE,uBAAuB,CAAC;oBACrD,UAAU,EAAE,cAAc;oBAC1B,MAAM,EAAE,aAAa;iBACtB,CAAC;YACJ,CAAC;YAED,wFAAwF;YACxF,IAAI,MAAM,CAAC,aAAa,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;gBACnD,MAAM,CAAC,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC;YAC/C,CAAC;YAED,sEAAsE;YACtE,IAAI,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;gBAC/B,MAAM,CAAC,OAAO,GAAG,OAAO,CAAC;YAC3B,CAAC;YAED,uEAAuE;YACvE,IAAI,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;gBACjC,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC;YAC7B,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAE7D,2EAA2E;IAC3E,8EAA8E;IAC9E,wBAAwB;IACxB,OAAO,CAAC,OAAO,EAAE,CAAC;IAClB,OAAO,OAAO,CAAC;AACjB,CAAC;AArCD,iCAqCC","sourcesContent":["import type { Transform } from 'babel-plugin-ember-template-compilation';\nimport { join } from 'path';\n\nexport default function loadAstPlugins(registry: any): Transform[] {\n let wrappers = registry.load('htmlbars-ast-plugin');\n for (let wrapper of wrappers) {\n const { plugin, parallelBabel, baseDir, cacheKey } = wrapper;\n if (plugin) {\n // if the parallelBabel options were set on the wrapper, but not on the plugin, add it\n if (parallelBabel && !plugin.parallelBabel) {\n plugin.parallelBabel = {\n requireFile: join(__dirname, 'htmlbars-unwrapper.js'),\n buildUsing: 'unwrapPlugin',\n params: parallelBabel,\n };\n }\n\n // NOTE: `_parallelBabel` (not `parallelBabel`) is expected by broccoli-babel-transpiler\n if (plugin.parallelBabel && !plugin._parallelBabel) {\n plugin._parallelBabel = plugin.parallelBabel;\n }\n\n // if the baseDir is set on the wrapper, but not on the plugin, add it\n if (baseDir && !plugin.baseDir) {\n plugin.baseDir = baseDir;\n }\n\n // if the cacheKey is set on the wrapper, but not on the plugin, add it\n if (cacheKey && !plugin.cacheKey) {\n plugin.cacheKey = cacheKey;\n }\n }\n }\n let plugins = wrappers.map((wrapper: any) => wrapper.plugin);\n\n // the plugins in the registry historically run in backwards order for dumb\n // reasons. Embroider keeps them in sensible order, so here is where we do the\n // compatibility switch.\n plugins.reverse();\n return plugins;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rename-require-plugin.js","sourceRoot":"","sources":["rename-require-plugin.ts"],"names":[],"mappings":";;AAGA,SAAwB,kBAAkB;IACxC,OAAO;QACL,OAAO,EAAE;YACP,sBAAsB,CAAC,IAAwC;gBAC7D,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE;oBACtC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;iBAC9B;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAVD,qCAUC","sourcesContent":["import type { types as t } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\n\nexport default function inlineHBSTransform(): unknown {\n return {\n visitor: {\n ImportDefaultSpecifier(path: NodePath<t.ImportDefaultSpecifier>) {\n if (path.node.local.name === 'require') {\n path.scope.rename('require');\n }\n },\n },\n };\n}\n"]}
1
+ {"version":3,"file":"rename-require-plugin.js","sourceRoot":"","sources":["rename-require-plugin.ts"],"names":[],"mappings":";;AAGA,SAAwB,kBAAkB;IACxC,OAAO;QACL,OAAO,EAAE;YACP,sBAAsB,CAAC,IAAwC;gBAC7D,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;oBACvC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;gBAC/B,CAAC;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAVD,qCAUC","sourcesContent":["import type { types as t } from '@babel/core';\nimport type { NodePath } from '@babel/traverse';\n\nexport default function inlineHBSTransform(): unknown {\n return {\n visitor: {\n ImportDefaultSpecifier(path: NodePath<t.ImportDefaultSpecifier>) {\n if (path.node.local.name === 'require') {\n path.scope.rename('require');\n }\n },\n },\n };\n}\n"]}
@@ -471,6 +471,9 @@ class TemplateResolver {
471
471
  return { files, components };
472
472
  }
473
473
  findRules(absPath) {
474
+ // when babel is invoked by vite our filenames can have query params still
475
+ // hanging off them. That would break rule matching.
476
+ absPath = (0, core_1.cleanUrl)(absPath, true);
474
477
  let fileRules = this.rules.files.get(absPath);
475
478
  let componentRules;
476
479
  let componentName = this.moduleResolver.reverseComponentLookup(absPath);