piral-core 0.14.0-unstable.3105 → 0.14.0

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,9 +1,35 @@
1
- module.exports = function() {
1
+ function getIdentifiers(packageName) {
2
+ const packageJson = `${packageName}/package.json`;
3
+
4
+ try {
5
+ const details = require(packageJson);
6
+
7
+ if (details.version) {
8
+ return [packageName, `${packageName}@${details.version}`];
9
+ }
10
+ } catch {}
11
+
12
+ return [packageName];
13
+ }
14
+
15
+ module.exports = function () {
2
16
  const appName = process.env.BUILD_PCKG_NAME || '';
3
- const externals = (process.env.SHARED_DEPENDENCIES || '').split(',');
4
- const deps = [`deps['${appName}']={}`, ...externals.map(name => `deps['${name}']=require('${name}')`)];
5
- const code = deps.join(';');
17
+ const externals = (process.env.SHARED_DEPENDENCIES || '').split(',').filter(Boolean);
18
+ const assignments = [];
19
+
20
+ if (appName) {
21
+ assignments.push(`deps['${appName}']={}`);
22
+ }
23
+
24
+ for (const name of externals) {
25
+ const identifiers = getIdentifiers(name);
26
+
27
+ for (const id of identifiers) {
28
+ assignments.push(`deps[${JSON.stringify(id)}]=require(${JSON.stringify(name)})`);
29
+ }
30
+ }
31
+
6
32
  return `module.exports = function(deps){
7
- ${code}
33
+ ${assignments.join(';')}
8
34
  }`;
9
35
  };
@@ -1,24 +1,32 @@
1
1
  import { isfunc } from 'piral-base';
2
+ import { __assign } from 'tslib';
2
3
  /**
3
4
  * The global dependencies, which represent the dependencies
4
5
  * shared from the app shell itself.
5
6
  */
6
- export const globalDependencies = {
7
- react: require('react'),
8
- 'react-dom': require('react-dom'),
9
- 'react-router': require('react-router'),
10
- 'react-router-dom': require('react-router-dom'),
11
- history: require('history'),
12
- tslib: require('tslib'),
13
- 'path-to-regexp': require('path-to-regexp'),
14
- '@libre/atom': require('@libre/atom'),
15
- '@dbeining/react-atom': require('@dbeining/react-atom'),
16
- };
7
+ export const globalDependencies = {};
17
8
  if (process.env.SHARED_DEPENDENCIES) {
18
9
  const fillDependencies = require('../../dependencies.codegen');
19
10
  if (isfunc(fillDependencies)) {
20
11
  fillDependencies(globalDependencies);
21
12
  }
13
+ else {
14
+ // fall back to the default list if the codegen is invalid / not supported
15
+ __assign(globalDependencies, {
16
+ react: require('react'),
17
+ 'react-dom': require('react-dom'),
18
+ 'react-router': require('react-router'),
19
+ 'react-router-dom': require('react-router-dom'),
20
+ history: require('history'),
21
+ tslib: require('tslib'),
22
+ 'path-to-regexp': require('path-to-regexp'),
23
+ '@libre/atom': require('@libre/atom'),
24
+ '@dbeining/react-atom': require('@dbeining/react-atom'),
25
+ });
26
+ }
27
+ }
28
+ else {
29
+ // App shell is built with something else than the Piral CLI - just don't fill ...
22
30
  }
23
31
  /**
24
32
  * The default dependency selector, which just returns the provided
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwC,MAAM,EAAE,MAAM,YAAY,CAAC;AAE1E;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAA0B;IACvD,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;IACjC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC;IACvC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAC/C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAC3C,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IACrC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,CAAC;CACxD,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;IACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAE/D,IAAI,MAAM,CAAC,gB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;;GAGG;AACH,MAAM,UAAU,yBAAyB,CAAC,YAAmC;IAC3E,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC"}
@@ -2,26 +2,34 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultModuleRequester = exports.defaultDependencySelector = exports.globalDependencies = void 0;
4
4
  const piral_base_1 = require("piral-base");
5
+ const tslib_1 = require("tslib");
5
6
  /**
6
7
  * The global dependencies, which represent the dependencies
7
8
  * shared from the app shell itself.
8
9
  */
9
- exports.globalDependencies = {
10
- react: require('react'),
11
- 'react-dom': require('react-dom'),
12
- 'react-router': require('react-router'),
13
- 'react-router-dom': require('react-router-dom'),
14
- history: require('history'),
15
- tslib: require('tslib'),
16
- 'path-to-regexp': require('path-to-regexp'),
17
- '@libre/atom': require('@libre/atom'),
18
- '@dbeining/react-atom': require('@dbeining/react-atom'),
19
- };
10
+ exports.globalDependencies = {};
20
11
  if (process.env.SHARED_DEPENDENCIES) {
21
12
  const fillDependencies = require('../../dependencies.codegen');
22
13
  if ((0, piral_base_1.isfunc)(fillDependencies)) {
23
14
  fillDependencies(exports.globalDependencies);
24
15
  }
16
+ else {
17
+ // fall back to the default list if the codegen is invalid / not supported
18
+ (0, tslib_1.__assign)(exports.globalDependencies, {
19
+ react: require('react'),
20
+ 'react-dom': require('react-dom'),
21
+ 'react-router': require('react-router'),
22
+ 'react-router-dom': require('react-router-dom'),
23
+ history: require('history'),
24
+ tslib: require('tslib'),
25
+ 'path-to-regexp': require('path-to-regexp'),
26
+ '@libre/atom': require('@libre/atom'),
27
+ '@dbeining/react-atom': require('@dbeining/react-atom'),
28
+ });
29
+ }
30
+ }
31
+ else {
32
+ // App shell is built with something else than the Piral CLI - just don't fill ...
25
33
  }
26
34
  /**
27
35
  * The default dependency selector, which just returns the provided
@@ -1 +1 @@
1
- {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":";;;AAAA,2CAA0E;AAE1E;;;GAGG;AACU,QAAA,kBAAkB,GAA0B;IACvD,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;IACjC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC;IACvC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,CAAC;IAC/C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;IACvB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC;IAC3C,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;IACrC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,CAAC;CACxD,CAAC;AAEF,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;IACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAE/D,IAAI,IAAA,mBAAM,EAAC,gBAAgB,CAAC,EAAE;QAC5B,gBAAgB,CAAC,0BAAkB,CAAC,CAAC;KACtC;CACF;AAED;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,YAAmC;IAC3E,OAAO,YAAY,CAAC;AACtB,CAAC;AAFD,8DAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC;AAFD,wDAEC"}
1
+ {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../src/modules/dependencies.ts"],"names":[],"mappings":";;;AAAA,2CAA0E;AAC1E,iCAAiC;AAEjC;;;GAGG;AACU,QAAA,kBAAkB,GAA0B,EAAE,CAAC;AAE5D,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE;IACnC,MAAM,gBAAgB,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;IAE/D,IAAI,IAAA,mBAAM,EAAC,gBAAgB,CAAC,EAAE;QAC5B,gBAAgB,CAAC,0BAAkB,CAAC,CAAC;KACtC;SAAM;QACL,0EAA0E;QAC1E,IAAA,gBAAQ,EAAC,0BAAkB,EAAE;YAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;YACvB,WAAW,EAAE,OAAO,CAAC,WAAW,CAAC;YACjC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC;YACvC,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,CAAC;YAC/C,OAAO,EAAE,OAAO,CAAC,SAAS,CAAC;YAC3B,KAAK,EAAE,OAAO,CAAC,OAAO,CAAC;YACvB,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,CAAC;YAC3C,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;YACrC,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,CAAC;SACxD,CAAC,CAAC;KACJ;CACF;KAAM;IACL,kFAAkF;CACnF;AAED;;;GAGG;AACH,SAAgB,yBAAyB,CAAC,YAAmC;IAC3E,OAAO,YAAY,CAAC;AACtB,CAAC;AAFD,8DAEC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC;AAFD,wDAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piral-core",
3
- "version": "0.14.0-unstable.3105",
3
+ "version": "0.14.0",
4
4
  "description": "The core library for creating a Piral instance.",
5
5
  "keywords": [
6
6
  "portal",
@@ -62,10 +62,21 @@
62
62
  "react-router": ">=5.0.0",
63
63
  "react-router-dom": ">=5.0.0"
64
64
  },
65
+ "sharedDependencies": [
66
+ "react",
67
+ "react-dom",
68
+ "react-router",
69
+ "react-router-dom",
70
+ "history",
71
+ "tslib",
72
+ "path-to-regexp",
73
+ "@libre/atom",
74
+ "@dbeining/react-atom"
75
+ ],
65
76
  "dependencies": {
66
77
  "@dbeining/react-atom": "^4.0.0",
67
- "piral-base": "^0.14.0-unstable.3105",
68
- "piral-debug-utils": "^0.14.0-unstable.3105"
78
+ "piral-base": "^0.14.0",
79
+ "piral-debug-utils": "^0.14.0"
69
80
  },
70
- "gitHead": "f0732b5a8decdddc5abd7c50a05af59dbcb03912"
81
+ "gitHead": "42d3691018d6fa49c2dd18a0b65e4f89961216b0"
71
82
  }
@@ -1,12 +1,10 @@
1
1
  import { globalDependencies, defaultDependencySelector, defaultModuleRequester } from './dependencies';
2
2
 
3
3
  describe('Dependencies Module', () => {
4
- it('globalDependencies should contain global dependencies', () => {
5
- expect(globalDependencies).toHaveProperty('react');
6
- expect(globalDependencies).toHaveProperty('history');
7
- expect(globalDependencies).not.toHaveProperty('foo');
4
+ it('globalDependencies should not contain any dependencies', () => {
5
+ expect(globalDependencies).toEqual({});
8
6
  });
9
-
7
+
10
8
  it('defaultDependencySelector should return given dependencies', () => {
11
9
  const deps = defaultDependencySelector({
12
10
  foo: 'bar',
@@ -14,7 +12,7 @@ describe('Dependencies Module', () => {
14
12
  expect(deps).toHaveProperty('foo');
15
13
  expect(deps).not.toHaveProperty('bar');
16
14
  });
17
-
15
+
18
16
  it('defaultModuleRequester should return given dependencies', async () => {
19
17
  const mods = await defaultModuleRequester();
20
18
  expect(mods).toEqual([]);
@@ -1,27 +1,33 @@
1
1
  import { PiletMetadata, AvailableDependencies, isfunc } from 'piral-base';
2
+ import { __assign } from 'tslib';
2
3
 
3
4
  /**
4
5
  * The global dependencies, which represent the dependencies
5
6
  * shared from the app shell itself.
6
7
  */
7
- export const globalDependencies: AvailableDependencies = {
8
- react: require('react'),
9
- 'react-dom': require('react-dom'),
10
- 'react-router': require('react-router'),
11
- 'react-router-dom': require('react-router-dom'),
12
- history: require('history'),
13
- tslib: require('tslib'),
14
- 'path-to-regexp': require('path-to-regexp'),
15
- '@libre/atom': require('@libre/atom'),
16
- '@dbeining/react-atom': require('@dbeining/react-atom'),
17
- };
8
+ export const globalDependencies: AvailableDependencies = {};
18
9
 
19
10
  if (process.env.SHARED_DEPENDENCIES) {
20
11
  const fillDependencies = require('../../dependencies.codegen');
21
12
 
22
13
  if (isfunc(fillDependencies)) {
23
14
  fillDependencies(globalDependencies);
15
+ } else {
16
+ // fall back to the default list if the codegen is invalid / not supported
17
+ __assign(globalDependencies, {
18
+ react: require('react'),
19
+ 'react-dom': require('react-dom'),
20
+ 'react-router': require('react-router'),
21
+ 'react-router-dom': require('react-router-dom'),
22
+ history: require('history'),
23
+ tslib: require('tslib'),
24
+ 'path-to-regexp': require('path-to-regexp'),
25
+ '@libre/atom': require('@libre/atom'),
26
+ '@dbeining/react-atom': require('@dbeining/react-atom'),
27
+ });
24
28
  }
29
+ } else {
30
+ // App shell is built with something else than the Piral CLI - just don't fill ...
25
31
  }
26
32
 
27
33
  /**