@vocab/webpack 0.0.0-expose-entry-regex-20230413013100 → 0.0.0-feature-ignore-flag-push-20241014224750

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 +1,2 @@
1
1
  export * from "../../dist/declarations/src/chunk-name";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidm9jYWItd2VicGFjay1jaHVuay1uYW1lLmNqcy5kLnRzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vZGlzdC9kZWNsYXJhdGlvbnMvc3JjL2NodW5rLW5hbWUuZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9
@@ -1,4 +1,4 @@
1
- import { UserConfig } from '@vocab/types';
1
+ import { type UserConfig } from '@vocab/core';
2
2
  import type { Compiler } from 'webpack';
3
3
  interface UserOptions extends Partial<UserConfig> {
4
4
  configFile?: string;
@@ -1,5 +1,5 @@
1
- import { UserConfig } from '@vocab/types';
1
+ import { type UserConfig } from '@vocab/core';
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 {};
@@ -1,3 +1,3 @@
1
- import type { TranslationModule } from '@vocab/types';
1
+ import type { TranslationModule } from '@vocab/core';
2
2
  export { createTranslationFile } from '@vocab/core/translation-file';
3
3
  export declare const createLanguage: (moduleId: string, loadImport: () => Promise<any>) => TranslationModule<any>;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- require('chalk');
3
+ require('picocolors');
4
4
  var debug = require('debug');
5
5
 
6
6
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -1,4 +1,4 @@
1
- import 'chalk';
1
+ import 'picocolors';
2
2
  import debug from 'debug';
3
3
 
4
4
  const trace = debug(`vocab:webpack`);
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- require('chalk');
3
+ require('picocolors');
4
4
  var debug = require('debug');
5
5
 
6
6
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
@@ -1 +1,2 @@
1
1
  export * from "./declarations/src/index";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidm9jYWItd2VicGFjay5janMuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4vZGVjbGFyYXRpb25zL3NyYy9pbmRleC5kLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBIn0=
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@vocab/core');
6
- var logger = require('./logger-65149486.cjs.dev.js');
7
- require('chalk');
6
+ var logger = require('./logger-ebb09632.cjs.dev.js');
7
+ require('picocolors');
8
8
  require('debug');
9
9
 
10
- const compiledVocabFileFilter = /\.vocab[\\\/]index\.(ts|js|cjs|mjs)$/;
10
+ const compiledVocabFileFilter = /\.vocab[\\/]index\.(?:ts|js|cjs|mjs)$/;
11
11
  class VocabWebpackPlugin {
12
12
  constructor({
13
13
  configFile,
@@ -3,11 +3,11 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@vocab/core');
6
- var logger = require('./logger-f79e34a8.cjs.prod.js');
7
- require('chalk');
6
+ var logger = require('./logger-018d2c78.cjs.prod.js');
7
+ require('picocolors');
8
8
  require('debug');
9
9
 
10
- const compiledVocabFileFilter = /\.vocab[\\\/]index\.(ts|js|cjs|mjs)$/;
10
+ const compiledVocabFileFilter = /\.vocab[\\/]index\.(?:ts|js|cjs|mjs)$/;
11
11
  class VocabWebpackPlugin {
12
12
  constructor({
13
13
  configFile,
@@ -1,9 +1,9 @@
1
1
  import { resolveConfigSync, validateConfig } from '@vocab/core';
2
- import { t as trace } from './logger-e1862ea1.esm.js';
3
- import 'chalk';
2
+ import { t as trace } from './logger-c5869e3f.esm.js';
3
+ import 'picocolors';
4
4
  import 'debug';
5
5
 
6
- const compiledVocabFileFilter = /\.vocab[\\\/]index\.(ts|js|cjs|mjs)$/;
6
+ const compiledVocabFileFilter = /\.vocab[\\/]index\.(?:ts|js|cjs|mjs)$/;
7
7
  class VocabWebpackPlugin {
8
8
  constructor({
9
9
  configFile,
@@ -1,2 +1,3 @@
1
1
  export * from "../../dist/declarations/src/loader";
2
2
  export { default } from "../../dist/declarations/src/loader";
3
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidm9jYWItd2VicGFjay1sb2FkZXIuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9kaXN0L2RlY2xhcmF0aW9ucy9zcmMvbG9hZGVyLmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
@@ -4,14 +4,36 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var path = require('path');
6
6
  var core = require('@vocab/core');
7
+ var cjsModuleLexer = require('cjs-module-lexer');
8
+ var esModuleLexer = require('es-module-lexer');
7
9
  var chunkName_dist_vocabWebpackChunkName = require('../../chunk-name/dist/vocab-webpack-chunk-name.cjs.dev.js');
8
- var logger = require('../../dist/logger-65149486.cjs.dev.js');
9
- require('chalk');
10
+ var logger = require('../../dist/logger-ebb09632.cjs.dev.js');
11
+ require('picocolors');
10
12
  require('debug');
11
13
 
12
14
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
13
15
 
16
+ function _interopNamespace(e) {
17
+ if (e && e.__esModule) return e;
18
+ var n = Object.create(null);
19
+ if (e) {
20
+ Object.keys(e).forEach(function (k) {
21
+ if (k !== 'default') {
22
+ var d = Object.getOwnPropertyDescriptor(e, k);
23
+ Object.defineProperty(n, k, d.get ? d : {
24
+ enumerable: true,
25
+ get: function () { return e[k]; }
26
+ });
27
+ }
28
+ });
29
+ }
30
+ n["default"] = e;
31
+ return Object.freeze(n);
32
+ }
33
+
14
34
  var path__default = /*#__PURE__*/_interopDefault(path);
35
+ var cjsModuleLexer__namespace = /*#__PURE__*/_interopNamespace(cjsModuleLexer);
36
+ var esModuleLexer__namespace = /*#__PURE__*/_interopNamespace(esModuleLexer);
15
37
 
16
38
  const trace = logger.trace.extend('loader');
17
39
 
@@ -26,7 +48,7 @@ function createIdentifier(lang, resourcePath, loadedTranslation) {
26
48
  langJson[key] = languageTranslations[key].message;
27
49
  }
28
50
  const base64 = Buffer.from(JSON.stringify(langJson), 'utf-8').toString('base64');
29
- const unloader = `${virtualResourceLoader}?source=${base64}`;
51
+ const unloader = `${virtualResourceLoader}?source=${encodeURIComponent(base64)}`;
30
52
  const fileIdent = path__default["default"].basename(resourcePath, 'translations.json');
31
53
  return `./${fileIdent}-${lang}-virtual.json!=!${unloader}!`;
32
54
  }
@@ -39,7 +61,7 @@ function stringifyRequest(request) {
39
61
  function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
40
62
  return lang => {
41
63
  const identifier = stringifyRequest.call(this, createIdentifier(lang, resourcePath, loadedTranslation));
42
- return (/* ts */`
64
+ return /* ts */`
43
65
  createLanguage(
44
66
  require.resolveWeak(${identifier}),
45
67
  () => import(
@@ -47,11 +69,20 @@ function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
47
69
  ${identifier}
48
70
  )
49
71
  )
50
- `.trim()
51
- );
72
+ `.trim();
52
73
  };
53
74
  }
54
- async function vocabLoader() {
75
+ function findExportNames(source, mode) {
76
+ if (mode === 'esm') {
77
+ const [, exports] = esModuleLexer__namespace.parse(source);
78
+ return exports;
79
+ }
80
+ const {
81
+ exports
82
+ } = cjsModuleLexer__namespace.parse(source);
83
+ return exports;
84
+ }
85
+ async function vocabLoader(source) {
55
86
  trace(`Using vocab loader for ${this.resourcePath}`);
56
87
  const callback = this.async();
57
88
  if (!callback) {
@@ -70,14 +101,35 @@ async function vocabLoader() {
70
101
  return;
71
102
  }
72
103
  const renderLanguageLoader = renderLanguageLoaderAsync.call(this, devJsonFilePath, loadedTranslation);
73
- const loadedLanguages = Object.keys(loadedTranslation.languages);
74
- const result = /* ts */`
75
- import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
76
-
77
- export default createTranslationFile({
78
- ${loadedLanguages.map(lang => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(',\n')}
79
- });
104
+ const translations = /* ts */`
105
+ const translations = createTranslationFile({
106
+ ${Object.keys(loadedTranslation.languages).map(lang => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(',\n')}
107
+ });
80
108
  `;
109
+ let result;
110
+
111
+ // this is necessary for the Web Assembly boot
112
+ await esModuleLexer__namespace.init;
113
+ const esmExports = findExportNames(source, 'esm');
114
+ if (esmExports.length > 0) {
115
+ const exportName = esmExports[0];
116
+ trace(`Found ESM export '${exportName.n}' in ${this.resourcePath}`);
117
+ result = /* ts */`
118
+ import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
119
+ ${translations}
120
+ export { translations as ${exportName.n} };
121
+ `;
122
+ } else {
123
+ // init needs to be called and waited upon
124
+ await cjsModuleLexer__namespace.init();
125
+ const exportName = findExportNames(source, 'cjs')[0];
126
+ trace(`Found CJS export '${exportName}' in ${this.resourcePath}`);
127
+ result = /* ts */`
128
+ const { createLanguage, createTranslationFile } = require('@vocab/webpack/${target}');
129
+ ${translations}
130
+ exports.${exportName} = translations;
131
+ `;
132
+ }
81
133
  trace('Created translation file', result);
82
134
  callback(null, result);
83
135
  }
@@ -4,14 +4,36 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var path = require('path');
6
6
  var core = require('@vocab/core');
7
+ var cjsModuleLexer = require('cjs-module-lexer');
8
+ var esModuleLexer = require('es-module-lexer');
7
9
  var chunkName_dist_vocabWebpackChunkName = require('../../chunk-name/dist/vocab-webpack-chunk-name.cjs.prod.js');
8
- var logger = require('../../dist/logger-f79e34a8.cjs.prod.js');
9
- require('chalk');
10
+ var logger = require('../../dist/logger-018d2c78.cjs.prod.js');
11
+ require('picocolors');
10
12
  require('debug');
11
13
 
12
14
  function _interopDefault (e) { return e && e.__esModule ? e : { 'default': e }; }
13
15
 
16
+ function _interopNamespace(e) {
17
+ if (e && e.__esModule) return e;
18
+ var n = Object.create(null);
19
+ if (e) {
20
+ Object.keys(e).forEach(function (k) {
21
+ if (k !== 'default') {
22
+ var d = Object.getOwnPropertyDescriptor(e, k);
23
+ Object.defineProperty(n, k, d.get ? d : {
24
+ enumerable: true,
25
+ get: function () { return e[k]; }
26
+ });
27
+ }
28
+ });
29
+ }
30
+ n["default"] = e;
31
+ return Object.freeze(n);
32
+ }
33
+
14
34
  var path__default = /*#__PURE__*/_interopDefault(path);
35
+ var cjsModuleLexer__namespace = /*#__PURE__*/_interopNamespace(cjsModuleLexer);
36
+ var esModuleLexer__namespace = /*#__PURE__*/_interopNamespace(esModuleLexer);
15
37
 
16
38
  const trace = logger.trace.extend('loader');
17
39
 
@@ -26,7 +48,7 @@ function createIdentifier(lang, resourcePath, loadedTranslation) {
26
48
  langJson[key] = languageTranslations[key].message;
27
49
  }
28
50
  const base64 = Buffer.from(JSON.stringify(langJson), 'utf-8').toString('base64');
29
- const unloader = `${virtualResourceLoader}?source=${base64}`;
51
+ const unloader = `${virtualResourceLoader}?source=${encodeURIComponent(base64)}`;
30
52
  const fileIdent = path__default["default"].basename(resourcePath, 'translations.json');
31
53
  return `./${fileIdent}-${lang}-virtual.json!=!${unloader}!`;
32
54
  }
@@ -39,7 +61,7 @@ function stringifyRequest(request) {
39
61
  function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
40
62
  return lang => {
41
63
  const identifier = stringifyRequest.call(this, createIdentifier(lang, resourcePath, loadedTranslation));
42
- return (/* ts */`
64
+ return /* ts */`
43
65
  createLanguage(
44
66
  require.resolveWeak(${identifier}),
45
67
  () => import(
@@ -47,11 +69,20 @@ function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
47
69
  ${identifier}
48
70
  )
49
71
  )
50
- `.trim()
51
- );
72
+ `.trim();
52
73
  };
53
74
  }
54
- async function vocabLoader() {
75
+ function findExportNames(source, mode) {
76
+ if (mode === 'esm') {
77
+ const [, exports] = esModuleLexer__namespace.parse(source);
78
+ return exports;
79
+ }
80
+ const {
81
+ exports
82
+ } = cjsModuleLexer__namespace.parse(source);
83
+ return exports;
84
+ }
85
+ async function vocabLoader(source) {
55
86
  trace(`Using vocab loader for ${this.resourcePath}`);
56
87
  const callback = this.async();
57
88
  if (!callback) {
@@ -70,14 +101,35 @@ async function vocabLoader() {
70
101
  return;
71
102
  }
72
103
  const renderLanguageLoader = renderLanguageLoaderAsync.call(this, devJsonFilePath, loadedTranslation);
73
- const loadedLanguages = Object.keys(loadedTranslation.languages);
74
- const result = /* ts */`
75
- import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
76
-
77
- export default createTranslationFile({
78
- ${loadedLanguages.map(lang => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(',\n')}
79
- });
104
+ const translations = /* ts */`
105
+ const translations = createTranslationFile({
106
+ ${Object.keys(loadedTranslation.languages).map(lang => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(',\n')}
107
+ });
80
108
  `;
109
+ let result;
110
+
111
+ // this is necessary for the Web Assembly boot
112
+ await esModuleLexer__namespace.init;
113
+ const esmExports = findExportNames(source, 'esm');
114
+ if (esmExports.length > 0) {
115
+ const exportName = esmExports[0];
116
+ trace(`Found ESM export '${exportName.n}' in ${this.resourcePath}`);
117
+ result = /* ts */`
118
+ import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
119
+ ${translations}
120
+ export { translations as ${exportName.n} };
121
+ `;
122
+ } else {
123
+ // init needs to be called and waited upon
124
+ await cjsModuleLexer__namespace.init();
125
+ const exportName = findExportNames(source, 'cjs')[0];
126
+ trace(`Found CJS export '${exportName}' in ${this.resourcePath}`);
127
+ result = /* ts */`
128
+ const { createLanguage, createTranslationFile } = require('@vocab/webpack/${target}');
129
+ ${translations}
130
+ exports.${exportName} = translations;
131
+ `;
132
+ }
81
133
  trace('Created translation file', result);
82
134
  callback(null, result);
83
135
  }
@@ -1,8 +1,10 @@
1
1
  import path from 'path';
2
2
  import { getDevLanguageFileFromTsFile, loadTranslation } from '@vocab/core';
3
+ import * as cjsModuleLexer from 'cjs-module-lexer';
4
+ import * as esModuleLexer from 'es-module-lexer';
3
5
  import { getChunkName } from '../../chunk-name/dist/vocab-webpack-chunk-name.esm.js';
4
- import { t as trace$1 } from '../../dist/logger-e1862ea1.esm.js';
5
- import 'chalk';
6
+ import { t as trace$1 } from '../../dist/logger-c5869e3f.esm.js';
7
+ import 'picocolors';
6
8
  import 'debug';
7
9
 
8
10
  const trace = trace$1.extend('loader');
@@ -18,7 +20,7 @@ function createIdentifier(lang, resourcePath, loadedTranslation) {
18
20
  langJson[key] = languageTranslations[key].message;
19
21
  }
20
22
  const base64 = Buffer.from(JSON.stringify(langJson), 'utf-8').toString('base64');
21
- const unloader = `${virtualResourceLoader}?source=${base64}`;
23
+ const unloader = `${virtualResourceLoader}?source=${encodeURIComponent(base64)}`;
22
24
  const fileIdent = path.basename(resourcePath, 'translations.json');
23
25
  return `./${fileIdent}-${lang}-virtual.json!=!${unloader}!`;
24
26
  }
@@ -31,7 +33,7 @@ function stringifyRequest(request) {
31
33
  function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
32
34
  return lang => {
33
35
  const identifier = stringifyRequest.call(this, createIdentifier(lang, resourcePath, loadedTranslation));
34
- return (/* ts */`
36
+ return /* ts */`
35
37
  createLanguage(
36
38
  require.resolveWeak(${identifier}),
37
39
  () => import(
@@ -39,11 +41,20 @@ function renderLanguageLoaderAsync(resourcePath, loadedTranslation) {
39
41
  ${identifier}
40
42
  )
41
43
  )
42
- `.trim()
43
- );
44
+ `.trim();
44
45
  };
45
46
  }
46
- async function vocabLoader() {
47
+ function findExportNames(source, mode) {
48
+ if (mode === 'esm') {
49
+ const [, exports] = esModuleLexer.parse(source);
50
+ return exports;
51
+ }
52
+ const {
53
+ exports
54
+ } = cjsModuleLexer.parse(source);
55
+ return exports;
56
+ }
57
+ async function vocabLoader(source) {
47
58
  trace(`Using vocab loader for ${this.resourcePath}`);
48
59
  const callback = this.async();
49
60
  if (!callback) {
@@ -62,14 +73,35 @@ async function vocabLoader() {
62
73
  return;
63
74
  }
64
75
  const renderLanguageLoader = renderLanguageLoaderAsync.call(this, devJsonFilePath, loadedTranslation);
65
- const loadedLanguages = Object.keys(loadedTranslation.languages);
66
- const result = /* ts */`
67
- import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
68
-
69
- export default createTranslationFile({
70
- ${loadedLanguages.map(lang => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(',\n')}
71
- });
76
+ const translations = /* ts */`
77
+ const translations = createTranslationFile({
78
+ ${Object.keys(loadedTranslation.languages).map(lang => `${JSON.stringify(lang)}: ${renderLanguageLoader(lang)}`).join(',\n')}
79
+ });
72
80
  `;
81
+ let result;
82
+
83
+ // this is necessary for the Web Assembly boot
84
+ await esModuleLexer.init;
85
+ const esmExports = findExportNames(source, 'esm');
86
+ if (esmExports.length > 0) {
87
+ const exportName = esmExports[0];
88
+ trace(`Found ESM export '${exportName.n}' in ${this.resourcePath}`);
89
+ result = /* ts */`
90
+ import { createLanguage, createTranslationFile } from '@vocab/webpack/${target}';
91
+ ${translations}
92
+ export { translations as ${exportName.n} };
93
+ `;
94
+ } else {
95
+ // init needs to be called and waited upon
96
+ await cjsModuleLexer.init();
97
+ const exportName = findExportNames(source, 'cjs')[0];
98
+ trace(`Found CJS export '${exportName}' in ${this.resourcePath}`);
99
+ result = /* ts */`
100
+ const { createLanguage, createTranslationFile } = require('@vocab/webpack/${target}');
101
+ ${translations}
102
+ exports.${exportName} = translations;
103
+ `;
104
+ }
73
105
  trace('Created translation file', result);
74
106
  callback(null, result);
75
107
  }
package/package.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "name": "@vocab/webpack",
3
- "version": "0.0.0-expose-entry-regex-20230413013100",
3
+ "version": "0.0.0-feature-ignore-flag-push-20241014224750",
4
+ "repository": {
5
+ "type": "git",
6
+ "url": "https://github.com/seek-oss/vocab.git",
7
+ "directory": "packages/webpack"
8
+ },
4
9
  "main": "dist/vocab-webpack.cjs.js",
5
10
  "module": "dist/vocab-webpack.esm.js",
6
11
  "exports": {
@@ -39,11 +44,12 @@
39
44
  "web"
40
45
  ],
41
46
  "dependencies": {
42
- "@vocab/core": "^1.2.5",
43
- "@vocab/types": "^1.1.2",
44
- "chalk": "^4.1.0",
47
+ "cjs-module-lexer": "^1.2.2",
45
48
  "debug": "^4.3.1",
46
- "virtual-resource-loader": "^1.0.1"
49
+ "es-module-lexer": "^1.0.0",
50
+ "picocolors": "^1.0.0",
51
+ "@vocab/core": "^1.6.2",
52
+ "virtual-resource-loader": "^0.0.0-feature-ignore-flag-push-20241014224750"
47
53
  },
48
54
  "devDependencies": {
49
55
  "@types/debug": "^4.1.5",
@@ -1 +1,2 @@
1
1
  export * from "../../dist/declarations/src/web";
2
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidm9jYWItd2VicGFjay13ZWIuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9kaXN0L2RlY2xhcmF0aW9ucy9zcmMvd2ViLmQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEifQ==
@@ -1,3 +0,0 @@
1
- import debug from 'debug';
2
- export declare const trace: debug.Debugger;
3
- export declare const log: (...params: unknown[]) => void;