@vocab/webpack 0.0.0-expose-entry-regex-20230413013100 → 0.0.0-expose-entry-regex-20230414045557

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.
@@ -1,5 +1,5 @@
1
1
  import { UserConfig } from '@vocab/types';
2
2
  import type { LoaderContext as WebpackLoaderContext } from 'webpack';
3
3
  type LoaderContext = WebpackLoaderContext<UserConfig>;
4
- export default function vocabLoader(this: LoaderContext): Promise<void>;
4
+ export default function vocabLoader(this: LoaderContext, source: string): Promise<void>;
5
5
  export {};
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var path = require('path');
6
+ var mlly = require('mlly');
6
7
  var core = require('@vocab/core');
7
8
  var chunkName_dist_vocabWebpackChunkName = require('../../chunk-name/dist/vocab-webpack-chunk-name.cjs.dev.js');
8
9
  var logger = require('../../dist/logger-65149486.cjs.dev.js');
@@ -51,7 +52,7 @@ function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
51
52
  );
52
53
  };
53
54
  }
54
- async function vocabLoader() {
55
+ async function vocabLoader(source) {
55
56
  trace(`Using vocab loader for ${this.resourcePath}`);
56
57
  const callback = this.async();
57
58
  if (!callback) {
@@ -71,12 +72,14 @@ async function vocabLoader() {
71
72
  }
72
73
  const renderLanguageLoader = renderLanguageLoaderAsync.call(this, devJsonFilePath, loadedTranslation);
73
74
  const loadedLanguages = Object.keys(loadedTranslation.languages);
75
+ const exportName = mlly.findExportNames(source)[0];
74
76
  const result = /* ts */`
75
77
  import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
76
78
 
77
- export default createTranslationFile({
79
+ const translation = createTranslationFile({
78
80
  ${loadedLanguages.map(lang => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(',\n')}
79
81
  });
82
+ export { translation as ${exportName} };
80
83
  `;
81
84
  trace('Created translation file', result);
82
85
  callback(null, result);
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var path = require('path');
6
+ var mlly = require('mlly');
6
7
  var core = require('@vocab/core');
7
8
  var chunkName_dist_vocabWebpackChunkName = require('../../chunk-name/dist/vocab-webpack-chunk-name.cjs.prod.js');
8
9
  var logger = require('../../dist/logger-f79e34a8.cjs.prod.js');
@@ -51,7 +52,7 @@ function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
51
52
  );
52
53
  };
53
54
  }
54
- async function vocabLoader() {
55
+ async function vocabLoader(source) {
55
56
  trace(`Using vocab loader for ${this.resourcePath}`);
56
57
  const callback = this.async();
57
58
  if (!callback) {
@@ -71,12 +72,14 @@ async function vocabLoader() {
71
72
  }
72
73
  const renderLanguageLoader = renderLanguageLoaderAsync.call(this, devJsonFilePath, loadedTranslation);
73
74
  const loadedLanguages = Object.keys(loadedTranslation.languages);
75
+ const exportName = mlly.findExportNames(source)[0];
74
76
  const result = /* ts */`
75
77
  import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
76
78
 
77
- export default createTranslationFile({
79
+ const translation = createTranslationFile({
78
80
  ${loadedLanguages.map(lang => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(',\n')}
79
81
  });
82
+ export { translation as ${exportName} };
80
83
  `;
81
84
  trace('Created translation file', result);
82
85
  callback(null, result);
@@ -1,4 +1,5 @@
1
1
  import path from 'path';
2
+ import { findExportNames } from 'mlly';
2
3
  import { getDevLanguageFileFromTsFile, loadTranslation } from '@vocab/core';
3
4
  import { getChunkName } from '../../chunk-name/dist/vocab-webpack-chunk-name.esm.js';
4
5
  import { t as trace$1 } from '../../dist/logger-e1862ea1.esm.js';
@@ -43,7 +44,7 @@ function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
43
44
  );
44
45
  };
45
46
  }
46
- async function vocabLoader() {
47
+ async function vocabLoader(source) {
47
48
  trace(`Using vocab loader for ${this.resourcePath}`);
48
49
  const callback = this.async();
49
50
  if (!callback) {
@@ -63,12 +64,14 @@ async function vocabLoader() {
63
64
  }
64
65
  const renderLanguageLoader = renderLanguageLoaderAsync.call(this, devJsonFilePath, loadedTranslation);
65
66
  const loadedLanguages = Object.keys(loadedTranslation.languages);
67
+ const exportName = findExportNames(source)[0];
66
68
  const result = /* ts */`
67
69
  import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
68
70
 
69
- export default createTranslationFile({
71
+ const translation = createTranslationFile({
70
72
  ${loadedLanguages.map(lang => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(',\n')}
71
73
  });
74
+ export { translation as ${exportName} };
72
75
  `;
73
76
  trace('Created translation file', result);
74
77
  callback(null, result);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vocab/webpack",
3
- "version": "0.0.0-expose-entry-regex-20230413013100",
3
+ "version": "0.0.0-expose-entry-regex-20230414045557",
4
4
  "main": "dist/vocab-webpack.cjs.js",
5
5
  "module": "dist/vocab-webpack.esm.js",
6
6
  "exports": {
@@ -43,6 +43,7 @@
43
43
  "@vocab/types": "^1.1.2",
44
44
  "chalk": "^4.1.0",
45
45
  "debug": "^4.3.1",
46
+ "mlly": "^1.2.0",
46
47
  "virtual-resource-loader": "^1.0.1"
47
48
  },
48
49
  "devDependencies": {