@embroider/vite 0.2.1-unstable.ea2a455 → 0.2.1-unstable.ea895c2

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/index.mjs CHANGED
@@ -6,3 +6,4 @@ export * from './src/template-tag.js';
6
6
  export * from './src/optimize-deps.js';
7
7
  export * from './src/build.js';
8
8
  export * from './src/assets.js';
9
+ export * from './src/content-for.js';
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@embroider/vite",
3
- "version": "0.2.1-unstable.ea2a455",
3
+ "version": "0.2.1-unstable.ea895c2",
4
4
  "main": "index.mjs",
5
5
  "peerDependencies": {
6
- "@embroider/core": "3.4.6-unstable.ea2a455",
6
+ "@embroider/core": "3.4.9-unstable.ea895c2",
7
7
  "vite": "^4.3.9 || ^5.0.0"
8
8
  },
9
9
  "scripts": {
@@ -11,7 +11,7 @@
11
11
  },
12
12
  "dependencies": {
13
13
  "@babel/core": "^7.22.9",
14
- "@embroider/macros": "1.14.1-unstable.ea2a455",
14
+ "@embroider/macros": "1.16.1-unstable.ea895c2",
15
15
  "@rollup/pluginutils": "^4.1.1",
16
16
  "assert-never": "^1.2.1",
17
17
  "content-tag": "^2.0.1",
@@ -25,7 +25,7 @@
25
25
  "send": "^0.18.0"
26
26
  },
27
27
  "devDependencies": {
28
- "@embroider/core": "3.4.6-unstable.ea2a455",
28
+ "@embroider/core": "3.4.9-unstable.ea895c2",
29
29
  "@types/babel__core": "^7.20.1",
30
30
  "@types/send": "^0.17.4",
31
31
  "@types/debug": "^4.1.5",
package/src/assets.js CHANGED
@@ -74,29 +74,40 @@ function assets() {
74
74
  });
75
75
  };
76
76
  },
77
- async buildStart() {
78
- if (mode !== 'build')
79
- return;
80
- const engines = resolverLoader.resolver.options.engines;
81
- for (const engine of engines) {
82
- const packages = engine.activeAddons.map(a => resolverLoader.resolver.packageCache.ownerOfFile(a.root));
83
- packages.forEach(pkg => {
84
- if (!pkg || !pkg.isV2Addon())
85
- return;
86
- const assets = pkg.meta['public-assets'] || {};
87
- Object.entries(assets).forEach(([path, dest]) => {
88
- // do not override app public assets
89
- if ((0, fs_extra_1.existsSync)((0, path_1.join)(publicDir, dest))) {
77
+ buildStart: {
78
+ // we need to wait for the compatBuild plugin's buildStart hook to finish
79
+ // so that the resolver config exists before we try to read it.
80
+ sequential: true,
81
+ order: 'post',
82
+ async handler() {
83
+ if (mode !== 'build')
84
+ return;
85
+ const engines = resolverLoader.resolver.options.engines;
86
+ for (const engine of engines) {
87
+ const packages = engine.activeAddons.map(a => resolverLoader.resolver.packageCache.ownerOfFile(a.root));
88
+ packages.forEach(pkg => {
89
+ if (!pkg || !pkg.isV2Addon())
90
90
  return;
91
- }
92
- this.emitFile({
93
- type: 'asset',
94
- source: (0, fs_extra_1.readFileSync)((0, path_1.join)(pkg.root, path)),
95
- fileName: path_1.posix.resolve('/', dest).slice(1),
91
+ const assets = pkg.meta['public-assets'] || {};
92
+ Object.entries(assets).forEach(([path, dest]) => {
93
+ // do not override app public assets
94
+ if ((0, fs_extra_1.existsSync)((0, path_1.join)(publicDir, dest))) {
95
+ return;
96
+ }
97
+ const filePath = (0, path_1.join)(pkg.root, path);
98
+ if (!(0, fs_extra_1.lstatSync)(filePath).isFile()) {
99
+ console.log(`Invalid package definition, ${pkg.name} has defined a file "${path}" that is not a file`);
100
+ return;
101
+ }
102
+ this.emitFile({
103
+ type: 'asset',
104
+ source: (0, fs_extra_1.readFileSync)(filePath),
105
+ fileName: path_1.posix.resolve('/', dest).slice(1),
106
+ });
96
107
  });
97
108
  });
98
- });
99
- }
109
+ }
110
+ },
100
111
  },
101
112
  };
102
113
  }
package/src/assets.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"assets.js","sourceRoot":"","sources":["assets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0CAAiD;AAEjD,iDAAmC;AACnC,+BAAmC;AACnC,uCAAoD;AACpD,g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AM,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;oBAC/C,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE,EAAE;wBAC9C,oCAAoC;wBACpC,IAAI,IAAA,qBAAU,EAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,CAAC,CAAC,EAAE;4BACrC,OAAO;yBACR;wBACD,IAAI,CAAC,QAAQ,CAAC;4BACZ,IAAI,EAAE,OAAO;4BACb,MAAM,EAAE,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;4BAC1C,QAAQ,EAAE,YAAK,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;yBAC5C,CAAC,CAAC;oBACL,CAAC,CAAC,CAAC;gBACL,CAAC,CAAC,CAAC;aACJ;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAhDD,wBAgDC","sourcesContent":["import type { Resolver } from '@embroider/core';\nimport { ResolverLoader } from '@embroider/core';\nimport type { Plugin } from 'vite';\nimport * as process from 'process';\nimport { join, posix } from 'path';\nimport { existsSync, readFileSync } from 'fs-extra';\nimport send from 'send';\nimport type { Readable } from 'stream';\n\nfunction findPublicAsset(relativePath: string, resolver: Resolver) {\n const packageCache = resolver.packageCache;\n let pkg = packageCache.ownerOfFile(relativePath);\n\n for (const engine of resolver.options.engines) {\n for (const addon of engine.activeAddons) {\n pkg = packageCache.ownerOfFile(addon.root);\n if (pkg && pkg.meta && pkg.isV2Addon() && pkg.meta['public-assets']) {\n const asset = Object.entries(pkg.meta['public-assets']).find(\n ([_key, a]) => posix.resolve('/', a) === relativePath\n )?.[0];\n let local = asset ? join(addon.root, asset) : null;\n if (local && existsSync(local)) {\n return local;\n }\n }\n }\n }\n}\n\nexport function assets(): Plugin {\n const cwd = process.cwd();\n const resolverLoader = new ResolverLoader(cwd);\n let mode: 'build' | 'serve' = 'build';\n let publicDir = 'public';\n return {\n name: 'assets',\n enforce: 'post',\n configResolved(options) {\n mode = options.command;\n publicDir = options.publicDir;\n },\n configureServer(server) {\n return () => {\n server.middlewares.use((req, res, next) => {\n if (req.originalUrl && req.originalUrl.length > 1) {\n const assetUrl = findPublicAsset(req.originalUrl.split('?')[0], resolverLoader.resolver);\n if (assetUrl) {\n return send(req as Readable, assetUrl).pipe(res);\n }\n }\n return next();\n });\n };\n },\n async buildStart() {\n if (mode !== 'build') return;\n const engines = resolverLoader.resolver.options.engines;\n for (const engine of engines) {\n const packages = engine.activeAddons.map(a => resolverLoader.resolver.packageCache.ownerOfFile(a.root));\n packages.forEach(pkg => {\n if (!pkg || !pkg.isV2Addon()) return;\n const assets = pkg.meta['public-assets'] || {};\n Object.entries(assets).forEach(([path, dest]) => {\n // do not override app public assets\n if (existsSync(join(publicDir, dest))) {\n return;\n }\n this.emitFile({\n type: 'asset',\n source: readFileSync(join(pkg.root, path)),\n fileName: posix.resolve('/', dest).slice(1),\n });\n });\n });\n }\n },\n };\n}\n"]}
1
+ {"version":3,"file":"assets.js","sourceRoot":"","sources":["assets.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0CAAiD;AAEjD,iDAAmC;AACnC,+BAAmC;AACnC,uCAA+D;AAC/D,gDAAwB;AAGxB,SAAS,eAAe,CAAC,YAAoB,EAAE,QAAkB;;IAC/D,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;IAC3C,IAAI,GAAG,GAAG,YAAY,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC;IAEjD,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE;QAC7C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,YAAY,EAAE;YACvC,GAAG,GAAG,YAAY,CAAC,WAAW,CAAC,KAAK,CAAC,IAA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AE,IAAI,CAAC,CAAC,EAAE;gCACrC,OAAO;6BACR;4BAED,MAAM,QAAQ,GAAG,IAAA,WAAI,EAAC,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;4BACtC,IAAI,CAAC,IAAA,oBAAS,EAAC,QAAQ,CAAC,CAAC,MAAM,EAAE,EAAE;gCACjC,OAAO,CAAC,GAAG,CAAC,+BAA+B,GAAG,CAAC,IAAI,wBAAwB,IAAI,sBAAsB,CAAC,CAAC;gCACvG,OAAO;6BACR;4BAED,IAAI,CAAC,QAAQ,CAAC;gCACZ,IAAI,EAAE,OAAO;gCACb,MAAM,EAAE,IAAA,uBAAY,EAAC,QAAQ,CAAC;gCAC9B,QAAQ,EAAE,YAAK,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;6BAC5C,CAAC,CAAC;wBACL,CAAC,CAAC,CAAC;oBACL,CAAC,CAAC,CAAC;iBACJ;YACH,CAAC;SACF;KACF,CAAC;AACJ,CAAC;AA7DD,wBA6DC","sourcesContent":["import type { Resolver } from '@embroider/core';\nimport { ResolverLoader } from '@embroider/core';\nimport type { Plugin } from 'vite';\nimport * as process from 'process';\nimport { join, posix } from 'path';\nimport { existsSync, readFileSync, lstatSync } from 'fs-extra';\nimport send from 'send';\nimport type { Readable } from 'stream';\n\nfunction findPublicAsset(relativePath: string, resolver: Resolver) {\n const packageCache = resolver.packageCache;\n let pkg = packageCache.ownerOfFile(relativePath);\n\n for (const engine of resolver.options.engines) {\n for (const addon of engine.activeAddons) {\n pkg = packageCache.ownerOfFile(addon.root);\n if (pkg && pkg.meta && pkg.isV2Addon() && pkg.meta['public-assets']) {\n const asset = Object.entries(pkg.meta['public-assets']).find(\n ([_key, a]) => posix.resolve('/', a) === relativePath\n )?.[0];\n let local = asset ? join(addon.root, asset) : null;\n if (local && existsSync(local)) {\n return local;\n }\n }\n }\n }\n}\n\nexport function assets(): Plugin {\n const cwd = process.cwd();\n const resolverLoader = new ResolverLoader(cwd);\n let mode: 'build' | 'serve' = 'build';\n let publicDir = 'public';\n return {\n name: 'assets',\n enforce: 'post',\n configResolved(options) {\n mode = options.command;\n publicDir = options.publicDir;\n },\n configureServer(server) {\n return () => {\n server.middlewares.use((req, res, next) => {\n if (req.originalUrl && req.originalUrl.length > 1) {\n const assetUrl = findPublicAsset(req.originalUrl.split('?')[0], resolverLoader.resolver);\n if (assetUrl) {\n return send(req as Readable, assetUrl).pipe(res);\n }\n }\n return next();\n });\n };\n },\n buildStart: {\n // we need to wait for the compatBuild plugin's buildStart hook to finish\n // so that the resolver config exists before we try to read it.\n sequential: true,\n order: 'post',\n async handler() {\n if (mode !== 'build') return;\n const engines = resolverLoader.resolver.options.engines;\n for (const engine of engines) {\n const packages = engine.activeAddons.map(a => resolverLoader.resolver.packageCache.ownerOfFile(a.root));\n packages.forEach(pkg => {\n if (!pkg || !pkg.isV2Addon()) return;\n const assets = pkg.meta['public-assets'] || {};\n Object.entries(assets).forEach(([path, dest]) => {\n // do not override app public assets\n if (existsSync(join(publicDir, dest))) {\n return;\n }\n\n const filePath = join(pkg.root, path);\n if (!lstatSync(filePath).isFile()) {\n console.log(`Invalid package definition, ${pkg.name} has defined a file \"${path}\" that is not a file`);\n return;\n }\n\n this.emitFile({\n type: 'asset',\n source: readFileSync(filePath),\n fileName: posix.resolve('/', dest).slice(1),\n });\n });\n });\n }\n },\n },\n };\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { Plugin } from 'vite';
2
+ export declare function contentFor(): Plugin;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.contentFor = void 0;
4
+ const fs_extra_1 = require("fs-extra");
5
+ const path_1 = require("path");
6
+ const core_1 = require("@embroider/core");
7
+ function contentFor() {
8
+ return {
9
+ name: 'embroider-content-for',
10
+ transformIndexHtml(html, { path }) {
11
+ let config = (0, fs_extra_1.readJSONSync)((0, path_1.join)((0, core_1.locateEmbroiderWorkingDir)(process.cwd()), 'content-for.json'));
12
+ let contentsForConfig = config[path];
13
+ for (const [contentType, htmlContent] of Object.entries(contentsForConfig)) {
14
+ html = html.replace(`{{content-for "${contentType}"}}`, `${htmlContent}`);
15
+ }
16
+ return html;
17
+ },
18
+ };
19
+ }
20
+ exports.contentFor = contentFor;
21
+ //# sourceMappingURL=content-for.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-for.js","sourceRoot":"","sources":["content-for.ts"],"names":[],"mappings":";;;AACA,uCAAwC;AACxC,+BAA4B;AAC5B,0CAA4D;AAE5D,SAAgB,UAAU;IACxB,OAAO;QACL,IAAI,EAAE,uBAAuB;QAE7B,kBAAkB,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE;YAC/B,IAAI,MAAM,GAAQ,IAAA,uBAAY,EAAC,IAAA,WAAI,EAAC,IAAA,gCAAyB,EAAC,OAAO,CAAC,GAAG,EAAE,CAAC,EAAE,kBAAkB,CAAC,CAAC,CAAC;YACnG,IAAI,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;YACrC,KAAK,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,iBAAiB,CAAC,EAAE;gBAC1E,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,WAAW,KAAK,EAAE,GAAG,WAAW,EAAE,CAAC,CAAC;aAC3E;YACD,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAbD,gCAaC","sourcesContent":["import type { Plugin } from 'vite';\nimport { readJSONSync } from 'fs-extra';\nimport { join } from 'path';\nimport { locateEmbroiderWorkingDir } from '@embroider/core';\n\nexport function contentFor(): Plugin {\n return {\n name: 'embroider-content-for',\n\n transformIndexHtml(html, { path }) {\n let config: any = readJSONSync(join(locateEmbroiderWorkingDir(process.cwd()), 'content-for.json'));\n let contentsForConfig = config[path];\n for (const [contentType, htmlContent] of Object.entries(contentsForConfig)) {\n html = html.replace(`{{content-for \"${contentType}\"}}`, `${htmlContent}`);\n }\n return html;\n },\n };\n}\n"]}