@embroider/addon-dev 8.0.1-unstable.54e2585 → 8.0.1-unstable.589c286
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 +3 -11
- package/src/rollup-app-reexports.js +2 -2
- package/src/rollup-app-reexports.js.map +1 -1
- package/src/rollup-declarations.d.ts +2 -5
- package/src/rollup-declarations.js +27 -3
- package/src/rollup-declarations.js.map +1 -1
- package/src/rollup-hbs-plugin.js +3 -0
- package/src/rollup-hbs-plugin.js.map +1 -1
- package/src/rollup.d.ts +1 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@embroider/addon-dev",
|
|
3
|
-
"version": "8.0.1-unstable.
|
|
3
|
+
"version": "8.0.1-unstable.589c286",
|
|
4
4
|
"description": "Utilities for addon authors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -30,14 +30,6 @@
|
|
|
30
30
|
"optional": true
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
|
-
"release-plan": {
|
|
34
|
-
"semverIncrementAs": {
|
|
35
|
-
"major": "prerelease",
|
|
36
|
-
"minor": "prerelease",
|
|
37
|
-
"patch": "prerelease"
|
|
38
|
-
},
|
|
39
|
-
"semverIncrementTag": "alpha"
|
|
40
|
-
},
|
|
41
33
|
"dependencies": {
|
|
42
34
|
"@rollup/pluginutils": "^5.1.0",
|
|
43
35
|
"content-tag": "^3.0.0",
|
|
@@ -47,10 +39,10 @@
|
|
|
47
39
|
"rollup-plugin-copy-assets": "^2.0.3",
|
|
48
40
|
"walk-sync": "^3.0.0",
|
|
49
41
|
"yargs": "^17.0.1",
|
|
50
|
-
"@embroider/core": "^4.0.
|
|
42
|
+
"@embroider/core": "^4.0.2-unstable.589c286"
|
|
51
43
|
},
|
|
52
44
|
"devDependencies": {
|
|
53
|
-
"@glimmer/syntax": "^0.
|
|
45
|
+
"@glimmer/syntax": "^0.94.9",
|
|
54
46
|
"@glint/core": "^1.5.0",
|
|
55
47
|
"@glint/template": "^1.5.0",
|
|
56
48
|
"@glint/environment-ember-loose": "^1.5.0",
|
|
@@ -16,7 +16,7 @@ function appReexports(opts) {
|
|
|
16
16
|
return {
|
|
17
17
|
name: 'app-reexports',
|
|
18
18
|
generateBundle(_, bundle) {
|
|
19
|
-
var _a, _b, _c, _d, _e;
|
|
19
|
+
var _a, _b, _c, _d, _e, _f;
|
|
20
20
|
let pkg = (0, fs_extra_1.readJsonSync)('package.json');
|
|
21
21
|
let appJS = {};
|
|
22
22
|
for (let addonFilename of Object.keys(bundle)) {
|
|
@@ -36,7 +36,7 @@ function appReexports(opts) {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
let originalAppJS = (_e = pkg['ember-addon']) === null || _e === void 0 ? void 0 : _e['app-js'];
|
|
39
|
+
let originalAppJS = (_f = (_e = pkg['ember-addon']) === null || _e === void 0 ? void 0 : _e['app-js']) !== null && _f !== void 0 ? _f : {};
|
|
40
40
|
let hasChanges = !!symmetricDifference(Object.keys(originalAppJS), Object.keys(appJS)).length;
|
|
41
41
|
// Don't cause a file i/o event unless something actually changed
|
|
42
42
|
if (hasChanges) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-app-reexports.js","sourceRoot":"","sources":["rollup-app-reexports.ts"],"names":[],"mappings":";;;;;AAWA,+BAqDC;AAhED,uCAAuD;AACvD,+BAA+B;AAC/B,0DAAkC;AAGlC,SAAS,mBAAmB,CAAC,IAAW,EAAE,IAAW;IACnD,OAAO,IAAI;SACR,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;SAChC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;A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BAAa,EAAC,cAAc,EAAE,GAAG,EAAE,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { readJsonSync, writeJsonSync } from 'fs-extra';\nimport { extname } from 'path';\nimport minimatch from 'minimatch';\nimport type { Plugin } from 'rollup';\n\nfunction symmetricDifference(arr1: any[], arr2: any[]) {\n return arr1\n .filter((x) => !arr2.includes(x))\n .concat(arr2.filter((x) => !arr1.includes(x)));\n}\n\nexport default function appReexports(opts: {\n from: string;\n to: string;\n include: string[];\n exclude?: string[];\n mapFilename?: (filename: string) => string;\n exports?: (filename: string) => string[] | string | undefined;\n}): Plugin {\n return {\n name: 'app-reexports',\n generateBundle(_, bundle) {\n let pkg = readJsonSync('package.json');\n let appJS: Record<string, string> = {};\n for (let addonFilename of Object.keys(bundle)) {\n let appFilename = opts.mapFilename?.(addonFilename) ?? addonFilename;\n let appExports = opts.exports?.(addonFilename) || ['default'];\n\n let computedExports =\n typeof appExports === 'string'\n ? appExports\n : `{ ${appExports.join(', ')} }`;\n\n if (\n opts.include.some((glob) => minimatch(addonFilename, glob)) &&\n !minimatch(addonFilename, '**/*.d.ts') &&\n opts.exclude?.some((glob) => minimatch(addonFilename, glob)) !== true\n ) {\n appJS[`./${appFilename}`] = `./dist/_app_/${appFilename}`;\n this.emitFile({\n type: 'asset',\n fileName: `_app_/${appFilename}`,\n source: `export ${computedExports} from \"${\n pkg.name\n }/${addonFilename.slice(0, -extname(addonFilename).length)}\";\\n`,\n });\n }\n }\n let originalAppJS = pkg['ember-addon']?.['app-js'] ?? {};\n\n let hasChanges = !!symmetricDifference(\n Object.keys(originalAppJS),\n Object.keys(appJS)\n ).length;\n\n // Don't cause a file i/o event unless something actually changed\n if (hasChanges) {\n pkg['ember-addon'] = Object.assign({}, pkg['ember-addon'], {\n 'app-js': appJS,\n });\n writeJsonSync('package.json', pkg, { spaces: 2 });\n }\n },\n };\n}\n"]}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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: '
|
|
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":";;;;;
|
|
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;gBAC1B,IAAI,EAAE,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,IAAA,eAAK,EAC5C,OAAO,EACP,CAAC,eAAe,CAAC,EACjB;oBACE,uEAAuE;oBACvE,0BAA0B;oBAC1B,6EAA6E;oBAC7E,qDAAqD;oBACrD,KAAK,EAAE,SAAS;oBAChB,WAAW,EAAE,IAAI;oBACjB,qDAAqD;oBACrD,MAAM,EAAE,KAAK;iBACd,CACF,CAAC;gBAEF,IAAI,QAAQ,GA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,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"]}
|
package/src/rollup-hbs-plugin.js
CHANGED
|
@@ -18,10 +18,12 @@ function rollupHbsPlugin({ excludeColocation, }) {
|
|
|
18
18
|
return null;
|
|
19
19
|
}
|
|
20
20
|
let resolution = await this.resolve(source, importer, {
|
|
21
|
+
...options,
|
|
21
22
|
skipSelf: true,
|
|
22
23
|
});
|
|
23
24
|
if (!resolution && (0, path_1.extname)(source) === '') {
|
|
24
25
|
resolution = await this.resolve(source + '.hbs', importer, {
|
|
26
|
+
...options,
|
|
25
27
|
skipSelf: true,
|
|
26
28
|
});
|
|
27
29
|
}
|
|
@@ -29,6 +31,7 @@ function rollupHbsPlugin({ excludeColocation, }) {
|
|
|
29
31
|
let hbsSource = (0, core_1.syntheticJStoHBS)(source);
|
|
30
32
|
if (hbsSource) {
|
|
31
33
|
resolution = await this.resolve(hbsSource, importer, {
|
|
34
|
+
...options,
|
|
32
35
|
skipSelf: true,
|
|
33
36
|
custom: {
|
|
34
37
|
embroider: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-hbs-plugin.js","sourceRoot":"","sources":["rollup-hbs-plugin.ts"],"names":[],"mappings":";;;;;AAaA,
|
|
1
|
+
{"version":3,"file":"rollup-hbs-plugin.js","sourceRoot":"","sources":["r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BAC/B,IAAI,CAAA,MAAA,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,0CAAE,IAAI,MAAK,4BAA4B,EAAE,CAAC;wBAC7D,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;oBACxB,CAAC;gBACH,CAAC;gBACD,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;oBACnB,OAAO,IAAI,CAAC;gBACd,CAAC;gBACD,OAAO,IAAA,cAAO,EAAC,IAAI,CAAC,CAAC;YACvB,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AAMD,SAAS,OAAO,CAAC,OAAsB,EAAE,EAAU;;IACjD,MAAM,IAAI,GAAG,MAAA,MAAA,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,0CAAE,IAAI,0CAAG,mBAAmB,CAAC,CAAC;IACpE,IAAI,IAAI,EAAE,CAAC;QACT,OAAO,IAAY,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import type { Plugin, PluginContext } from 'rollup';\nimport { createFilter } from '@rollup/pluginutils';\nimport minimatch from 'minimatch';\nimport {\n hbsToJS,\n templateOnlyComponentSource,\n needsSyntheticComponentJS,\n syntheticJStoHBS,\n} from '@embroider/core';\nimport { extname } from 'path';\n\nconst hbsFilter = createFilter('**/*.hbs?([?]*)');\n\nexport default function rollupHbsPlugin({\n excludeColocation,\n}: {\n excludeColocation?: string[];\n}): Plugin {\n return {\n name: 'rollup-hbs-plugin',\n async resolveId(source: string, importer: string | undefined, options) {\n if (options.custom?.embroider?.isExtensionSearch) {\n return null;\n }\n\n let resolution = await this.resolve(source, importer, {\n ...options,\n skipSelf: true,\n });\n\n if (!resolution && extname(source) === '') {\n resolution = await this.resolve(source + '.hbs', importer, {\n ...options,\n skipSelf: true,\n });\n }\n\n if (!resolution) {\n let hbsSource = syntheticJStoHBS(source);\n if (hbsSource) {\n resolution = await this.resolve(hbsSource, importer, {\n ...options,\n skipSelf: true,\n custom: {\n embroider: {\n isExtensionSearch: true,\n },\n },\n });\n }\n\n if (!resolution) {\n return null;\n }\n }\n\n if (resolution && resolution.id.endsWith('.hbs')) {\n let isExcluded = excludeColocation?.some((glob) =>\n minimatch(resolution!.id, glob)\n );\n if (isExcluded) {\n return resolution;\n }\n }\n\n let syntheticId = needsSyntheticComponentJS(source, resolution.id);\n if (syntheticId) {\n this.addWatchFile(source);\n return {\n id: syntheticId,\n meta: {\n 'rollup-hbs-plugin': {\n type: 'template-only-component-js',\n },\n },\n };\n }\n },\n\n load(id: string) {\n if (getMeta(this, id)?.type === 'template-only-component-js') {\n this.addWatchFile(id);\n return {\n code: templateOnlyComponentSource(),\n };\n }\n },\n\n transform: {\n // Enforce running the hbs transform before any others like babel that expect valid JS\n order: 'pre',\n handler(code: string, id: string) {\n let hbsFilename = id.replace(/\\.\\w{1,3}$/, '') + '.hbs';\n if (hbsFilename !== id) {\n this.addWatchFile(hbsFilename);\n if (getMeta(this, id)?.type === 'template-only-component-js') {\n this.addWatchFile(id);\n }\n }\n if (!hbsFilter(id)) {\n return null;\n }\n return hbsToJS(code);\n },\n },\n };\n}\n\ntype Meta = {\n type: 'template-only-component-js';\n};\n\nfunction getMeta(context: PluginContext, id: string): Meta | null {\n const meta = context.getModuleInfo(id)?.meta?.['rollup-hbs-plugin'];\n if (meta) {\n return meta as Meta;\n } else {\n return null;\n }\n}\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
|
}
|