@embroider/addon-dev 7.1.2-unstable.fc482ba → 7.1.3
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 +0 -20
- package/package.json +3 -3
- package/src/rollup-app-reexports.js +1 -6
- 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-keep-assets.d.ts +1 -2
- package/src/rollup-keep-assets.js +28 -91
- package/src/rollup-keep-assets.js.map +1 -1
- package/src/rollup-public-entrypoints.js +3 -16
- package/src/rollup-public-entrypoints.js.map +1 -1
- package/src/rollup.d.ts +2 -6
- package/src/rollup.js +1 -2
- package/src/rollup.js.map +1 -1
package/README.md
CHANGED
|
@@ -22,26 +22,6 @@ 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
|
-
|
|
45
25
|
## addon-dev command
|
|
46
26
|
|
|
47
27
|
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": "7.1.
|
|
3
|
+
"version": "7.1.3",
|
|
4
4
|
"description": "Utilities for addon authors",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
}
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@rollup/pluginutils": "^
|
|
34
|
+
"@rollup/pluginutils": "^4.1.1",
|
|
35
35
|
"content-tag": "^3.0.0",
|
|
36
36
|
"execa": "^5.1.1",
|
|
37
37
|
"fs-extra": "^10.0.0",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"rollup-plugin-copy-assets": "^2.0.3",
|
|
40
40
|
"walk-sync": "^3.0.0",
|
|
41
41
|
"yargs": "^17.0.1",
|
|
42
|
-
"@embroider/core": "^3.5.
|
|
42
|
+
"@embroider/core": "^3.5.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@glimmer/syntax": "^0.84.2",
|
|
@@ -7,11 +7,6 @@ exports.default = appReexports;
|
|
|
7
7
|
const fs_extra_1 = require("fs-extra");
|
|
8
8
|
const path_1 = require("path");
|
|
9
9
|
const minimatch_1 = __importDefault(require("minimatch"));
|
|
10
|
-
function symmetricDifference(arr1, arr2) {
|
|
11
|
-
return arr1
|
|
12
|
-
.filter((x) => !arr2.includes(x))
|
|
13
|
-
.concat(arr2.filter((x) => !arr1.includes(x)));
|
|
14
|
-
}
|
|
15
10
|
function appReexports(opts) {
|
|
16
11
|
return {
|
|
17
12
|
name: 'app-reexports',
|
|
@@ -37,7 +32,7 @@ function appReexports(opts) {
|
|
|
37
32
|
}
|
|
38
33
|
}
|
|
39
34
|
let originalAppJS = (_e = pkg['ember-addon']) === null || _e === void 0 ? void 0 : _e['app-js'];
|
|
40
|
-
let hasChanges =
|
|
35
|
+
let hasChanges = JSON.stringify(originalAppJS) !== JSON.stringify(appJS);
|
|
41
36
|
// Don't cause a file i/o event unless something actually changed
|
|
42
37
|
if (hasChanges) {
|
|
43
38
|
pkg['ember-addon'] = Object.assign({}, pkg['ember-addon'], {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-app-reexports.js","sourceRoot":"","sources":["rollup-app-reexports.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"rollup-app-reexports.js","sourceRoot":"","sources":["rollup-app-reexports.ts"],"names":[],"mappings":";;;;;AAKA,+BAkDC;AAvDD,uCAAuD;AACvD,+BAA+B;AAC/B,0DAAkC;AAGlC,SAAwB,YAAY,CAAC,IAOpC;IACC,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,cAAc,CAAC,CAAC,EAAE,MAAM;;YACtB,IAAI,GAAG,GAAG,IAAA,uBAAY,EAAC,cAAc,CAAC,CAAC;YACvC,IAAI,KAAK,GAA2B,EAAE,CAAC;YACvC,KAAK,IAAI,aAAa,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;gBAC9C,IAAI,WAAW,GAAG,MAAA,MAAA,IAAI,CAAC,WAAW,qDAAG,aAAa,CAAC,mCAAI,aAAa,CAAC;gBACrE,IAAI,UAAU,GAAG,CAAA,MAAA,IAAI,CAAC,OAAO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AAC,aAAa,CAAC,EAAE;oBACzD,QAAQ,EAAE,KAAK;iBAChB,CAAC,CAAC;gBACH,IAAA,wBAAa,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\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 = JSON.stringify(originalAppJS) !== JSON.stringify(appJS);\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,GAAG,CAAC,EAAE,CAAC;oBACjB,IAAI,GAAG,GAA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E;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"]}
|
|
@@ -4,105 +4,42 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.default = keepAssets;
|
|
7
|
-
const
|
|
8
|
-
const path_1 = require("path");
|
|
7
|
+
const walk_sync_1 = __importDefault(require("walk-sync"));
|
|
9
8
|
const fs_1 = require("fs");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
function keepAssets({ from, include, exports, }) {
|
|
14
|
-
const marker = `__keep_assets_marker_${counter++}__`;
|
|
9
|
+
const path_1 = require("path");
|
|
10
|
+
const minimatch_1 = __importDefault(require("minimatch"));
|
|
11
|
+
function keepAssets({ from, include, }) {
|
|
15
12
|
return {
|
|
16
|
-
name: '
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
meta: {
|
|
29
|
-
'keep-assets': {
|
|
30
|
-
binaryLoaded: true,
|
|
31
|
-
},
|
|
32
|
-
},
|
|
33
|
-
};
|
|
13
|
+
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' };
|
|
34
25
|
}
|
|
26
|
+
return resolution;
|
|
35
27
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (include.some((pattern) => (0, minimatch_1.default)(id, pattern))) {
|
|
46
|
-
let ref = this.emitFile({
|
|
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({
|
|
47
37
|
type: 'asset',
|
|
48
|
-
fileName:
|
|
49
|
-
source:
|
|
38
|
+
fileName: name,
|
|
39
|
+
source: (0, fs_1.readFileSync)((0, path_1.join)(from, name)),
|
|
50
40
|
});
|
|
51
|
-
if (exports === '*') {
|
|
52
|
-
return `export * from ${marker}("${ref}")`;
|
|
53
|
-
}
|
|
54
|
-
else if (exports === 'default') {
|
|
55
|
-
return `export default ${marker}("${ref}")`;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
// side-effect only
|
|
59
|
-
return `${marker}("${ref}")`;
|
|
60
|
-
}
|
|
61
41
|
}
|
|
62
42
|
},
|
|
63
|
-
renderChunk(code, chunk) {
|
|
64
|
-
const { getName, imports } = nameTracker(code, exports);
|
|
65
|
-
code = code.replace(new RegExp(`${marker}\\("([^"]+)"\\)`, 'g'), (_x, ref) => {
|
|
66
|
-
var _a;
|
|
67
|
-
let assetFileName = this.getFileName(ref);
|
|
68
|
-
let relativeName = './' + (0, path_1.relative)((0, path_1.dirname)(chunk.fileName), assetFileName);
|
|
69
|
-
return (_a = getName(relativeName)) !== null && _a !== void 0 ? _a : '';
|
|
70
|
-
});
|
|
71
|
-
return imports() + code;
|
|
72
|
-
},
|
|
73
43
|
};
|
|
74
44
|
}
|
|
75
|
-
function nameTracker(code, exports) {
|
|
76
|
-
let counter = 0;
|
|
77
|
-
let assets = new Map();
|
|
78
|
-
function getName(assetName) {
|
|
79
|
-
if (assets.has(assetName)) {
|
|
80
|
-
return assets.get(assetName);
|
|
81
|
-
}
|
|
82
|
-
if (!exports) {
|
|
83
|
-
assets.set(assetName, undefined);
|
|
84
|
-
return undefined;
|
|
85
|
-
}
|
|
86
|
-
while (true) {
|
|
87
|
-
let candidate = `_asset_${counter++}_`;
|
|
88
|
-
if (!code.includes(candidate)) {
|
|
89
|
-
assets.set(assetName, candidate);
|
|
90
|
-
return candidate;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function imports() {
|
|
95
|
-
return ([...assets]
|
|
96
|
-
.map(([assetName, importedName]) => {
|
|
97
|
-
if (importedName) {
|
|
98
|
-
return `import ${importedName} from "${assetName}"`;
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
return `import "${assetName}"`;
|
|
102
|
-
}
|
|
103
|
-
})
|
|
104
|
-
.join('\n') + '\n');
|
|
105
|
-
}
|
|
106
|
-
return { getName, imports };
|
|
107
|
-
}
|
|
108
45
|
//# sourceMappingURL=rollup-keep-assets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-keep-assets.js","sourceRoot":"","sources":["rollup-keep-assets.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"rollup-keep-assets.js","source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AAC;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"]}
|
|
@@ -11,28 +11,15 @@ function normalizeFileExt(fileName) {
|
|
|
11
11
|
return fileName.replace(/(?<!\.d)\.ts|\.hbs|\.gts|\.gjs$/, '.js');
|
|
12
12
|
}
|
|
13
13
|
function publicEntrypoints(args) {
|
|
14
|
-
const allEntryPoints = new Set();
|
|
15
14
|
return {
|
|
16
15
|
name: 'addon-modules',
|
|
17
16
|
async buildStart() {
|
|
18
|
-
const include = [
|
|
19
|
-
...args.include,
|
|
20
|
-
'**/*.hbs',
|
|
21
|
-
'**/*.ts',
|
|
22
|
-
'**/*.gts',
|
|
23
|
-
'**/*.gjs',
|
|
24
|
-
];
|
|
25
|
-
// wait a bit first https://github.com/nodejs/node/issues/4760
|
|
26
|
-
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
27
17
|
let matches = (0, walk_sync_1.default)(args.srcDir, {
|
|
28
|
-
globs: include,
|
|
18
|
+
globs: [...args.include, '**/*.hbs', '**/*.ts', '**/*.gts', '**/*.gjs'],
|
|
29
19
|
ignore: args.exclude,
|
|
30
20
|
});
|
|
31
|
-
matches.forEach((m) => allEntryPoints.add(m));
|
|
32
|
-
for (const name of allEntryPoints) {
|
|
33
|
-
this.addWatchFile(path_1.default.resolve(args.srcDir, name));
|
|
34
|
-
}
|
|
35
21
|
for (let name of matches) {
|
|
22
|
+
this.addWatchFile(path_1.default.join(args.srcDir, name));
|
|
36
23
|
// the matched file, but with the extension swapped with .js
|
|
37
24
|
let normalizedName = normalizeFileExt(name);
|
|
38
25
|
// anything that doesn't match the users patterns, and wasn't a template-only
|
|
@@ -58,7 +45,7 @@ function publicEntrypoints(args) {
|
|
|
58
45
|
let isUserDefined = args.include.some((pattern) => (0, minimatch_1.default)(name, pattern));
|
|
59
46
|
// additionally, we want to emit chunks where the pattern matches the supported
|
|
60
47
|
// file extensions above (TS, GTS, etc) as if they were already the built JS.
|
|
61
|
-
let wouldMatchIfBuilt = include.some((pattern) => (0, minimatch_1.default)(normalizedName, pattern));
|
|
48
|
+
let wouldMatchIfBuilt = args.include.some((pattern) => (0, minimatch_1.default)(normalizedName, pattern));
|
|
62
49
|
if (isUserDefined || wouldMatchIfBuilt) {
|
|
63
50
|
this.emitFile({
|
|
64
51
|
type: 'chunk',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollup-public-entrypoints.js","sourceRoot":"","sources":["rollup-public-entrypoints.ts"],"names":[],"mappings":";;;;;AAUA,
|
|
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,C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 '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"]}
|
package/src/rollup.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare class Addon {
|
|
|
17
17
|
hbs(options?: {}): Plugin<any>;
|
|
18
18
|
gjs(): Plugin<any>;
|
|
19
19
|
clean(): Plugin<any>;
|
|
20
|
-
keepAssets(patterns: string[]
|
|
20
|
+
keepAssets(patterns: string[]): Plugin<any>;
|
|
21
21
|
output(): {
|
|
22
22
|
dir: string;
|
|
23
23
|
entryFileNames: string;
|
|
@@ -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
|
}
|
package/src/rollup.js
CHANGED
|
@@ -75,11 +75,10 @@ class Addon {
|
|
|
75
75
|
// to leave those imports alone and to make sure the corresponding .css files
|
|
76
76
|
// are kept in the same relative locations in the destDir as they were in the
|
|
77
77
|
// srcDir.
|
|
78
|
-
keepAssets(patterns
|
|
78
|
+
keepAssets(patterns) {
|
|
79
79
|
return (0, rollup_keep_assets_1.default)({
|
|
80
80
|
from: __classPrivateFieldGet(this, _Addon_srcDir, "f"),
|
|
81
81
|
include: patterns,
|
|
82
|
-
exports: exports,
|
|
83
82
|
});
|
|
84
83
|
}
|
|
85
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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AC9D,GAAG,CAAC,OAAO,GAAG,EAAE;QACd,OAAO,IAAA,2BAAG,EAAC,OAAO,CAAC,CAAC;IACtB,CAAC;IAED,GAAG;QACD,OAAO,IAAA,2BAAG,GAAE,CAAC;IACf,CAAC;IAED,mHAAmH;IACnH,2DAA2D;IAC3D,oCAAoC;IACpC,KAAK;QACH,OAAO,IAAA,mCAAK,GAAE,CAAC;IACjB,CAAC;IAED,4EAA4E;IAC5E,6EAA6E;IAC7E,6EAA6E;IAC7E,UAAU;IACV,UAAU,CAAC,QAAkB;QAC3B,OAAO,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;IAED,YAAY,CAAC,IAAY;QACvB,OAAO,IAAA,6BAAY,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;CACF;AArGD,sBAqGC","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 declarations } from './rollup-declarations';\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[]) {\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 declarations(path: string) {\n return declarations(path);\n }\n}\n"]}
|