@embroider/addon-dev 1.8.2 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/addon-dev",
3
- "version": "1.8.2",
3
+ "version": "2.0.0",
4
4
  "description": "Utilities for addon authors",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,11 +24,11 @@
24
24
  "src/**/*.js.map"
25
25
  ],
26
26
  "scripts": {
27
- "prepare": "tsc",
27
+ "xprepare": "tsc",
28
28
  "test": "jest"
29
29
  },
30
30
  "dependencies": {
31
- "@embroider/core": "^1.8.2",
31
+ "@embroider/core": "^1.9.0",
32
32
  "@rollup/pluginutils": "^4.1.1",
33
33
  "assert-never": "^1.2.1",
34
34
  "fs-extra": "^10.0.0",
@@ -4,48 +4,65 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const walk_sync_1 = __importDefault(require("walk-sync"));
7
- const path_1 = require("path");
7
+ const path_1 = __importDefault(require("path"));
8
8
  const minimatch_1 = __importDefault(require("minimatch"));
9
- const fs_extra_1 = require("fs-extra");
10
9
  function normalizeFileExt(fileName) {
11
10
  return fileName.replace(/\.ts|\.hbs|\.gts|\.gjs$/, '.js');
12
11
  }
13
- const hbsPattern = '**/*.hbs';
14
12
  function publicEntrypoints(args) {
15
13
  return {
16
14
  name: 'addon-modules',
17
15
  async buildStart() {
18
16
  let matches = (0, walk_sync_1.default)(args.srcDir, {
19
- globs: [...args.include, hbsPattern],
17
+ globs: [...args.include, '**/*.hbs', '**/*.ts', '**/*.gts', '**/*.gjs'],
20
18
  });
21
19
  for (let name of matches) {
22
- if (args.include.some((pattern) => (0, minimatch_1.default)(name, pattern))) {
23
- // anything that matches one of the user's patterns is definitely emitted
20
+ // the matched file, but with the extension swapped with .js
21
+ let normalizedName = normalizeFileExt(name);
22
+ // anything that doesn't match the users patterns, and wasn't a template-only
23
+ // component needs to be emitted "as-is" so that other plugins may handle it.
24
+ let isTO = isTemplateOnly(matches, name);
25
+ let isHbs = path_1.default.extname(name) === '.hbs';
26
+ // hbs for-colocated components is handled by the rollup-hbs-plugin
27
+ // hbs for template-only components is handled in the isTO block
28
+ if (isHbs && !isTO) {
29
+ continue;
30
+ }
31
+ // these chunks matched are **/*.hbs glob and are
32
+ // guaranteed to not have any corresponding file as a co-located component would have.
33
+ if (isTO) {
24
34
  this.emitFile({
25
35
  type: 'chunk',
26
- id: (0, path_1.join)(args.srcDir, name),
27
- fileName: normalizeFileExt(name),
36
+ id: path_1.default.join(args.srcDir, normalizedName),
37
+ fileName: normalizedName,
28
38
  });
39
+ continue;
29
40
  }
30
- else {
31
- // this file didn't match one of the user's patterns, so it must match
32
- // our hbsPattern. Infer the possible existence of a synthesized
33
- // template-only component JS file and test whether that file would
34
- // match the user's patterns.
35
- let normalizedName = normalizeFileExt(name);
36
- let id = (0, path_1.join)(args.srcDir, normalizedName);
37
- if (args.include.some((pattern) => (0, minimatch_1.default)(normalizedName, pattern)) &&
38
- !(0, fs_extra_1.pathExistsSync)(id)) {
39
- this.emitFile({
40
- type: 'chunk',
41
- id,
42
- fileName: normalizedName,
43
- });
44
- }
41
+ // anything that matches one of the user's patterns is definitely emitted
42
+ let isUserDefined = args.include.some((pattern) => (0, minimatch_1.default)(name, pattern));
43
+ // additionally, we want to emit chunks where the pattern matches the supported
44
+ // file extensions above (TS, GTS, etc) as if they were already the built JS.
45
+ let wouldMatchIfBuilt = args.include.some((pattern) => (0, minimatch_1.default)(normalizedName, pattern));
46
+ if (isUserDefined || wouldMatchIfBuilt) {
47
+ this.emitFile({
48
+ type: 'chunk',
49
+ id: path_1.default.join(args.srcDir, name),
50
+ fileName: normalizedName,
51
+ });
52
+ continue;
45
53
  }
46
54
  }
47
55
  },
48
56
  };
49
57
  }
50
58
  exports.default = publicEntrypoints;
59
+ function isTemplateOnly(matches, filePath) {
60
+ let isHbs = path_1.default.extname(filePath) === '.hbs';
61
+ if (!isHbs)
62
+ return false;
63
+ let correspondingFileGlob = path_1.default.join(path_1.default.dirname(filePath), path_1.default.basename(filePath).replace(/hbs$/, '*'));
64
+ let relatedFiles = matches.filter((match) => (0, minimatch_1.default)(match, correspondingFileGlob));
65
+ let isTO = relatedFiles.filter((x) => x !== filePath).length === 0;
66
+ return isTO;
67
+ }
51
68
  //# sourceMappingURL=rollup-public-entrypoints.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup-public-entrypoints.js","sourceRoot":"","sources":["rollup-public-entrypoints.ts"],"names":[],"mappings":";;;;;AAAA,0DAAiC;AACjC,+BAA4B;AAC5B,0DAAkC;AAGlC,uCAA0C;AAE1C,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,QAAQ,CAAC,OAAO,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,GAAG,UAAU,CAAC;AAE9B,SAAwB,iBAAiB,CAAC,IAGzC;IACC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,CAAC,UAAU;YACd,IAAI,OAAO,GAAG,IAAA,mBAAQ,EAAC,IAAI,CAAC,MAAM,EAAE;gBAClC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,UAAU,CAAC;aACrC,CAAC,CAAC;YAEH,KAAK,IAAI,IAAI,IAAI,OAAO,EAAE;gBACxB,IAAI,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,mBAAS,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,EAAE;oBAC5D,yEAAyE;oBACzE,IAAI,CAAC,QAAQ,CAAC;wBACZ,IAAI,EAAE,OAAO;wBACb,EAAE,EAAE,IAAA,WAAI,EAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;wBAC3B,QAAQ,EAAE,gBAAgB,CAAC,IAAI,CAAC;qBACjC,CAAC,CAAC;iBACJ;qBAAM;oBACL,sEAAsE;oBACtE,gEAAgE;oBAChE,mEAAmE;oBACnE,6BAA6B;oBAC7B,IAAI,cAAc,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;oBAC5C,IAAI,EAAE,GAAG,IAAA,WAAI,EAAC,IAAI,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;oBAC3C,IACE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAC5B,IAAA,mBAAS,EAAC,cAAc,EAAE,OAAO,CAAC,CACnC;wBACD,CAAC,IAAA,yBAAc,EAAC,EAAE,CAAC,EACnB;wBACA,IAAI,CAAC,QAAQ,CAAC;4BACZ,IAAI,EAAE,OAAO;4BACb,EAAE;4BACF,QAAQ,EAAE,cAAc;yBACzB,CAAC,CAAC;qBACJ;iBACF;aACF;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AA1CD,oCA0CC","sourcesContent":["import walkSync from 'walk-sync';\nimport { join } from 'path';\nimport minimatch from 'minimatch';\n\nimport type { Plugin } from 'rollup';\nimport { pathExistsSync } from 'fs-extra';\n\nfunction normalizeFileExt(fileName: string) {\n return fileName.replace(/\\.ts|\\.hbs|\\.gts|\\.gjs$/, '.js');\n}\n\nconst hbsPattern = '**/*.hbs';\n\nexport default function publicEntrypoints(args: {\n srcDir: string;\n include: string[];\n}): Plugin {\n return {\n name: 'addon-modules',\n async buildStart() {\n let matches = walkSync(args.srcDir, {\n globs: [...args.include, hbsPattern],\n });\n\n for (let name of matches) {\n if (args.include.some((pattern) => minimatch(name, pattern))) {\n // anything that matches one of the user's patterns is definitely emitted\n this.emitFile({\n type: 'chunk',\n id: join(args.srcDir, name),\n fileName: normalizeFileExt(name),\n });\n } else {\n // this file didn't match one of the user's patterns, so it must match\n // our hbsPattern. Infer the possible existence of a synthesized\n // template-only component JS file and test whether that file would\n // match the user's patterns.\n let normalizedName = normalizeFileExt(name);\n let id = join(args.srcDir, normalizedName);\n if (\n args.include.some((pattern) =>\n minimatch(normalizedName, pattern)\n ) &&\n !pathExistsSync(id)\n ) {\n this.emitFile({\n type: 'chunk',\n id,\n fileName: normalizedName,\n });\n }\n }\n }\n },\n };\n}\n"]}
1
+ {"version":3,"file":"rollup-public-entrypoints.js","sourceRoot":"","sources":["rollup-public-entrypoints.ts"],"names":[],"mappings":";;;;;AAAA,0DAAiC;AACjC,gDAAwB;AACxB,0DAAkC;AAIlC,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,QAAQ,CAAC,OAAO,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED,SAAwB,iBAAiB,CAAC,IAGzC;IACC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,KAAK,CAAC,UAAU;YACd,IAAI,OAAO,GAAG,IAAA,mBAAQ,EAAC,IAAI,CAAC,MAAM,EAAE;gBAClC,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC;aACxE,CAAC,CAAC;YAEH,KAAK,IAAI,IAAI,IAAI,OAAO,EAAE;gBACxB,4DAA4D;gBAC5D,IAAI,cAAc,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;gBAE5C,6EAA6E;gBAC7E,6EAA6E;gBAC7E,IAAI,IAAI,GAAG,cAAc,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;gBAEzC,IAAI,KAAK,GAAG,cAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,MAAM,CAAC;gBAE1C,mEAAmE;gBACnE,gEAAgE;gBAChE,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;oBAClB,SAAS;iBACV;gBAED,iDAAiD;gBACjD,sFAAsF;gBACtF,IAAI,IAAI,EAAE;oBACR,IAAI,CAAC,QAAQ,CAAC;wBACZ,IAAI,EAAE,OAAO;wBACb,EAAE,EAAE,cAAI,CAAC,IAAI,CAAC,IA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AAC;IACF,IAAI,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;IAEnE,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import walkSync from 'walk-sync';\nimport path from 'path';\nimport minimatch from 'minimatch';\n\nimport type { Plugin } from 'rollup';\n\nfunction normalizeFileExt(fileName: string) {\n return fileName.replace(/\\.ts|\\.hbs|\\.gts|\\.gjs$/, '.js');\n}\n\nexport default function publicEntrypoints(args: {\n srcDir: string;\n include: string[];\n}): Plugin {\n return {\n name: 'addon-modules',\n async buildStart() {\n let matches = walkSync(args.srcDir, {\n globs: [...args.include, '**/*.hbs', '**/*.ts', '**/*.gts', '**/*.gjs'],\n });\n\n for (let name of matches) {\n // the matched file, but with the extension swapped with .js\n let normalizedName = normalizeFileExt(name);\n\n // anything that doesn't match the users patterns, and wasn't a template-only\n // component needs to be emitted \"as-is\" so that other plugins may handle it.\n let isTO = isTemplateOnly(matches, name);\n\n let isHbs = path.extname(name) === '.hbs';\n\n // hbs for-colocated components is handled by the rollup-hbs-plugin\n // hbs for template-only components is handled in the isTO block\n if (isHbs && !isTO) {\n continue;\n }\n\n // these chunks matched are **/*.hbs glob and are\n // guaranteed to not have any corresponding file as a co-located component would have.\n if (isTO) {\n this.emitFile({\n type: 'chunk',\n id: path.join(args.srcDir, normalizedName),\n fileName: normalizedName,\n });\n\n continue;\n }\n\n // anything that matches one of the user's patterns is definitely emitted\n let isUserDefined = args.include.some((pattern) =>\n minimatch(name, pattern)\n );\n\n // additionally, we want to emit chunks where the pattern matches the supported\n // file extensions above (TS, GTS, etc) as if they were already the built JS.\n let wouldMatchIfBuilt = args.include.some((pattern) =>\n minimatch(normalizedName, pattern)\n );\n\n if (isUserDefined || wouldMatchIfBuilt) {\n this.emitFile({\n type: 'chunk',\n id: path.join(args.srcDir, name),\n fileName: normalizedName,\n });\n\n continue;\n }\n }\n },\n };\n}\n\nfunction isTemplateOnly(matches: string[], filePath: string) {\n let isHbs = path.extname(filePath) === '.hbs';\n\n if (!isHbs) return false;\n\n let correspondingFileGlob = path.join(\n path.dirname(filePath),\n path.basename(filePath).replace(/hbs$/, '*')\n );\n\n let relatedFiles = matches.filter((match) =>\n minimatch(match, correspondingFileGlob)\n );\n let isTO = relatedFiles.filter((x) => x !== filePath).length === 0;\n\n return isTO;\n}\n"]}
package/src/rollup.d.ts CHANGED
@@ -10,12 +10,14 @@ export declare class Addon {
10
10
  }): Plugin;
11
11
  publicEntrypoints(patterns: string[]): Plugin;
12
12
  hbs(): Plugin;
13
- clean(): Plugin;
13
+ clean(): import("rollup").Plugin;
14
14
  keepAssets(patterns: string[]): Plugin;
15
15
  output(): {
16
16
  dir: string;
17
17
  format: string;
18
18
  entryFileNames: string;
19
+ hoistTransitiveImports: boolean;
20
+ sourcemap: boolean;
19
21
  };
20
22
  dependencies(): Plugin;
21
23
  }
package/src/rollup.js CHANGED
@@ -56,7 +56,7 @@ class Addon {
56
56
  // By default rollup does not clear the output directory between builds. This
57
57
  // does that.
58
58
  clean() {
59
- return (0, rollup_plugin_delete_1.default)({ targets: `${__classPrivateFieldGet(this, _Addon_destDir, "f")}/*` });
59
+ return (0, rollup_plugin_delete_1.default)({ targets: `${__classPrivateFieldGet(this, _Addon_destDir, "f")}/*`, hook: 'generateBundle' });
60
60
  }
61
61
  // V2 Addons are allowed to contain imports of .css files. This tells rollup
62
62
  // to leave those imports alone and to make sure the corresponding .css files
@@ -72,8 +72,19 @@ class Addon {
72
72
  // emitting ES modules, in your `destDir`, and their filenames are equal to
73
73
  // their bundle names (the bundle names get generated by `publicEntrypoints`
74
74
  // above).
75
+ //
76
+ // hoistTransitiveImports is disabled because the purpose of hoisting transitive imports
77
+ // is to improve performance of apps loading modules.
78
+ // Since v2 addons do not know exactly how they'll be used, this performance decision
79
+ // is left up to apps.
75
80
  output() {
76
- return { dir: __classPrivateFieldGet(this, _Addon_destDir, "f"), format: 'es', entryFileNames: '[name]' };
81
+ return {
82
+ dir: __classPrivateFieldGet(this, _Addon_destDir, "f"),
83
+ format: 'es',
84
+ entryFileNames: '[name]',
85
+ hoistTransitiveImports: false,
86
+ sourcemap: true,
87
+ };
77
88
  }
78
89
  dependencies() {
79
90
  return (0, rollup_addon_dependencies_1.default)();
package/src/rollup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.js","sourceRoot":"","sources":["rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4EAAqD;AACrD,4FAA2E;AAC3E,kFAAiE;AACjE,gFAAwD;AACxD,8EAA6D;AAC7D,4FAAsE;AAGtE,MAAa,KAAK;IAIhB,YAAY,SAAgD,EAAE;;QAH9D,gCAAgB;QAChB,iCAAiB;QAGf,uBAAA,IAAI,iBAAW,MAAA,MAAM,CAAC,MAAM,mCAAI,KAAK,MAAA,CAAC;QACtC,uBAAA,IAAI,kBAAY,MAAA,MAAM,CAAC,OAAO,mCAAI,MAAM,MAAA,CAAC;IAC3C,CAAC;IAED,0EAA0E;IAC1E,yEAAyE;IACzE,0CAA0C;IAC1C,YAAY,CACV,QAAkB,EAClB,OAAuD,EAAE;QAEzD,OAAO,IAAA,8BAAY,EAAC;YAClB,IAAI,EAAE,uBAAA,IAAI,qBAAQ;YAClB,EAAE,EAAE,uBAAA,IAAI,sBAAS;YACjB,OAAO,EAAE,QAAQ;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;IACL,CAAC;IAED,4EAA4E;IAC5E,0EAA0E;IAC1E,+EAA+E;IAC/E,iBAAiB,CAAC,QAAkB;QAClC,OAAO,IAAA,mCAAiB,EAAC,EAAE,MAAM,EAAE,uBAAA,IAAI,qBAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC;IACxE,CAAC;IAED,oEAAoE;IACpE,sEAAsE;IACtE,8DAA8D;IAC9D,GAAG;QACD,OAAO,IAAA,2BAAG,GAAE,CAAC;IACf,CAAC;IAED,6EAA6E;IAC7E,aAAa;IACb,KAAK;QACH,OAAO,IAAA,8BAAK,EAAC,EAAE,OAAO,EAAE,GAAG,uBAAA,IAAI,sBAAS,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,4EAA4E;IAC5E,6EAA6E;IAC7E,6EAA6E;IAC7E,UAAU;IACV,UAAU,CAAC,QAAkB;QAC3B,OAAO,IAAA,4BAAU,EAAC;YAChB,IAAI,EAAE,uBAAA,IAAI,qBAAQ;YAClB,OAAO,EAAE,QAAQ;SAClB,CAAC,CAAC;IACL,CAAC;IAED,8EAA8E;IAC9E,2EAA2E;IAC3E,4EAA4E;IAC5E,UAAU;IACV,MAAM;QACJ,OAAO,EAAE,GAAG,EAAE,uBAAA,IAAI,sBAAS,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;IACxE,CAAC;IAED,YAAY;QACV,OAAO,IAAA,mCAAY,GAAE,CAAC;IACxB,CAAC;CACF;AAlED,sBAkEC","sourcesContent":["import { default as hbs } from './rollup-hbs-plugin';\nimport { default as publicEntrypoints } from './rollup-public-entrypoints';\nimport { default as appReexports } from './rollup-app-reexports';\nimport { default as clean } from 'rollup-plugin-delete';\nimport { default as keepAssets } from './rollup-keep-assets';\nimport { default as dependencies } from './rollup-addon-dependencies';\nimport type { Plugin } from 'rollup';\n\nexport class Addon {\n #srcDir: string;\n #destDir: string;\n\n constructor(params: { srcDir?: string; destDir?: string } = {}) {\n this.#srcDir = params.srcDir ?? 'src';\n this.#destDir = params.destDir ?? 'dist';\n }\n\n // Given a list of globs describing modules in your srcDir, this generates\n // corresponding appTree modules that contain reexports, and updates your\n // package.json metadata to list them all.\n appReexports(\n patterns: string[],\n opts: { mapFilename?: (fileName: string) => string } = {}\n ): Plugin {\n return appReexports({\n from: this.#srcDir,\n to: this.#destDir,\n include: patterns,\n mapFilename: opts.mapFilename,\n });\n }\n\n // This configures rollup to emit public entrypoints for each module in your\n // srcDir that matches one of the given globs. Typical addons will want to\n // match patterns like \"components/**/*.js\", \"index.js\", and \"test-support.js\".\n publicEntrypoints(patterns: string[]) {\n return publicEntrypoints({ srcDir: this.#srcDir, include: patterns });\n }\n\n // This wraps standalone .hbs files as Javascript files using inline\n // templates. This means special resolving rules for .hbs files aren't\n // required for javascript tooling to understand your package.\n hbs() {\n return hbs();\n }\n\n // By default rollup does not clear the output directory between builds. This\n // does that.\n clean() {\n return clean({ targets: `${this.#destDir}/*` });\n }\n\n // V2 Addons are allowed to contain imports of .css files. This tells rollup\n // to leave those imports alone and to make sure the corresponding .css files\n // are kept in the same relative locations in the destDir as they were in the\n // srcDir.\n keepAssets(patterns: string[]) {\n return keepAssets({\n from: this.#srcDir,\n include: patterns,\n });\n }\n\n // This is the default `output` configuration you should pass to rollup. We're\n // emitting ES modules, in your `destDir`, and their filenames are equal to\n // their bundle names (the bundle names get generated by `publicEntrypoints`\n // above).\n output() {\n return { dir: this.#destDir, format: 'es', entryFileNames: '[name]' };\n }\n\n dependencies() {\n return dependencies();\n }\n}\n"]}
1
+ {"version":3,"file":"rollup.js","sourceRoot":"","sources":["rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4EAAqD;AACrD,4FAA2E;AAC3E,kFAAiE;AACjE,gFAAwD;AACxD,8EAA6D;AAC7D,4FAAsE;AAGtE,MAAa,KAAK;IAIhB,YAAY,SAAgD,EAAE;;QAH9D,gCAAgB;QAChB,iCAAiB;QAGf,uBAAA,IAAI,iBAAW,MAAA,MAAM,CAAC,MAAM,mCAAI,KAAK,MAAA,CAAC;QACtC,uBAAA,IAAI,kBAAY,MAAA,MAAM,CAAC,OAAO,mCAAI,MAAM,MAAA,CAAC;IAC3C,CAAC;IAED,0EAA0E;IAC1E,yEAAyE;IACzE,0CAA0C;IAC1C,YAAY,CACV,QAAkB,EAClB,OAAuD,EAAE;QAEzD,OAAO,IAAA,8BAAY,EAAC;YAClB,IAAI,EAAE,uBAA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":["import { default as hbs } from './rollup-hbs-plugin';\nimport { default as publicEntrypoints } from './rollup-public-entrypoints';\nimport { default as appReexports } from './rollup-app-reexports';\nimport { default as clean } from 'rollup-plugin-delete';\nimport { default as keepAssets } from './rollup-keep-assets';\nimport { default as dependencies } from './rollup-addon-dependencies';\nimport type { Plugin } from 'rollup';\n\nexport class Addon {\n #srcDir: string;\n #destDir: string;\n\n constructor(params: { srcDir?: string; destDir?: string } = {}) {\n this.#srcDir = params.srcDir ?? 'src';\n this.#destDir = params.destDir ?? 'dist';\n }\n\n // Given a list of globs describing modules in your srcDir, this generates\n // corresponding appTree modules that contain reexports, and updates your\n // package.json metadata to list them all.\n appReexports(\n patterns: string[],\n opts: { mapFilename?: (fileName: string) => string } = {}\n ): Plugin {\n return appReexports({\n from: this.#srcDir,\n to: this.#destDir,\n include: patterns,\n mapFilename: opts.mapFilename,\n });\n }\n\n // This configures rollup to emit public entrypoints for each module in your\n // srcDir that matches one of the given globs. Typical addons will want to\n // match patterns like \"components/**/*.js\", \"index.js\", and \"test-support.js\".\n publicEntrypoints(patterns: string[]) {\n return publicEntrypoints({ srcDir: this.#srcDir, include: patterns });\n }\n\n // This wraps standalone .hbs files as Javascript files using inline\n // templates. This means special resolving rules for .hbs files aren't\n // required for javascript tooling to understand your package.\n hbs() {\n return hbs();\n }\n\n // By default rollup does not clear the output directory between builds. This\n // does that.\n clean() {\n return clean({ targets: `${this.#destDir}/*`, hook: 'generateBundle' });\n }\n\n // V2 Addons are allowed to contain imports of .css files. This tells rollup\n // to leave those imports alone and to make sure the corresponding .css files\n // are kept in the same relative locations in the destDir as they were in the\n // srcDir.\n keepAssets(patterns: string[]) {\n return keepAssets({\n from: this.#srcDir,\n include: patterns,\n });\n }\n\n // This is the default `output` configuration you should pass to rollup. We're\n // emitting ES modules, in your `destDir`, and their filenames are equal to\n // their bundle names (the bundle names get generated by `publicEntrypoints`\n // above).\n //\n // hoistTransitiveImports is disabled because the purpose of hoisting transitive imports\n // is to improve performance of apps loading modules.\n // Since v2 addons do not know exactly how they'll be used, this performance decision\n // is left up to apps.\n output() {\n return {\n dir: this.#destDir,\n format: 'es',\n entryFileNames: '[name]',\n hoistTransitiveImports: false,\n sourcemap: true,\n };\n }\n\n dependencies() {\n return dependencies();\n }\n}\n"]}
@@ -10,7 +10,7 @@ function resolvePlugins(plugins) {
10
10
  return plugins.map((somePlugin) => {
11
11
  // If it's a string attempt to resolve the path to a module.
12
12
  return typeof somePlugin === 'string'
13
- ? require(somePlugin) // eslint-disable-line @typescript-eslint/no-require-imports
13
+ ? require(require.resolve(somePlugin, { paths: [process.cwd()] })) // eslint-disable-line @typescript-eslint/no-require-imports
14
14
  : somePlugin;
15
15
  });
16
16
  }
@@ -1 +1 @@
1
- {"version":3,"file":"template-transform-plugin.js","sourceRoot":"","sources":["template-transform-plugin.ts"],"names":[],"mappings":";;;;;AAAA,wHAAsE;AACtE,0CAA2E;AAC3E,mGAAmF;AAWnF,SAAS,cAAc,CAAC,OAAkC;IACxD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,UAAmC,EAAE,EAAE;QACzD,4DAA4D;QAC5D,OAAO,OAAO,UAAU,KAAK,QAAQ;YACnC,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,4DAA4D;YAClF,CAAC,CAAC,UAAU,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kBAAe,IAAA,wCAAI,EAAC,CAAC,OAAgB,EAAE,EAAE;IACvC,IAAI,EACF,aAAa,EAAE,WAAW,GAAG,EAAE,EAC/B,YAAY,GAAG,2CAA2C,GAC3D,GAAG,OAAO,CAAC;IAEZ,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAE7C,MAAM,aAAa,GAAwB,cAAc,CAAC,WAAW,CAAC,CAAC;IAEvE,MAAM,MAAM,GAA2B;QACrC,QAAQ,EAAE,EAAE;QACZ,yBAAyB,EAAE,GAAG,EAAE,CAAC,IAAA,8CAAe,EAAC,YAAY,CAAC;QAC9D,OAAO,EAAE;YACP,GAAG,EAAE,aAAa;SACnB;KACF,CAAC;IAEF,OAAO,IAAI,uBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC","sourcesContent":["import make from '@embroider/core/src/babel-plugin-stage1-inline-hbs';\nimport { TemplateCompiler, TemplateCompilerParams } from '@embroider/core';\nimport { getEmberExports } from '@embroider/core/src/load-ember-template-compiler';\n\nexport type TemplateTransform = () => { name: string; visitor: {} };\nexport type TemplateTransformPlugin = TemplateTransform | string;\nexport interface Options {\n // An array of either Glimmer AST plugins or paths that can be resolved to a plugin.\n astTransforms?: TemplateTransformPlugin[];\n // Defaults to 'ember-source/dist/ember-template-compiler'\n compilerPath?: string;\n}\n\nfunction resolvePlugins(plugins: TemplateTransformPlugin[]) {\n return plugins.map((somePlugin: TemplateTransformPlugin) => {\n // If it's a string attempt to resolve the path to a module.\n return typeof somePlugin === 'string'\n ? require(somePlugin) // eslint-disable-line @typescript-eslint/no-require-imports\n : somePlugin;\n });\n}\n\nexport default make((options: Options) => {\n let {\n astTransforms: somePlugins = [],\n compilerPath = 'ember-source/dist/ember-template-compiler',\n } = options;\n\n compilerPath = require.resolve(compilerPath);\n\n const astTransforms: TemplateTransform[] = resolvePlugins(somePlugins);\n\n const params: TemplateCompilerParams = {\n EmberENV: {},\n loadEmberTemplateCompiler: () => getEmberExports(compilerPath),\n plugins: {\n ast: astTransforms,\n },\n };\n\n return new TemplateCompiler(params);\n});\n"]}
1
+ {"version":3,"file":"template-transform-plugin.js","sourceRoot":"","sources":["template-transform-plugin.ts"],"names":[],"mappings":";;;;;AAAA,wHAAsE;AACtE,0CAA2E;AAC3E,mGAAmF;AAWnF,SAAS,cAAc,CAAC,OAAkC;IACxD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,UAAmC,EAAE,EAAE;QACzD,4DAA4D;QAC5D,OAAO,OAAO,UAAU,KAAK,QAAQ;YACnC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,KAAK,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,4DAA4D;YAC/H,CAAC,CAAC,UAAU,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,kBAAe,IAAA,wCAAI,EAAC,CAAC,OAAgB,EAAE,EAAE;IACvC,IAAI,EACF,aAAa,EAAE,WAAW,GAAG,EAAE,EAC/B,YAAY,GAAG,2CAA2C,GAC3D,GAAG,OAAO,CAAC;IAEZ,YAAY,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAE7C,MAAM,aAAa,GAAwB,cAAc,CAAC,WAAW,CAAC,CAAC;IAEvE,MAAM,MAAM,GAA2B;QACrC,QAAQ,EAAE,EAAE;QACZ,yBAAyB,EAAE,GAAG,EAAE,CAAC,IAAA,8CAAe,EAAC,YAAY,CAAC;QAC9D,OAAO,EAAE;YACP,GAAG,EAAE,aAAa;SACnB;KACF,CAAC;IAEF,OAAO,IAAI,uBAAgB,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC","sourcesContent":["import make from '@embroider/core/src/babel-plugin-stage1-inline-hbs';\nimport { TemplateCompiler, TemplateCompilerParams } from '@embroider/core';\nimport { getEmberExports } from '@embroider/core/src/load-ember-template-compiler';\n\nexport type TemplateTransform = () => { name: string; visitor: {} };\nexport type TemplateTransformPlugin = TemplateTransform | string;\nexport interface Options {\n // An array of either Glimmer AST plugins or paths that can be resolved to a plugin.\n astTransforms?: TemplateTransformPlugin[];\n // Defaults to 'ember-source/dist/ember-template-compiler'\n compilerPath?: string;\n}\n\nfunction resolvePlugins(plugins: TemplateTransformPlugin[]) {\n return plugins.map((somePlugin: TemplateTransformPlugin) => {\n // If it's a string attempt to resolve the path to a module.\n return typeof somePlugin === 'string'\n ? require(require.resolve(somePlugin, { paths: [process.cwd()] })) // eslint-disable-line @typescript-eslint/no-require-imports\n : somePlugin;\n });\n}\n\nexport default make((options: Options) => {\n let {\n astTransforms: somePlugins = [],\n compilerPath = 'ember-source/dist/ember-template-compiler',\n } = options;\n\n compilerPath = require.resolve(compilerPath);\n\n const astTransforms: TemplateTransform[] = resolvePlugins(somePlugins);\n\n const params: TemplateCompilerParams = {\n EmberENV: {},\n loadEmberTemplateCompiler: () => getEmberExports(compilerPath),\n plugins: {\n ast: astTransforms,\n },\n };\n\n return new TemplateCompiler(params);\n});\n"]}