@mirta/rollup 0.3.1 → 0.3.2

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.
Files changed (2) hide show
  1. package/dist/index.mjs +27 -31
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -208,7 +208,7 @@ function wbRulesImports() {
208
208
 
209
209
  const env = process.env.NODE_ENV;
210
210
  const isProduction = env === 'production';
211
- const packagesPattern = /node_modules[\\/]@?(.+)[\\/](.+)/;
211
+ const packagesPattern = /(.*)node_modules[\\/]@?(.+)[\\/](.+)?/;
212
212
  const modulesPattern = /(?:src[\\/])?wb-rules-modules[\\/](.*)/;
213
213
  const scriptsPattern = /(?:src[\\/])?(?:wb-rules[\\/])?(.*)/;
214
214
  const outputDir = {
@@ -238,46 +238,42 @@ function globRelative(path, pattern) {
238
238
  }
239
239
  return pathParts.slice(i).join('/');
240
240
  }
241
- function packageEntry(pkg, entry) {
242
- const key = entry ? `${pkg}/${entry}` : pkg;
243
- // if ((process.env.NODE_ENV !== 'production'))
244
- // console.debug(`Package Entry: ${key}`)
245
- return `wb-rules-modules/packages/${key}.js`;
241
+ function tryGetPackageEntry(sourcePath) {
242
+ const pathParts = [];
243
+ do {
244
+ const match = packagesPattern.exec(sourcePath);
245
+ if (!match)
246
+ break;
247
+ if (match[3])
248
+ pathParts.unshift(match[3]);
249
+ pathParts.unshift('packages/' + match[2].replace(/\/dist$/, ''));
250
+ sourcePath = match[1];
251
+ } while (sourcePath);
252
+ if (pathParts.length)
253
+ return `wb-rules-modules/${pathParts.join('/')}.js`;
246
254
  }
247
- function moduleEntry(entry) {
255
+ function tryGetModuleEntry(sourcePath) {
256
+ const match = modulesPattern.exec(sourcePath);
257
+ if (!match)
258
+ return;
248
259
  // if ((process.env.NODE_ENV !== 'production'))
249
260
  // console.debug(`Module Entry: ${entry}`)
250
- return `wb-rules-modules/${entry}.js`;
261
+ return `wb-rules-modules/${match[1]}.js`;
251
262
  }
252
- function scriptEntry(entry) {
263
+ function tryGetScriptEntry(sourcePath) {
264
+ const match = scriptsPattern.exec(sourcePath);
265
+ if (!match)
266
+ return;
253
267
  // if ((process.env.NODE_ENV !== 'production'))
254
268
  // console.debug(`Script Entry: ${entry}`)
255
- return `wb-rules/${entry}.js`;
269
+ return `wb-rules/${match[1]}.js`;
256
270
  }
257
271
  function getEntry(path) {
258
272
  if (path.startsWith('_virtual'))
259
273
  return path;
260
- let match;
261
- match = packagesPattern.exec(path);
262
- if (match) {
263
- // if ((process.env.NODE_ENV !== 'production'))
264
- // console.debug(match)
265
- return packageEntry(match[1].replace(/\/dist$/, ''), match[2]);
266
- }
267
- match = modulesPattern.exec(path);
268
- if (match) {
269
- // if ((process.env.NODE_ENV !== 'production'))
270
- // console.debug(match)
271
- return moduleEntry(match[1]);
272
- }
273
- match = scriptsPattern.exec(path);
274
- if (match) {
275
- // if ((process.env.NODE_ENV !== 'production'))
276
- // console.debug(match)
277
- return scriptEntry(match[1]);
278
- }
279
- // console.log(`No one! ${path}`)
280
- return path;
274
+ return tryGetPackageEntry(path) ?? tryGetModuleEntry(path) ?? tryGetScriptEntry(path)
275
+ // None of the above matched.
276
+ ?? path;
281
277
  }
282
278
  function defineRuntimeConfig(options = {}) {
283
279
  const { cwd = process.cwd(), external, monorepo, dotenv: dotenvOptions = {}, plugins = [], } = options;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mirta/rollup",
3
3
  "description": "Predefined Rollup configuration for wb-rules project builds.",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "license": "Unlicense",
6
6
  "keywords": [
7
7
  "mirta",
@@ -37,7 +37,7 @@
37
37
  "@rollup/plugin-commonjs": "^28.0.6",
38
38
  "@rollup/plugin-babel": "^6.0.4",
39
39
  "@rollup/plugin-multi-entry": "^6.0.1",
40
- "@rollup/plugin-node-resolve": "^16.0.1",
40
+ "@rollup/plugin-node-resolve": "^16.0.2",
41
41
  "@rollup/plugin-typescript": "^12.1.4",
42
42
  "babel-plugin-array-includes": "^2.0.3",
43
43
  "del": "^8.0.1",
@@ -45,10 +45,10 @@
45
45
  "rollup-plugin-dts": "^6.2.3",
46
46
  "rollup-plugin-typescript2": "^0.36.0",
47
47
  "typescript": "^5.8.3",
48
- "@mirta/polyfills": "0.3.1"
48
+ "@mirta/polyfills": "0.3.2"
49
49
  },
50
50
  "devDependencies": {
51
- "rollup": "^4.52.3"
51
+ "rollup": "^4.52.4"
52
52
  },
53
53
  "scripts": {
54
54
  "clean": "rimraf dist",