@embroider/addon-dev 8.0.1-unstable.f40acf0 → 8.0.1-unstable.f9c81e9

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": "8.0.1-unstable.f40acf0",
3
+ "version": "8.0.1-unstable.f9c81e9",
4
4
  "description": "Utilities for addon authors",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,11 +32,12 @@
32
32
  },
33
33
  "release-plan": {
34
34
  "semverIncrementAs": {
35
- "major": "premajor",
35
+ "major": "prerelease",
36
36
  "minor": "prerelease",
37
37
  "patch": "prerelease"
38
38
  },
39
- "semverIncrementTag": "alpha"
39
+ "semverIncrementTag": "alpha",
40
+ "publishTag": "alpha"
40
41
  },
41
42
  "dependencies": {
42
43
  "@rollup/pluginutils": "^5.1.0",
@@ -47,7 +48,7 @@
47
48
  "rollup-plugin-copy-assets": "^2.0.3",
48
49
  "walk-sync": "^3.0.0",
49
50
  "yargs": "^17.0.1",
50
- "@embroider/core": "^4.0.1-unstable.f40acf0"
51
+ "@embroider/core": "^4.0.1-unstable.f9c81e9"
51
52
  },
52
53
  "devDependencies": {
53
54
  "@glimmer/syntax": "^0.84.2",
@@ -1,5 +1,2 @@
1
- export default function rollupDeclarationsPlugin(declarationsDir: string): {
2
- name: string;
3
- buildStart: () => void;
4
- writeBundle: () => Promise<void>;
5
- };
1
+ import type { Plugin } from 'rollup';
2
+ export default function rollupDeclarationsPlugin(declarationsDir: string): Plugin;
@@ -7,17 +7,36 @@ exports.default = rollupDeclarationsPlugin;
7
7
  const execa_1 = __importDefault(require("execa"));
8
8
  const walk_sync_1 = __importDefault(require("walk-sync"));
9
9
  const promises_1 = require("fs/promises");
10
+ const fs_1 = require("fs");
10
11
  function rollupDeclarationsPlugin(declarationsDir) {
11
12
  let glintPromise;
12
13
  return {
13
- name: 'glint-dts',
14
- buildStart: () => {
14
+ name: 'declarations',
15
+ buildStart() {
15
16
  const runGlint = async () => {
16
- await (0, execa_1.default)('glint', ['--declaration'], {
17
+ let { exitCode, escapedCommand } = await (0, execa_1.default)('glint', ['--declaration'], {
18
+ // using stdio: inherit is the only way to retain color output from the
19
+ // underlying tsc process.
20
+ // However, the viewer of the error will not know which plugin it comes from.
21
+ // So that's why we have the additional logging below
17
22
  stdio: 'inherit',
18
23
  preferLocal: true,
24
+ // Without reject, execa would throw a hard exception
25
+ reject: false,
19
26
  });
27
+ if (exitCode > 0) {
28
+ let msg = `Failed to generate declarations via \`${escapedCommand}\``;
29
+ if (this.meta.watchMode) {
30
+ this.warn(msg);
31
+ }
32
+ else {
33
+ this.error(msg);
34
+ }
35
+ }
20
36
  await fixDeclarationsInMatchingFiles(declarationsDir);
37
+ if (exitCode === 0) {
38
+ this.info(`\`${escapedCommand}\` succeeded`);
39
+ }
21
40
  };
22
41
  // We just kick off glint here early in the rollup process, without making rollup wait for this to finish, by not returning the promise
23
42
  // The output of this is not relevant to further stages of the rollup build, this is just happening in parallel to other rollup compilation
@@ -28,6 +47,11 @@ function rollupDeclarationsPlugin(declarationsDir) {
28
47
  };
29
48
  }
30
49
  async function fixDeclarationsInMatchingFiles(dir) {
50
+ // can't fix what doesn't exist
51
+ // (happens when glint errors and doesn't output a ${dir} directory
52
+ if (!(0, fs_1.existsSync)(dir)) {
53
+ return;
54
+ }
31
55
  const dtsFiles = (0, walk_sync_1.default)(dir, {
32
56
  globs: ['**/*.d.ts'],
33
57
  directories: false,
@@ -1 +1 @@
1
- {"version":3,"file":"rollup-declarations.js","sourceRoot":"","sources":["rollup-declarations.ts"],"names":[],"mappings":";;;;;AAIA,2CAuBC;AA3BD,kDAA0B;AAC1B,0DAAiC;AACjC,0CAAkD;AAElD,SAAwB,wBAAwB,CAAC,eAAuB;IACtE,IAAI,YAA2B,CAAC;IAEhC,OAAO;QACL,IAAI,EAAE,WAAW;QACjB,UAAU,EAAE,GAAG,EAAE;Y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-sync';\nimport { readFile, writeFile } from 'fs/promises';\n\nexport default function rollupDeclarationsPlugin(declarationsDir: string) {\n let glintPromise: Promise<void>;\n\n return {\n name: 'glint-dts',\n buildStart: () => {\n const runGlint = async () => {\n await execa('glint', ['--declaration'], {\n stdio: 'inherit',\n preferLocal: true,\n });\n\n await fixDeclarationsInMatchingFiles(declarationsDir);\n };\n\n // We just kick off glint here early in the rollup process, without making rollup wait for this to finish, by not returning the promise\n // The output of this is not relevant to further stages of the rollup build, this is just happening in parallel to other rollup compilation\n glintPromise = runGlint();\n },\n\n // Make rollup wait for glint to have finished before calling the build job done\n writeBundle: () => glintPromise,\n };\n}\n\nasync function fixDeclarationsInMatchingFiles(dir: string) {\n const dtsFiles = walkSync(dir, {\n globs: ['**/*.d.ts'],\n directories: false,\n includeBasePath: true,\n });\n\n return Promise.all(\n dtsFiles.map(async (file) => {\n const content = await readFile(file, { encoding: 'utf8' });\n\n await writeFile(file, fixDeclarations(content));\n })\n );\n}\n\n// Strip any .gts extension from imports in d.ts files, as these won't resolve. See https://github.com/typed-ember/glint/issues/628\n// Once Glint v2 is available, this shouldn't be needed anymore.\nfunction fixDeclarations(content: string) {\n return content\n .replace(/from\\s+'([^']+)\\.gts'/g, `from '$1'`)\n .replace(/from\\s+\"([^\"]+)\\.gts\"/g, `from '$1'`)\n .replace(/import\\(\"([^\"]+)\\.gts\"\\)/g, `import('$1')`)\n .replace(/import\\('([^']+)\\.gts'\\)/g, `import('$1')`);\n}\n"]}
1
+ {"version":3,"file":"rollup-declarations.js","sourceRoot":"","sources":["rollup-declarations.ts"],"names":[],"mappings":";;;;;AAMA,2CAgDC;AArDD,kDAA0B;AAC1B,0DAAiC;AACjC,0CAAkD;AAClD,2BAAgC;AAEhC,SAAwB,wBAAwB,CAC9C,eAAuB;IAEvB,IAAI,YAA2B,CAAC;IAEhC,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,UAAU;YACR,MAAM,QAAQ,GAAG,KAAK,IAAI,EAAE;gBAC1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IAEH,OAAO,OAAO,CAAC,GAAG,CAChB,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAC1B,MAAM,OAAO,GAAG,MAAM,IAAA,mBAAQ,EAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QAE3D,MAAM,IAAA,oBAAS,EAAC,IAAI,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC,CAAC;IAClD,CAAC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,mIAAmI;AACnI,gEAAgE;AAChE,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO,OAAO;SACX,OAAO,CAAC,wBAAwB,EAAE,WAAW,CAAC;SAC9C,OAAO,CAAC,wBAAwB,EAAE,WAAW,CAAC;SAC9C,OAAO,CAAC,2BAA2B,EAAE,cAAc,CAAC;SACpD,OAAO,CAAC,2BAA2B,EAAE,cAAc,CAAC,CAAC;AAC1D,CAAC","sourcesContent":["import type { Plugin } from 'rollup';\nimport execa from 'execa';\nimport walkSync from 'walk-sync';\nimport { readFile, writeFile } from 'fs/promises';\nimport { existsSync } from 'fs';\n\nexport default function rollupDeclarationsPlugin(\n declarationsDir: string\n): Plugin {\n let glintPromise: Promise<void>;\n\n return {\n name: 'declarations',\n buildStart() {\n const runGlint = async () => {\n let { exitCode, escapedCommand } = await execa(\n 'glint',\n ['--declaration'],\n {\n // using stdio: inherit is the only way to retain color output from the\n // underlying tsc process.\n // However, the viewer of the error will not know which plugin it comes from.\n // So that's why we have the additional logging below\n stdio: 'inherit',\n preferLocal: true,\n // Without reject, execa would throw a hard exception\n reject: false,\n }\n );\n\n if (exitCode > 0) {\n let msg = `Failed to generate declarations via \\`${escapedCommand}\\``;\n\n if (this.meta.watchMode) {\n this.warn(msg);\n } else {\n this.error(msg);\n }\n }\n\n await fixDeclarationsInMatchingFiles(declarationsDir);\n if (exitCode === 0) {\n this.info(`\\`${escapedCommand}\\` succeeded`);\n }\n };\n\n // We just kick off glint here early in the rollup process, without making rollup wait for this to finish, by not returning the promise\n // The output of this is not relevant to further stages of the rollup build, this is just happening in parallel to other rollup compilation\n glintPromise = runGlint();\n },\n\n // Make rollup wait for glint to have finished before calling the build job done\n writeBundle: () => glintPromise,\n };\n}\n\nasync function fixDeclarationsInMatchingFiles(dir: string) {\n // can't fix what doesn't exist\n // (happens when glint errors and doesn't output a ${dir} directory\n if (!existsSync(dir)) {\n return;\n }\n\n const dtsFiles = walkSync(dir, {\n globs: ['**/*.d.ts'],\n directories: false,\n includeBasePath: true,\n });\n\n return Promise.all(\n dtsFiles.map(async (file) => {\n const content = await readFile(file, { encoding: 'utf8' });\n\n await writeFile(file, fixDeclarations(content));\n })\n );\n}\n\n// Strip any .gts extension from imports in d.ts files, as these won't resolve. See https://github.com/typed-ember/glint/issues/628\n// Once Glint v2 is available, this shouldn't be needed anymore.\nfunction fixDeclarations(content: string) {\n return content\n .replace(/from\\s+'([^']+)\\.gts'/g, `from '$1'`)\n .replace(/from\\s+\"([^\"]+)\\.gts\"/g, `from '$1'`)\n .replace(/import\\(\"([^\"]+)\\.gts\"\\)/g, `import('$1')`)\n .replace(/import\\('([^']+)\\.gts'\\)/g, `import('$1')`);\n}\n"]}
@@ -25,6 +25,11 @@ function rollupGjsPlugin() {
25
25
  };
26
26
  },
27
27
  },
28
+ onLog(_level, log) {
29
+ if (log.code === 'EVAL' && gjsFilter(log.id)) {
30
+ return false;
31
+ }
32
+ },
28
33
  };
29
34
  }
30
35
  const gjsFilter = (0, pluginutils_1.createFilter)('**/*.g{j,t}s');
@@ -1 +1 @@
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
+ {"version":3,"file":"rollup-gjs-plugin.js","sourceRoot":"","sources":["rollup-gjs-plugin.ts"],"names":[],"mappings":";;AASA,kCA2BC;AApCD,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;QAED,KAAK,CAAC,MAAgB,EAAE,GAAc;YACpC,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;gBAC7C,OAAO,KAAK,CAAC;YACf,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,SAAS,GAAG,IAAA,0BAAY,EAAC,cAAc,CAAC,CAAC","sourcesContent":["import { createFilter } from '@rollup/pluginutils';\nimport type { LogLevel, Plugin, RollupLog } 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 onLog(_level: LogLevel, log: RollupLog): boolean | void {\n if (log.code === 'EVAL' && gjsFilter(log.id)) {\n return false;\n }\n },\n };\n}\n\nconst gjsFilter = createFilter('**/*.g{j,t}s');\n"]}
package/src/rollup.d.ts CHANGED
@@ -28,9 +28,5 @@ export declare class Addon {
28
28
  };
29
29
  dependencies(): Plugin<any>;
30
30
  publicAssets(path: string, opts?: PublicAssetsOptions): Plugin<any>;
31
- declarations(path: string): {
32
- name: string;
33
- buildStart: () => void;
34
- writeBundle: () => Promise<void>;
35
- };
31
+ declarations(path: string): Plugin<any>;
36
32
  }