ag-grid-community 30.0.1 → 30.0.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.
package/.hash CHANGED
@@ -1 +1 @@
1
- 5758559b78ac3a827f52934467a783675af13c81 -
1
+ 2302d391d63164a8d5f6ccd158d13d2ea5ff70c0 -
package/config.js CHANGED
@@ -17,6 +17,7 @@ const builds = {
17
17
  dest: path.resolve(__dirname, './dist/ag-grid-community.cjs.js'),
18
18
  format: 'cjs',
19
19
  env: 'development',
20
+ nodeFormatOverride: 'es5-cjs',
20
21
  banner
21
22
  },
22
23
  'community-cjs-prod': {
@@ -24,6 +25,7 @@ const builds = {
24
25
  dest: path.resolve(__dirname, './dist/ag-grid-community.cjs.min.js'),
25
26
  format: 'cjs',
26
27
  env: 'production',
28
+ nodeFormatOverride: 'es5-cjs',
27
29
  banner
28
30
  },
29
31
  'community-esm-dev': {
@@ -47,16 +49,16 @@ function genConfig(name) {
47
49
  const config = {
48
50
  input: opts.entry,
49
51
  plugins: [
50
- node({browser: true}), // for utils package - defaulting to use index.js
52
+ node({format: opts.nodeFormatOverride }), // for utils package - defaulting to use index.js
51
53
  typescript({
52
54
  tsconfig: "tsconfig.es6.json"
53
- })
55
+ }),
54
56
  ].concat(opts.plugins || []),
55
57
  output: {
56
58
  file: opts.dest,
57
59
  format: opts.format,
58
60
  banner: opts.banner,
59
- name: opts.moduleName
61
+ name: opts.moduleName,
60
62
  },
61
63
  onwarn: (msg, warn) => {
62
64
  if (msg.code === 'THIS_IS_UNDEFINED') return;
package/customise.js ADDED
@@ -0,0 +1,67 @@
1
+ /**
2
+ * There are some issues which we have had to resolve by editing plugins as it was the only way to achieve what we
3
+ * needed to. This script applies these customisations by replacing content inside the node_modules after they've been
4
+ * installed; perhaps we should fork the plugins properly and point to those instead.
5
+ */
6
+
7
+ const fs = require('fs-extra');
8
+
9
+ const applyCustomisation = (packageName, expectedVersion, customisation, providedPath = null, optional = false) => {
10
+ const packagePath = providedPath ? providedPath : `./node_modules/${packageName}/package.json`;
11
+ if (!fs.existsSync(packagePath) && optional) {
12
+ console.log(`${packagePath} doesn't exist but is optional - skipping`);
13
+ return true;
14
+ }
15
+
16
+ const version = require(packagePath).version;
17
+ const versionMatches = version === expectedVersion;
18
+
19
+ if (versionMatches) {
20
+ customisation.apply();
21
+ console.log(`✓ ${customisation.name}`);
22
+ } else {
23
+ console.error(`✗ ${customisation.name}`);
24
+ console.error(`Customisation failed: Expected version ${expectedVersion} of ${packageName} but found ${version}. You should test the customisation with the new version and update the expected version number if it works.`);
25
+ }
26
+
27
+ return versionMatches;
28
+ };
29
+
30
+ const updateFileContents = (filename, existingContent, newContent) => {
31
+ const contents = fs.readFileSync(filename, 'utf8');
32
+ const newContents = contents.replace(existingContent, newContent);
33
+
34
+ if (newContents !== contents) {
35
+ fs.writeFileSync(filename, newContents);
36
+ }
37
+ };
38
+
39
+ const forceEs5ForCjsBundles = () => {
40
+
41
+ return applyCustomisation('rollup-plugin-node-resolve', '5.2.0', {
42
+ name: `Force ES5 for CJS bundles`,
43
+ apply: () => updateFileContents(
44
+ './node_modules/rollup-plugin-node-resolve/dist/rollup-plugin-node-resolve.cjs.js',
45
+ 'if (typeof pkg[field] === \'string\') {',
46
+ `if (options.format === 'es5-cjs') {
47
+ pkg['main'] = "./dist/esm/es5/main.js";
48
+ } else if (typeof pkg[field] === 'string') {`
49
+ )
50
+ });
51
+ };
52
+
53
+ console.log(`--------------------------------------------------------------------------------`);
54
+ console.log(`Applying customisations...`);
55
+
56
+ const success = [
57
+ forceEs5ForCjsBundles(),
58
+ ].every(x => x);
59
+
60
+ if (success) {
61
+ console.log(`Finished!`);
62
+ } else {
63
+ console.error('Failed.');
64
+ process.exitCode = 1;
65
+ }
66
+
67
+ console.log(`--------------------------------------------------------------------------------`);