@embroider/addon-dev 8.3.0 → 8.4.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 +2 -2
- package/src/commands.d.ts +1 -0
- package/src/rollup-addon-dependencies.d.ts +1 -0
- package/src/rollup-app-reexports.d.ts +1 -0
- package/src/rollup-declarations.d.ts +1 -0
- package/src/rollup-declarations.js +28 -9
- package/src/rollup-declarations.js.map +1 -1
- package/src/rollup-gjs-plugin.d.ts +1 -0
- package/src/rollup-hbs-plugin.d.ts +1 -0
- package/src/rollup-incremental-plugin.d.ts +1 -0
- package/src/rollup-keep-assets.d.ts +1 -0
- package/src/rollup-public-assets.d.ts +1 -0
- package/src/rollup-public-assets.js +1 -1
- package/src/rollup-public-assets.js.map +1 -1
- package/src/rollup-public-entrypoints.d.ts +1 -0
- package/src/rollup.d.ts +1 -0
- package/src/template-colocation-plugin.d.ts +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/addon-dev",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.4.0",
|
|
4
4
|
"description": "Utilities for addon authors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"rollup-plugin-copy-assets": "^2.0.3",
|
|
41
41
|
"walk-sync": "^3.0.0",
|
|
42
42
|
"yargs": "^17.0.1",
|
|
43
|
-
"@embroider/core": "^4.
|
|
43
|
+
"@embroider/core": "^4.6.6"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@glimmer/syntax": "^0.94.9",
|
package/src/commands.d.ts
CHANGED
|
@@ -94,22 +94,41 @@ async function fixDeclarationsInMatchingFiles(dir) {
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
const dtsFiles = (0, walk_sync_1.default)(dir, {
|
|
97
|
-
globs: ['**/*.d.ts'],
|
|
97
|
+
globs: ['**/*.d.ts', '**/*.d.gts.ts', '**/*.d.gjs.ts'],
|
|
98
98
|
directories: false,
|
|
99
99
|
includeBasePath: true,
|
|
100
100
|
});
|
|
101
101
|
return Promise.all(dtsFiles.map(async (file) => {
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
// TypeScript has never supported "compiled to JS" workflows
|
|
103
|
+
// when using external tools.
|
|
104
|
+
//
|
|
105
|
+
// So, the "arbitrary extensions" TS emits, will look like .d.gts.ts
|
|
106
|
+
// or .d.gjs.ts
|
|
107
|
+
//
|
|
108
|
+
// Because TS doesn't understand that external tools emit JS,
|
|
109
|
+
// and thus their declarations must be .d.ts, we have to
|
|
110
|
+
// manually handle this rename ourselves.
|
|
111
|
+
//
|
|
112
|
+
// Upstream: https://github.com/microsoft/TypeScript/issues/64053
|
|
113
|
+
// This'll be a no-op if/when TS fixes this.
|
|
114
|
+
let target = file.replace(/\.d\.(gts|gjs)\.ts$/, '.d.ts');
|
|
115
|
+
if (target !== file) {
|
|
116
|
+
await (0, promises_1.rename)(file, target);
|
|
117
|
+
}
|
|
118
|
+
const content = await (0, promises_1.readFile)(target, { encoding: 'utf8' });
|
|
119
|
+
await (0, promises_1.writeFile)(target, fixDeclarations(content));
|
|
104
120
|
}));
|
|
105
121
|
}
|
|
106
|
-
// Strip any .gts extension from imports in d.ts files, as these won't
|
|
107
|
-
//
|
|
122
|
+
// Strip any .gts/.gjs extension from imports in d.ts files, as these won't
|
|
123
|
+
// resolve once the declaration files themselves are named *.d.ts.
|
|
124
|
+
// See
|
|
125
|
+
// - https://github.com/typed-ember/glint/issues/628
|
|
126
|
+
// - https://github.com/microsoft/TypeScript/issues/64053
|
|
108
127
|
function fixDeclarations(content) {
|
|
109
128
|
return content
|
|
110
|
-
.replace(/from\s+'([^']+)\.gts'/g, `from '$1'`)
|
|
111
|
-
.replace(/from\s+"([^"]+)\.gts"/g, `from '$1'`)
|
|
112
|
-
.replace(/import\("([^"]+)\.gts"\)/g, `import('$1')`)
|
|
113
|
-
.replace(/import\('([^']+)\.gts'\)/g, `import('$1')`);
|
|
129
|
+
.replace(/from\s+'([^']+)\.(gts|gjs)'/g, `from '$1'`)
|
|
130
|
+
.replace(/from\s+"([^"]+)\.(gts|gjs)"/g, `from '$1'`)
|
|
131
|
+
.replace(/import\("([^"]+)\.(gts|gjs)"\)/g, `import('$1')`)
|
|
132
|
+
.replace(/import\('([^']+)\.(gts|gjs)'\)/g, `import('$1')`);
|
|
114
133
|
}
|
|
115
134
|
//# sourceMappingURL=rollup-declarations.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-declarations.js","sourceRoot":"","sources":["rollup-declarations.ts"],"names":[],"mappings":";;;;;AAUA,2CA0FC;AAnGD,kDAA0B;AAC1B,0DAAiC;AACjC,
|
|
1
|
+
{"version":3,"file":"rollup-declarations.js","sourceRoot":"","sources":["rollup-declarations.ts"],"names":[],"mappings":";;;;;AAUA,2CA0FC;AAnGD,kDAA0B;AAC1B,0DAAiC;AACjC,0CAA0D;AAC1D,2BAA8C;AAC9C,2CAAuC;AAEvC,IAAI,MAAM,GAAG,qBAAqB,CAAC;AACnC,IAAI,MAAM,GAAG,yBAAyB,CAAC;AAEvC,SAAwB,wBAAwB,CAC9C,eAAuB;AACvB;;;;;GAKG;AACH,OAAgB;IAEhB,IAAI,YAA2B,CAAC;IAEhC,IAAI,YAAY,GAAG,OAAO,CAAC;IAE3B,KAAK,UAAU,gBAAgB;QAC7B,IAAI,YAAY;YAAE,OAAO;QAEzB,IAAI,YAAY,GAAG,MAAM,IAAA,sBAAS,GAAE,CAAC;QACrC,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB;;eAEG;YACH,YAAY,GAAG,MAAM,CAAC;YACtB,OAAO;QACT,CAAC;QAED,IAAI,cAAc,GAAG,IAAA,iBAAY,EAAC,YAAY,CAAC,CAAC;QAChD,IAAI,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,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;AACJ,CAAC;AAED,2EAA2E;AAC3E,kEAAkE;AAClE,MAAM;AACN,qDAAqD;AACrD,0DAA0D;AAC1D,SAAS,eAAe,CAAC,OAAe;IACtC,OAAO,OAAO;SACX,OAAO,CAAC,8BAA8B,EAAE,WAAW,CAAC;SACpD,OAAO,CAAC,8BAA8B,EAAE,WAAW,CAAC;SACpD,OAAO,CAAC,iCAAiC,EAAE,cAAc,CAAC;SAC1D,OAAO,CAAC,iCAAiC,EAAE,cAAc,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import type { Plugin } from 'rollup';\nimport execa from 'execa';\nimport walkSync from 'walk-sync';\nimport { readFile, rename, writeFile } from 'fs/promises';\nimport { existsSync, readFileSync } from 'fs';\nimport { packageUp } from 'package-up';\n\nlet glint1 = 'glint --declaration';\nlet glint2 = 'ember-tsc --declaration';\n\nexport default function rollupDeclarationsPlugin(\n declarationsDir: string,\n /**\n * The command to use to generate types.\n * Defaults to:\n * - glint --declaration # for glint v1\n * - ember-tsc --declaration # for glint v2\n */\n command?: string\n): Plugin {\n let glintPromise: Promise<void>;\n\n let commandToRun = command;\n\n async function determineCommand() {\n if (commandToRun) return;\n\n let manifestPath = await packageUp();\n if (!manifestPath) {\n /**\n * Historical default is to use glint v1\n */\n commandToRun = glint1;\n return;\n }\n\n let manifestBuffer = readFileSync(manifestPath);\n let manifest = JSON.parse(manifestBuffer.toString());\n let deps = {\n ...manifest.devDependencies,\n ...manifest.dependencies,\n };\n\n if (deps['@glint/ember-tsc']) {\n commandToRun = glint2;\n return;\n }\n if (deps['@glint/core']) {\n commandToRun = glint1;\n return;\n }\n\n throw new Error(\n `Cannot use addon.declarations() plugin without glint present or an explicit command set as the second parameter. e.g.: addon.declarations('declarations', 'tsc --declaration')`\n );\n }\n\n return {\n name: 'declarations',\n buildStart() {\n const runGlint = async () => {\n await determineCommand();\n\n if (!commandToRun) return;\n\n let { exitCode, escapedCommand } = await execa.command(commandToRun, {\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 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', '**/*.d.gts.ts', '**/*.d.gjs.ts'],\n directories: false,\n includeBasePath: true,\n });\n\n return Promise.all(\n dtsFiles.map(async (file) => {\n // TypeScript has never supported \"compiled to JS\" workflows\n // when using external tools.\n //\n // So, the \"arbitrary extensions\" TS emits, will look like .d.gts.ts\n // or .d.gjs.ts\n //\n // Because TS doesn't understand that external tools emit JS,\n // and thus their declarations must be .d.ts, we have to\n // manually handle this rename ourselves.\n //\n // Upstream: https://github.com/microsoft/TypeScript/issues/64053\n // This'll be a no-op if/when TS fixes this.\n let target = file.replace(/\\.d\\.(gts|gjs)\\.ts$/, '.d.ts');\n\n if (target !== file) {\n await rename(file, target);\n }\n\n const content = await readFile(target, { encoding: 'utf8' });\n\n await writeFile(target, fixDeclarations(content));\n })\n );\n}\n\n// Strip any .gts/.gjs extension from imports in d.ts files, as these won't\n// resolve once the declaration files themselves are named *.d.ts.\n// See\n// - https://github.com/typed-ember/glint/issues/628\n// - https://github.com/microsoft/TypeScript/issues/64053\nfunction fixDeclarations(content: string) {\n return content\n .replace(/from\\s+'([^']+)\\.(gts|gjs)'/g, `from '$1'`)\n .replace(/from\\s+\"([^\"]+)\\.(gts|gjs)\"/g, `from '$1'`)\n .replace(/import\\(\"([^\"]+)\\.(gts|gjs)\"\\)/g, `import('$1')`)\n .replace(/import\\('([^']+)\\.(gts|gjs)'\\)/g, `import('$1')`);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-public-assets.js","sourceRoot":"","sources":["rollup-public-assets.ts"],"names":[],"mappings":";;;;;AA4BA,+BA+CC;AA3ED,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,
|
|
1
|
+
{"version":3,"file":"rollup-public-assets.js","sourceRoot":"","sources":["rollup-public-assets.ts"],"names":[],"mappings":";;;;;AA4BA,+BA+CC;AA3ED,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,OAA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ACpD,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","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 closeBundle() {\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 ?? pkg.name;\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"]}
|
package/src/rollup.d.ts
CHANGED