@embroider/addon-dev 4.3.0 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ For a guide on porting a V1 addon to V2, see https://github.com/embroider-build/
20
20
 
21
21
  ### addon.publicAssets(path <required>, options)
22
22
 
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
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
25
  ## addon-dev command
26
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@embroider/addon-dev",
3
- "version": "4.3.0",
3
+ "version": "4.3.1",
4
4
  "description": "Utilities for addon authors",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,7 +32,8 @@ function publicAssets(path, opts) {
32
32
  });
33
33
  const publicAssets = filenames.reduce((acc, v) => {
34
34
  var _a;
35
- acc[`./${path}/${v}`] = (0, posix_1.resolve)('/' + (0, posix_1.join)((_a = opts === null || opts === void 0 ? void 0 : opts.namespace) !== null && _a !== void 0 ? _a : pkg.name, path, v));
35
+ const namespace = (_a = opts === null || opts === void 0 ? void 0 : opts.namespace) !== null && _a !== void 0 ? _a : (0, posix_1.join)(pkg.name, path);
36
+ acc[`./${path}/${v}`] = (0, posix_1.resolve)('/' + (0, posix_1.join)(namespace, v));
36
37
  return acc;
37
38
  }, {});
38
39
  let originalPublicAssets = (_a = pkg['ember-addon']) === null || _a === void 0 ? void 0 : _a['public-assets'];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Z,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;YAExE,IAAI,UAAU,EAAE;gBACd,GAAG,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,aAAa,CAAC,EAAE;oBACzD,eAAe,EAAE,YAAY;iBAC9B,CAAC,CAAC;gBAEH,IAAA,wBAAa,EAAC,cAAc,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;aACnD;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AA/CD,+BA+CC","sourcesContent":["import { readJsonSync, writeJsonSync } from 'fs-extra';\nimport walkSync from 'walk-sync';\nimport type { Plugin } from 'rollup';\nimport { resolve, join } from 'path/posix';\n\nexport interface PublicAssetsOptions {\n /**\n * glob pattern passed to `walkSync.include` to pick files\n */\n include?: string[];\n\n /**\n * glob pattern passed to `walkSync.ignore` to exclude files\n */\n exclude?: string[];\n\n /**\n * namespace to expose files\n */\n namespace?: string;\n}\n\n/**\n * A rollup plugin to expose a folder of assets\n *\n * @param path - the public folder that you want to add as public assets\n * @returns\n */\nexport default function publicAssets(\n path: string,\n opts?: PublicAssetsOptions\n): Plugin {\n const includeGlobPatterns = opts?.include;\n const excludedGlobPatterns = opts?.exclude || [];\n\n return {\n name: 'public-assets-bundler',\n\n // Prior to https://github.com/rollup/rollup/pull/5270, we cannot call this\n // from within `generateBundle`\n buildStart() {\n this.addWatchFile(path);\n },\n\n generateBundle() {\n let pkg = readJsonSync('package.json');\n const filenames = walkSync(path, {\n directories: false,\n globs: includeGlobPatterns,\n ignore: excludedGlobPatterns,\n });\n const publicAssets: Record<string, string> = filenames.reduce(\n (acc: Record<string, string>, v): Record<string, string> => {\n acc[`./${path}/${v}`] = resolve(\n '/' + join(opts?.namespace ?? pkg.name, path, v)\n );\n return acc;\n },\n {}\n );\n\n let originalPublicAssets = pkg['ember-addon']?.['public-assets'];\n\n let hasChanges =\n JSON.stringify(originalPublicAssets) !== JSON.stringify(publicAssets);\n\n if (hasChanges) {\n pkg['ember-addon'] = Object.assign({}, pkg['ember-addon'], {\n 'public-assets': publicAssets,\n });\n\n writeJsonSync('package.json', pkg, { spaces: 2 });\n }\n },\n };\n}\n"]}
1
+ {"version":3,"file":"rollup-public-assets.js","sourceRoot":"","sources":["rollup-public-assets.ts"],"names":[],"mappings":";;;;;AAAA,uCAAuD;AACvD,0DAAiC;AAEjC,sCAA2C;AAmB3C;;;;;GAKG;AACH,SAAwB,YAAY,CAClC,IAAY,EACZ,IAA0B;IAE1B,MAAM,mBAAmB,GAAG,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,CAAC;IAC1C,MAAM,oBAAoB,GAAG,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,KAAI,EAAE,CAAC;IAEjD,OAAO;QACL,IAAI,EAAE,uBAAuB;QAE7B,2EAA2E;QAC3E,+BAA+B;QAC/B,UAAU;YACR,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC;QAED,cAAc;;YACZ,IAAI,GAAG,GAAG,IAAA,uBAAY,EAAC,cAAc,CAAC,CAAC;YACvC,MAAM,SAAS,GAAG,IAAA,mBAAQ,EAAC,IAAI,EAAE;gBAC/B,WAAW,EAAE,KAAK;gBAClB,KAAK,EAAE,mBAAmB;gBAC1B,MAAM,EAAE,oBAAoB;aAC7B,CAAC,CAAC;YACH,MAAM,YAAY,GAA2B,SAAS,CAAC,MAAM,CAC3D,CAAC,GAA2B,EAAE,CAAC,EAA0B,EAAE;;gBACzD,MAAM,SAAS,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,mCAAI,IAAA,YAAI,EAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBAE1D,GAAG,CAAC,KAAK,IAAI,IAAI,CAAC,EAAE,CAAC,GAAG,IAAA,eAAO,EAAC,GAAG,GAAG,IAAA,YAAI,EAAC,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC;gBAC1D,OAAO,GAAG,CAAC;YACb,CAAC,EACD,EAAE,CACH,CAAC;YAEF,IAAI,oBAAoB,GAAG,MAAA,GAAG,CAAC,aAAa,CAAC,0CAAG,eAAe,CAAC,CAAC;YAEjE,IAAI,UAAU,GACZ,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC;YAExE,IAAI,UAAU,EAAE;gBACd,GAAG,CAAC,aAAa,CAAC,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,CAAC,aAAa,CAAC,EAAE;oBACzD,eAAe,EAAE,YAAY;iBAC9B,CAAC,CAAC;gBAEH,IAAA,wBAAa,EAAC,cAAc,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;aACnD;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AA/CD,+BA+CC","sourcesContent":["import { readJsonSync, writeJsonSync } from 'fs-extra';\nimport walkSync from 'walk-sync';\nimport type { Plugin } from 'rollup';\nimport { resolve, join } from 'path/posix';\n\nexport interface PublicAssetsOptions {\n /**\n * glob pattern passed to `walkSync.include` to pick files\n */\n include?: string[];\n\n /**\n * glob pattern passed to `walkSync.ignore` to exclude files\n */\n exclude?: string[];\n\n /**\n * namespace to expose files\n */\n namespace?: string;\n}\n\n/**\n * A rollup plugin to expose a folder of assets\n *\n * @param path - the public folder that you want to add as public assets\n * @returns\n */\nexport default function publicAssets(\n path: string,\n opts?: PublicAssetsOptions\n): Plugin {\n const includeGlobPatterns = opts?.include;\n const excludedGlobPatterns = opts?.exclude || [];\n\n return {\n name: 'public-assets-bundler',\n\n // Prior to https://github.com/rollup/rollup/pull/5270, we cannot call this\n // from within `generateBundle`\n buildStart() {\n this.addWatchFile(path);\n },\n\n generateBundle() {\n let pkg = readJsonSync('package.json');\n const filenames = walkSync(path, {\n directories: false,\n globs: includeGlobPatterns,\n ignore: excludedGlobPatterns,\n });\n const publicAssets: Record<string, string> = filenames.reduce(\n (acc: Record<string, string>, v): Record<string, string> => {\n const namespace = opts?.namespace ?? join(pkg.name, path);\n\n acc[`./${path}/${v}`] = resolve('/' + join(namespace, v));\n return acc;\n },\n {}\n );\n\n let originalPublicAssets = pkg['ember-addon']?.['public-assets'];\n\n let hasChanges =\n JSON.stringify(originalPublicAssets) !== JSON.stringify(publicAssets);\n\n if (hasChanges) {\n pkg['ember-addon'] = Object.assign({}, pkg['ember-addon'], {\n 'public-assets': publicAssets,\n });\n\n writeJsonSync('package.json', pkg, { spaces: 2 });\n }\n },\n };\n}\n"]}