@embroider/addon-dev 6.0.1 → 7.0.1-unstable.3e8dbe3

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/README.md CHANGED
@@ -22,6 +22,26 @@ For a guide on porting a V1 addon to V2, see https://github.com/embroider-build/
22
22
 
23
23
  A rollup plugin to expose a folder of assets. `path` is a required to define which folder to expose. `options.include` is a glob pattern passed to `walkSync.include` to pick files. `options.exlude` is a glob pattern passed to `walkSync.ignore` to exclude files. `options.namespace` is the namespace to expose files, defaults to the package name + the path that you provided e.g. if you call `addon.publicAssets('public')` in a v2 addon named `super-addon` then your namespace will default to `super-addon/public`.
24
24
 
25
+ ### addon.keepAssets(patterns: string[], exports?: 'default' | '*')
26
+
27
+ A rollup plugin to preserve imports of non-Javascript assets unchanged in your published package. For example, the v2-addon-blueprint uses:
28
+
29
+ ```js
30
+ addon.keepAssets(['**/*.css'])
31
+ ```
32
+
33
+ so that the line `import "./my.css"` in your addon will be preserved and the corresponding CSS file will get included at the right path.
34
+
35
+ `keepAssets` is intended to compose correctly with other plugins that synthesize CSS imports, like `glimmer-scoped-css`. It will capture their output and produce real CSS files in your published package.
36
+
37
+ The `exports` option defaults to `undefined` which means the assets are used for side-effect only and don't export any values. This is the supported way to use CSS in v2 addons. But you can also preserve assets that present themselves as having default exports with the value `"default"` or arbitrary named exports with the value `"*"`. For example:
38
+
39
+ ```js
40
+ addon.keepAssets(["**/*.png"], "default")
41
+ ```
42
+
43
+ lets you say `import imageURL from './my-image.png'`. Not that this pattern is **not** automatically supported in V2 addons and you would need to tell apps that consume your addon to handle it in a custom way.
44
+
25
45
  ## addon-dev command
26
46
 
27
47
  The `addon-dev` command helps with common tasks in v2 addons.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/addon-dev",
3
- "version": "6.0.1",
3
+ "version": "7.0.1-unstable.3e8dbe3",
4
4
  "description": "Utilities for addon authors",
5
5
  "repository": {
6
6
  "type": "git",
@@ -31,14 +31,14 @@
31
31
  }
32
32
  },
33
33
  "dependencies": {
34
- "@rollup/pluginutils": "^4.1.1",
35
- "content-tag": "^2.0.1",
34
+ "@rollup/pluginutils": "^5.1.0",
35
+ "content-tag": "^3.0.0",
36
36
  "fs-extra": "^10.0.0",
37
37
  "minimatch": "^3.0.4",
38
38
  "rollup-plugin-copy-assets": "^2.0.3",
39
39
  "walk-sync": "^3.0.0",
40
40
  "yargs": "^17.0.1",
41
- "@embroider/core": "^3.4.18"
41
+ "@embroider/core": "^3.4.20-unstable.3e8dbe3"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@glimmer/syntax": "^0.84.2",
@@ -1,4 +1,2 @@
1
1
  import type { Plugin } from 'rollup';
2
- export default function rollupGjsPlugin({ inline_source_map }?: {
3
- inline_source_map: boolean;
4
- }): Plugin;
2
+ export default function rollupGjsPlugin(): Plugin;
@@ -6,7 +6,7 @@ const content_tag_1 = require("content-tag");
6
6
  const PLUGIN_NAME = 'rollup-gjs-plugin';
7
7
  const processor = new content_tag_1.Preprocessor();
8
8
  // import { parse as pathParse } from 'path';
9
- function rollupGjsPlugin({ inline_source_map } = { inline_source_map: true }) {
9
+ function rollupGjsPlugin() {
10
10
  return {
11
11
  name: PLUGIN_NAME,
12
12
  transform: {
@@ -16,12 +16,12 @@ function rollupGjsPlugin({ inline_source_map } = { inline_source_map: true }) {
16
16
  if (!gjsFilter(id)) {
17
17
  return null;
18
18
  }
19
- let code = processor.process(input, {
19
+ let { code, map } = processor.process(input, {
20
20
  filename: id,
21
- inline_source_map,
22
21
  });
23
22
  return {
24
23
  code,
24
+ map,
25
25
  };
26
26
  },
27
27
  },
@@ -1 +1 @@
1
- {"version":3,"file":"rollup-gjs-plugin.js","sourceRoot":"","sources":["rollup-gjs-plugin.ts"],"names":[],"mappings":";;AASA,kCAuBC;AAhCD,qDAAmD;AAEnD,6CAA2C;AAE3C,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAM,SAAS,GAAG,IAAI,0BAAY,EAAE,CAAC;AACrC,6CAA6C;AAE7C,SAAwB,eAAe,CACrC,EAAE,iBAAiB,EAAE,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE;IAEnD,OAAO;QACL,IAAI,EAAE,WAAW;QAEjB,SAAS,EAAE;YACT,sFAAsF;YACtF,KAAK,EAAE,KAAK;YACZ,OAAO,CAAC,KAAa,EAAE,EAAU;gBAC/B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;oBACnB,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,IAAI,IAAI,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE;oBAClC,QAAQ,EAAE,EAAE;oBACZ,iBAAiB;iBAClB,CAAC,CAAC;gBACH,OAAO;oBACL,IAAI;iBACL,CAAC;YACJ,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAG,IAAA,0BAAY,EAAC,cAAc,CAAC,CAAC","sourcesContent":["import { createFilter } from '@rollup/pluginutils';\nimport type { Plugin } from 'rollup';\nimport { Preprocessor } from 'content-tag';\n\nconst PLUGIN_NAME = 'rollup-gjs-plugin';\n\nconst processor = new Preprocessor();\n// import { parse as pathParse } from 'path';\n\nexport default function rollupGjsPlugin(\n { inline_source_map } = { inline_source_map: true }\n): Plugin {\n return {\n name: PLUGIN_NAME,\n\n transform: {\n // Enforce running the gjs transform before any others like babel that expect valid JS\n order: 'pre',\n handler(input: string, id: string) {\n if (!gjsFilter(id)) {\n return null;\n }\n let code = processor.process(input, {\n filename: id,\n inline_source_map,\n });\n return {\n code,\n };\n },\n },\n };\n}\n\nconst gjsFilter = createFilter('**/*.g{j,t}s');\n"]}
1
+ {"version":3,"file":"rollup-gjs-plugin.js","sourceRoot":"","sources":["rollup-gjs-plugin.ts"],"names":[],"mappings":";;AASA,kCAqBC;AA9BD,qDAAmD;AAEnD,6CAA2C;AAE3C,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAExC,MAAM,SAAS,GAAG,IAAI,0BAAY,EAAE,CAAC;AACrC,6CAA6C;AAE7C,SAAwB,eAAe;IACrC,OAAO;QACL,IAAI,EAAE,WAAW;QAEjB,SAAS,EAAE;YACT,sFAAsF;YACtF,KAAK,EAAE,KAAK;YACZ,OAAO,CAAC,KAAa,EAAE,EAAU;gBAC/B,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;oBACnB,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,GAAG,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE;oBAC3C,QAAQ,EAAE,EAAE;iBACb,CAAC,CAAC;gBACH,OAAO;oBACL,IAAI;oBACJ,GAAG;iBACJ,CAAC;YACJ,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAG,IAAA,0BAAY,EAAC,cAAc,CAAC,CAAC","sourcesContent":["import { createFilter } from '@rollup/pluginutils';\nimport type { Plugin } from 'rollup';\nimport { Preprocessor } from 'content-tag';\n\nconst PLUGIN_NAME = 'rollup-gjs-plugin';\n\nconst processor = new Preprocessor();\n// import { parse as pathParse } from 'path';\n\nexport default function rollupGjsPlugin(): Plugin {\n return {\n name: PLUGIN_NAME,\n\n transform: {\n // Enforce running the gjs transform before any others like babel that expect valid JS\n order: 'pre',\n handler(input: string, id: string) {\n if (!gjsFilter(id)) {\n return null;\n }\n let { code, map } = processor.process(input, {\n filename: id,\n });\n return {\n code,\n map,\n };\n },\n },\n };\n}\n\nconst gjsFilter = createFilter('**/*.g{j,t}s');\n"]}
@@ -1,5 +1,6 @@
1
1
  import type { Plugin } from 'rollup';
2
- export default function keepAssets({ from, include, }: {
2
+ export default function keepAssets({ from, include, exports, }: {
3
3
  from: string;
4
4
  include: string[];
5
+ exports?: undefined | 'default' | '*';
5
6
  }): Plugin;
@@ -4,42 +4,77 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = keepAssets;
7
- const walk_sync_1 = __importDefault(require("walk-sync"));
8
- const fs_1 = require("fs");
9
- const path_1 = require("path");
10
7
  const minimatch_1 = __importDefault(require("minimatch"));
11
- function keepAssets({ from, include, }) {
8
+ const path_1 = require("path");
9
+ // randomly chosen, we're just looking to have high-entropy identifiers that
10
+ // won't collide with anyting else in the source
11
+ let counter = 11559;
12
+ function keepAssets({ from, include, exports, }) {
13
+ const marker = `__copy_asset_marker_${counter++}__`;
12
14
  return {
13
15
  name: 'copy-assets',
14
- // imports of assets should be left alone in the source code. This can cover
15
- // the case of .css as defined in the embroider v2 addon spec.
16
- async resolveId(source, importer, options) {
17
- const resolution = await this.resolve(source, importer, {
18
- skipSelf: true,
19
- ...options,
20
- });
21
- if (resolution &&
22
- importer &&
23
- include.some((pattern) => (0, minimatch_1.default)(resolution.id, pattern))) {
24
- return { id: (0, path_1.resolve)((0, path_1.dirname)(importer), source), external: 'relative' };
25
- }
26
- return resolution;
27
- },
28
- // the assets go into the output directory in the same relative locations as
29
- // in the input directory
30
- async generateBundle() {
31
- for (let name of (0, walk_sync_1.default)(from, {
32
- globs: include,
33
- directories: false,
34
- })) {
35
- this.addWatchFile((0, path_1.join)(from, name));
36
- this.emitFile({
16
+ transform(code, id) {
17
+ if (include.some((pattern) => (0, minimatch_1.default)(id, pattern))) {
18
+ let ref = this.emitFile({
37
19
  type: 'asset',
38
- fileName: name,
39
- source: (0, fs_1.readFileSync)((0, path_1.join)(from, name)),
20
+ fileName: (0, path_1.relative)(from, id),
21
+ source: code,
40
22
  });
23
+ if (exports === '*') {
24
+ return `export * from ${marker}("${ref}")`;
25
+ }
26
+ else if (exports === 'default') {
27
+ return `export default ${marker}("${ref}")`;
28
+ }
29
+ else {
30
+ // side-effect only
31
+ return `${marker}("${ref}")`;
32
+ }
41
33
  }
42
34
  },
35
+ renderChunk(code, chunk) {
36
+ const { getName, imports } = nameTracker(code, exports);
37
+ code = code.replace(new RegExp(`${marker}\\("([^"]+)"\\)`, 'g'), (_x, ref) => {
38
+ var _a;
39
+ let assetFileName = this.getFileName(ref);
40
+ let relativeName = './' + (0, path_1.relative)((0, path_1.dirname)(chunk.fileName), assetFileName);
41
+ return (_a = getName(relativeName)) !== null && _a !== void 0 ? _a : '';
42
+ });
43
+ return imports() + code;
44
+ },
43
45
  };
44
46
  }
47
+ function nameTracker(code, exports) {
48
+ let counter = 0;
49
+ let assets = new Map();
50
+ function getName(assetName) {
51
+ if (assets.has(assetName)) {
52
+ return assets.get(assetName);
53
+ }
54
+ if (!exports) {
55
+ assets.set(assetName, undefined);
56
+ return undefined;
57
+ }
58
+ while (true) {
59
+ let candidate = `_asset_${counter++}_`;
60
+ if (!code.includes(candidate)) {
61
+ assets.set(assetName, candidate);
62
+ return candidate;
63
+ }
64
+ }
65
+ }
66
+ function imports() {
67
+ return ([...assets]
68
+ .map(([assetName, importedName]) => {
69
+ if (importedName) {
70
+ return `import ${importedName} from "${assetName}"`;
71
+ }
72
+ else {
73
+ return `import "${assetName}"`;
74
+ }
75
+ })
76
+ .join('\n') + '\n');
77
+ }
78
+ return { getName, imports };
79
+ }
45
80
  //# sourceMappingURL=rollup-keep-assets.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"rollup-keep-assets.js","sourceRoot":"","sources":["rollup-keep-assets.ts"],"names":[],"mappings":";;;;;AAMA,6BA4CC;AAlDD,0DAAiC;AAEjC,2BAAkC;AAClC,+BAA8C;AAC9C,0DAAkC;AAElC,SAAwB,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,GAIR;IACC,OAAO;QACL,IAAI,EAAE,aAAa;QAEnB,4EAA4E;QAC5E,8DAA8D;QAC9D,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO;YACvC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE;gBACtD,QAAQ,EAAE,IAAI;gBACd,GAAG,OAAO;aACX,CAAC,CAAC;YACH,IACE,UAAU;gBACV,QAAQ;gBACR,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,mBAAS,EAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,EAC5D,CAAC;gBACD,OAAO,EAAE,EAAE,EAAE,IAAA,cAAO,EAAC,IAAA,cAAO,EAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC;YAC1E,CAAC;YACD,OAAO,UAAU,CAAC;QACpB,CAAC;QAED,4EAA4E;QAC5E,yBAAyB;QACzB,KAAK,CAAC,cAAc;YAClB,KAAK,IAAI,IAAI,IAAI,IAAA,mBAAQ,EAAC,IAAI,EAAE;gBAC9B,KAAK,EAAE,OAAO;gBACd,WAAW,EAAE,KAAK;aACnB,CAAC,EAAE,CAAC;gBACH,IAAI,CAAC,YAAY,CAAC,IAAA,WAAI,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;gBAEpC,IAAI,CAAC,QAAQ,CAAC;oBACZ,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,IAAA,iBAAY,EAAC,IAAA,WAAI,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBACvC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import walkSync from 'walk-sync';\nimport type { Plugin } from 'rollup';\nimport { readFileSync } from 'fs';\nimport { dirname, join, resolve } from 'path';\nimport minimatch from 'minimatch';\n\nexport default function keepAssets({\n from,\n include,\n}: {\n from: string;\n include: string[];\n}): Plugin {\n return {\n name: 'copy-assets',\n\n // imports of assets should be left alone in the source code. This can cover\n // the case of .css as defined in the embroider v2 addon spec.\n async resolveId(source, importer, options) {\n const resolution = await this.resolve(source, importer, {\n skipSelf: true,\n ...options,\n });\n if (\n resolution &&\n importer &&\n include.some((pattern) => minimatch(resolution.id, pattern))\n ) {\n return { id: resolve(dirname(importer), source), external: 'relative' };\n }\n return resolution;\n },\n\n // the assets go into the output directory in the same relative locations as\n // in the input directory\n async generateBundle() {\n for (let name of walkSync(from, {\n globs: include,\n directories: false,\n })) {\n this.addWatchFile(join(from, name));\n\n this.emitFile({\n type: 'asset',\n fileName: name,\n source: readFileSync(join(from, name)),\n });\n }\n },\n };\n}\n"]}
1
+ {"version":3,"file":"rollup-keep-assets.js","sourceRoot":"","sources":["rollup-keep-assets.ts"],"names":[],"mappings":";;;;;AAQA,6BA8CC;AArDD,0DAAkC;AAClC,+BAAyC;AAEzC,4EAA4E;AAC5E,gDAAgD;AAChD,IAAI,OAAO,GAAG,KAAK,CAAC;AAEpB,SAAwB,UAAU,CAAC,EACjC,IAAI,EACJ,OAAO,EACP,OAAO,GAKR;IACC,MAAM,MAAM,GAAG,uBAAuB,OAAO,EAAE,IAAI,CAAC;IAEpD,OAAO;QACL,IAAI,EAAE,aAAa;QAEnB,SAAS,CAAC,IAAY,EAAE,EAAU;YAChC,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,mBAAS,EAAC,EAAE,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC;gBACtD,IAAI,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC;oBACtB,IAAI,EAAE,OAAO;oBACb,QAAQ,EAAE,IAAA,eAAQ,EAAC,IAAI,EAAE,EAAE,CAAC;oBAC5B,MAAM,EAAE,IAAI;iBACb,CAAC,CAAC;gBACH,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;oBACpB,OAAO,iBAAiB,MAAM,KAAK,GAAG,IAAI,CAAC;gBAC7C,CAAC;qBAAM,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;oBACjC,OAAO,kBAAkB,MAAM,KAAK,GAAG,IAAI,CAAC;gBAC9C,CAAC;qBAAM,CAAC;oBACN,mBAAmB;oBACnB,OAAO,GAAG,MAAM,KAA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C,EAAE,CAAC;gBAC9B,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;gBACjC,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC;IAED,SAAS,OAAO;QACd,OAAO,CACL,CAAC,GAAG,MAAM,CAAC;aACR,GAAG,CAAC,CAAC,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,EAAE;YACjC,IAAI,YAAY,EAAE,CAAC;gBACjB,OAAO,UAAU,YAAY,UAAU,SAAS,GAAG,CAAC;YACtD,CAAC;iBAAM,CAAC;gBACN,OAAO,WAAW,SAAS,GAAG,CAAC;YACjC,CAAC;QACH,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CACrB,CAAC;IACJ,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC;AAC9B,CAAC","sourcesContent":["import type { Plugin } from 'rollup';\nimport minimatch from 'minimatch';\nimport { dirname, relative } from 'path';\n\n// randomly chosen, we're just looking to have high-entropy identifiers that\n// won't collide with anyting else in the source\nlet counter = 11559;\n\nexport default function keepAssets({\n from,\n include,\n exports,\n}: {\n from: string;\n include: string[];\n exports?: undefined | 'default' | '*';\n}): Plugin {\n const marker = `__copy_asset_marker_${counter++}__`;\n\n return {\n name: 'copy-assets',\n\n transform(code: string, id: string) {\n if (include.some((pattern) => minimatch(id, pattern))) {\n let ref = this.emitFile({\n type: 'asset',\n fileName: relative(from, id),\n source: code,\n });\n if (exports === '*') {\n return `export * from ${marker}(\"${ref}\")`;\n } else if (exports === 'default') {\n return `export default ${marker}(\"${ref}\")`;\n } else {\n // side-effect only\n return `${marker}(\"${ref}\")`;\n }\n }\n },\n renderChunk(code, chunk) {\n const { getName, imports } = nameTracker(code, exports);\n\n code = code.replace(\n new RegExp(`${marker}\\\\(\"([^\"]+)\"\\\\)`, 'g'),\n (_x, ref) => {\n let assetFileName = this.getFileName(ref);\n let relativeName =\n './' + relative(dirname(chunk.fileName), assetFileName);\n return getName(relativeName) ?? '';\n }\n );\n return imports() + code;\n },\n };\n}\n\nfunction nameTracker(code: string, exports: undefined | 'default' | '*') {\n let counter = 0;\n let assets = new Map<string, string | undefined>();\n\n function getName(assetName: string): string | undefined {\n if (assets.has(assetName)) {\n return assets.get(assetName)!;\n }\n if (!exports) {\n assets.set(assetName, undefined);\n return undefined;\n }\n while (true) {\n let candidate = `_asset_${counter++}_`;\n if (!code.includes(candidate)) {\n assets.set(assetName, candidate);\n return candidate;\n }\n }\n }\n\n function imports() {\n return (\n [...assets]\n .map(([assetName, importedName]) => {\n if (importedName) {\n return `import ${importedName} from \"${assetName}\"`;\n } else {\n return `import \"${assetName}\"`;\n }\n })\n .join('\\n') + '\\n'\n );\n }\n\n return { getName, imports };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"rollup-public-entrypoints.js","sourceRoot":"","sources":["rollup-public-entrypoints.ts"],"names":[],"mappings":";;;;;AAUA,oCAkEC;AA5ED,0DAAiC;AACjC,gDAAwB;AACxB,0DAAkC;AAIlC,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,QAAQ,CAAC,OAAO,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;AACpE,CAAC;AAED,SAAwB,iBAAiB,CAAC,IAIzC;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;gBACvE,MAAM,EAAE,IAAI,CAAC,OAAO;aACrB,CAAC,CAAC;YAEH,KAAK,IAAI,IAAI,IAAI,OAAO,EAAE,CAAC;gBACzB,IAAI,CAAC,YAAY,CAAC,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,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AAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,OAAiB,EAAE,QAAgB;IACzD,IAAI,KAAK,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,MAAM,CAAC;IAE9C,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzB,IAAI,qBAAqB,GAAG,cAAI,CAAC,IAAI,CACnC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EACtB,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAC7C,CAAC;IAEF,IAAI,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1C,IAAA,mBAAS,EAAC,KAAK,EAAE,qBAAqB,CAAC,CACxC,CAAC;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(/(?<!\\.d)\\.ts|\\.hbs|\\.gts|\\.gjs$/, '.js');\n}\n\nexport default function publicEntrypoints(args: {\n srcDir: string;\n include: string[];\n exclude?: 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 ignore: args.exclude,\n });\n\n for (let name of matches) {\n this.addWatchFile(path.join(args.srcDir, name));\n\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"]}
1
+ {"version":3,"file":"rollup-public-entrypoints.js","sourceRoot":"","sources":["rollup-public-entrypoints.ts"],"names":[],"mappings":";;;;;AAUA,oCAkEC;AA5ED,0DAAiC;AACjC,gDAAwB;AACxB,0DAAkC;AAIlC,SAAS,gBAAgB,CAAC,QAAgB;IACxC,OAAO,QAAQ,CAAC,OAAO,CAAC,iCAAiC,EAAE,KAAK,CAAC,CAAC;AACpE,CAAC;AAED,SAAwB,iBAAiB,CAAC,IAIzC;IACC,OAAO;QACL,IAAI,EAAE,eAAe;QAErB,KAAK,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BAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACpD,IAAA,mBAAS,EAAC,cAAc,EAAE,OAAO,CAAC,CACnC,CAAC;gBAEF,IAAI,aAAa,IAAI,iBAAiB,EAAE,CAAC;oBACvC,IAAI,CAAC,QAAQ,CAAC;wBACZ,IAAI,EAAE,OAAO;wBACb,EAAE,EAAE,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;wBAChC,QAAQ,EAAE,cAAc;qBACzB,CAAC,CAAC;oBAEH,SAAS;gBACX,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,cAAc,CAAC,OAAiB,EAAE,QAAgB;IACzD,IAAI,KAAK,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,MAAM,CAAC;IAE9C,IAAI,CAAC,KAAK;QAAE,OAAO,KAAK,CAAC;IAEzB,IAAI,qBAAqB,GAAG,cAAI,CAAC,IAAI,CACnC,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,EACtB,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAC7C,CAAC;IAEF,IAAI,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAC1C,IAAA,mBAAS,EAAC,KAAK,EAAE,qBAAqB,CAAC,CACxC,CAAC;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(/(?<!\\.d)\\.ts|\\.hbs|\\.gts|\\.gjs$/, '.js');\n}\n\nexport default function publicEntrypoints(args: {\n srcDir: string;\n include: string[];\n exclude?: string[];\n}): Plugin {\n return {\n name: 'addon-modules',\n\n async buildStart() {\n let matches = walkSync(args.srcDir, {\n globs: [...args.include, '**/*.hbs', '**/*.ts', '**/*.gts', '**/*.gjs'],\n ignore: args.exclude,\n });\n\n for (let name of matches) {\n this.addWatchFile(path.join(args.srcDir, name));\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
@@ -15,11 +15,9 @@ export declare class Addon {
15
15
  exclude?: string[];
16
16
  }): Plugin<any>;
17
17
  hbs(options?: {}): Plugin<any>;
18
- gjs(options?: {
19
- inline_source_map: boolean;
20
- }): Plugin<any>;
18
+ gjs(): Plugin<any>;
21
19
  clean(): Plugin<any>;
22
- keepAssets(patterns: string[]): Plugin<any>;
20
+ keepAssets(patterns: string[], exports?: undefined | 'default' | '*'): Plugin<any>;
23
21
  output(): {
24
22
  dir: string;
25
23
  entryFileNames: string;
package/src/rollup.js CHANGED
@@ -61,8 +61,8 @@ class Addon {
61
61
  hbs(options = {}) {
62
62
  return (0, rollup_hbs_plugin_1.default)(options);
63
63
  }
64
- gjs(options) {
65
- return (0, rollup_gjs_plugin_1.default)(options);
64
+ gjs() {
65
+ return (0, rollup_gjs_plugin_1.default)();
66
66
  }
67
67
  // this does incremental updates to the dist files and also deletes files that are not part of the generated bundle
68
68
  // rollup already supports incremental transforms of files,
@@ -74,10 +74,11 @@ class Addon {
74
74
  // to leave those imports alone and to make sure the corresponding .css files
75
75
  // are kept in the same relative locations in the destDir as they were in the
76
76
  // srcDir.
77
- keepAssets(patterns) {
77
+ keepAssets(patterns, exports) {
78
78
  return (0, rollup_keep_assets_1.default)({
79
79
  from: __classPrivateFieldGet(this, _Addon_srcDir, "f"),
80
80
  include: patterns,
81
+ exports: exports,
81
82
  });
82
83
  }
83
84
  // This is the default `output` configuration you should pass to rollup. We're
package/src/rollup.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rollup.js","sourceRoot":"","sources":["rollup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,4EAAqD;AACrD,4EAAqD;AACrD,4FAA2E;AAC3E,kFAAiE;AACjE,8EAA6D;AAC7D,4FAAsE;AACtE,kFAGgC;AAChC,4FAA+D;AAG/D,MAAa,KAAK;IAIhB,YAAY,SAAgD,EAAE;;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,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,EAAE;IACF,wFAAwF;IACxF,qDAAqD;IACrD,qFAAqF;IACrF,sBAAsB;IACtB,MAAM;QACJ,OAAO;YACL,GAAG,EAAE,uBAAA,IAAI,sBAAS;YAClB,cAAc,EAAE,QAAQ;YACxB,wBAAwB,EAAE,CAAC;YAC3B,MAAM,EAAE,IAAI;YACZ,sBAAsB,EAAE,KAAK;YAC7B,SAAS,EAAE,IAAI;SAChB,CAAC;IACJ,CAAC;IAED,YAAY;QACV,OAAO,IAAA,mCAAY,GAAE,CAAC;IACxB,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,IAA0B;QACnD,OAAO,IAAA,8BAAY,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAjGD,sBAiGC","sourcesContent":["import { default as hbs } from './rollup-hbs-plugin';\nimport { default as gjs } from './rollup-gjs-plugin';\nimport { default as publicEntrypoints } from './rollup-public-entrypoints';\nimport { default as appReexports } from './rollup-app-reexports';\nimport { default as keepAssets } from './rollup-keep-assets';\nimport { default as dependencies } from './rollup-addon-dependencies';\nimport {\n default as publicAssets,\n type PublicAssetsOptions,\n} from './rollup-public-assets';\nimport { default as clean } from './rollup-incremental-plugin';\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: {\n mapFilename?: (fileName: string) => string;\n exports?: (filename: string) => string[] | string | undefined;\n exclude?: string[];\n } = {}\n ): Plugin {\n return appReexports({\n from: this.#srcDir,\n to: this.#destDir,\n include: patterns,\n mapFilename: opts.mapFilename,\n exports: opts.exports,\n exclude: opts.exclude,\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[], opts: { exclude?: string[] } = {}) {\n return publicEntrypoints({\n srcDir: this.#srcDir,\n include: patterns,\n exclude: opts.exclude,\n });\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(options = {}) {\n return hbs(options);\n }\n\n gjs(options?: { inline_source_map: boolean }) {\n return gjs(options);\n }\n\n // this does incremental updates to the dist files and also deletes files that are not part of the generated bundle\n // rollup already supports incremental transforms of files,\n // this extends it to the dist files\n clean() {\n return clean();\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 entryFileNames: '[name]',\n experimentalMinChunkSize: 0,\n format: 'es',\n hoistTransitiveImports: false,\n sourcemap: true,\n };\n }\n\n dependencies() {\n return dependencies();\n }\n\n publicAssets(path: string, opts?: PublicAssetsOptions) {\n return publicAssets(path, opts);\n }\n}\n"]}
1
+ {"version":3,"file":"rollup.js","sourceRoot":"","sources":["rollup.ts"],"names":[],"mappings":";;;;;;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C,KAAK;QACH,OAAO,IAAA,mCAAK,GAAE,CAAC;IACjB,CAAC;IAED,4EAA4E;IAC5E,6EAA6E;IAC7E,6EAA6E;IAC7E,UAAU;IACV,UAAU,CAAC,QAAkB,EAAE,OAAqC;QAClE,OAAO,IAAA,4BAAU,EAAC;YAChB,IAAI,EAAE,uBAAA,IAAI,qBAAQ;YAClB,OAAO,EAAE,QAAQ;YACjB,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;IACL,CAAC;IAED,8EAA8E;IAC9E,2EAA2E;IAC3E,4EAA4E;IAC5E,UAAU;IACV,EAAE;IACF,wFAAwF;IACxF,qDAAqD;IACrD,qFAAqF;IACrF,sBAAsB;IACtB,MAAM;QACJ,OAAO;YACL,GAAG,EAAE,uBAAA,IAAI,sBAAS;YAClB,cAAc,EAAE,QAAQ;YACxB,wBAAwB,EAAE,CAAC;YAC3B,MAAM,EAAE,IAAI;YACZ,sBAAsB,EAAE,KAAK;YAC7B,SAAS,EAAE,IAAI;SAChB,CAAC;IACJ,CAAC;IAED,YAAY;QACV,OAAO,IAAA,mCAAY,GAAE,CAAC;IACxB,CAAC;IAED,YAAY,CAAC,IAAY,EAAE,IAA0B;QACnD,OAAO,IAAA,8BAAY,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AAlGD,sBAkGC","sourcesContent":["import { default as hbs } from './rollup-hbs-plugin';\nimport { default as gjs } from './rollup-gjs-plugin';\nimport { default as publicEntrypoints } from './rollup-public-entrypoints';\nimport { default as appReexports } from './rollup-app-reexports';\nimport { default as keepAssets } from './rollup-keep-assets';\nimport { default as dependencies } from './rollup-addon-dependencies';\nimport {\n default as publicAssets,\n type PublicAssetsOptions,\n} from './rollup-public-assets';\nimport { default as clean } from './rollup-incremental-plugin';\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: {\n mapFilename?: (fileName: string) => string;\n exports?: (filename: string) => string[] | string | undefined;\n exclude?: string[];\n } = {}\n ): Plugin {\n return appReexports({\n from: this.#srcDir,\n to: this.#destDir,\n include: patterns,\n mapFilename: opts.mapFilename,\n exports: opts.exports,\n exclude: opts.exclude,\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[], opts: { exclude?: string[] } = {}) {\n return publicEntrypoints({\n srcDir: this.#srcDir,\n include: patterns,\n exclude: opts.exclude,\n });\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(options = {}) {\n return hbs(options);\n }\n\n gjs() {\n return gjs();\n }\n\n // this does incremental updates to the dist files and also deletes files that are not part of the generated bundle\n // rollup already supports incremental transforms of files,\n // this extends it to the dist files\n clean() {\n return clean();\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[], exports?: undefined | 'default' | '*') {\n return keepAssets({\n from: this.#srcDir,\n include: patterns,\n exports: exports,\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 entryFileNames: '[name]',\n experimentalMinChunkSize: 0,\n format: 'es',\n hoistTransitiveImports: false,\n sourcemap: true,\n };\n }\n\n dependencies() {\n return dependencies();\n }\n\n publicAssets(path: string, opts?: PublicAssetsOptions) {\n return publicAssets(path, opts);\n }\n}\n"]}