@common-stack/generate-plugin 7.0.4-alpha.1 → 7.0.4-alpha.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 (34) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/lib/generators/add-fullstack/files/package.json +1 -1
  3. package/lib/generators/add-fullstack/files/rollup.config.base.mjs +45 -22
  4. package/lib/generators/add-package/files/browser/rollup.config.mjs +1 -1
  5. package/lib/generators/add-package/files/browser/tsconfig.json +15 -27
  6. package/lib/generators/add-package/files/client/rollup.config.mjs +30 -25
  7. package/lib/generators/add-package/files/client/tsconfig.json +13 -26
  8. package/lib/generators/add-package/files/core/rollup.config.mjs +33 -61
  9. package/lib/generators/add-package/files/core/tsconfig.json +12 -21
  10. package/lib/generators/add-package/files/server/rollup.config.mjs +31 -24
  11. package/lib/generators/add-package/files/server/tsconfig.json +15 -25
  12. package/lib/generators/add-package/generator.cjs +53 -11
  13. package/lib/generators/add-package/generator.cjs.map +1 -1
  14. package/lib/generators/add-package/generator.d.ts +4 -1
  15. package/lib/generators/add-package/generator.mjs +53 -11
  16. package/lib/generators/add-package/generator.mjs.map +1 -1
  17. package/package.json +2 -2
  18. package/src/generators/add-fullstack/files/package.json +1 -1
  19. package/src/generators/add-fullstack/files/rollup.config.base.mjs +45 -22
  20. package/src/generators/add-package/files/browser/rollup.config.mjs +1 -1
  21. package/src/generators/add-package/files/browser/tsconfig.json +15 -27
  22. package/src/generators/add-package/files/client/rollup.config.mjs +30 -25
  23. package/src/generators/add-package/files/client/tsconfig.json +13 -26
  24. package/src/generators/add-package/files/core/rollup.config.mjs +33 -61
  25. package/src/generators/add-package/files/core/tsconfig.json +12 -21
  26. package/src/generators/add-package/files/server/rollup.config.mjs +31 -24
  27. package/src/generators/add-package/files/server/tsconfig.json +15 -25
  28. package/src/generators/add-package/generator.ts +75 -17
  29. package/lib/generators/add-package/files/browser/webpack.config.js +0 -71
  30. package/lib/generators/add-package/files/client/webpack.config.js +0 -72
  31. package/lib/generators/add-package/files/core/webpack.config.js +0 -53
  32. package/src/generators/add-package/files/browser/webpack.config.js +0 -71
  33. package/src/generators/add-package/files/client/webpack.config.js +0 -72
  34. package/src/generators/add-package/files/core/webpack.config.js +0 -53
@@ -1,4 +1,4 @@
1
- import {__awaiter}from'tslib';import {formatFiles,generateFiles,updateJson}from'@nx/devkit';import*as path from'path';import {isValid,getValid}from'../../utils/index.mjs';import {processFiles}from'../../utils/filesConfig.mjs';import {syncConfig}from'../../utils/syncConfig.mjs';function addPackageGenerator(tree, options) {
1
+ import {__awaiter}from'tslib';import {formatFiles,offsetFromRoot,generateFiles,updateJson}from'@nx/devkit';import*as path from'path';import {isValid,getValid}from'../../utils/index.mjs';import {processFiles}from'../../utils/filesConfig.mjs';import {syncConfig}from'../../utils/syncConfig.mjs';import {renameDotFiles,copyNpmrc}from'../../utils/copyDotfiles.mjs';function addPackageGenerator(tree, options) {
2
2
  return __awaiter(this, void 0, void 0, function* () {
3
3
  if (!isValid(options.name)) {
4
4
  console.error('Package name can not be empty, please try again!');
@@ -14,7 +14,7 @@ import {__awaiter}from'tslib';import {formatFiles,generateFiles,updateJson}from'
14
14
  generatePackage(tree, Object.assign(Object.assign({}, options), { type: packageType.toLocaleLowerCase() }), true);
15
15
  }
16
16
  else {
17
- packages.forEach(pkg => {
17
+ packages.forEach((pkg) => {
18
18
  const configs = Object.assign(Object.assign({}, options), { type: pkg });
19
19
  generatePackage(tree, configs, true);
20
20
  });
@@ -31,20 +31,62 @@ import {__awaiter}from'tslib';import {formatFiles,generateFiles,updateJson}from'
31
31
  // await formatFiles(tree);
32
32
  // }
33
33
  const generatePackage = (tree_1, options_1, ...args_1) => __awaiter(void 0, [tree_1, options_1, ...args_1], void 0, function* (tree, options, cmdLine = false) {
34
- const basePath = `${options.name}/${options.type}`;
35
- const packageRoot = isValid(options.directory) ? `${getValid(options.directory)}/${basePath}` : basePath;
36
- const baseName = isValid(options.name) ? `${options.name}-${options.type}` : options.type;
37
- const packageName = isValid(options.ns) ? `${getValid(options.ns)}-${baseName}` : baseName;
38
- generateFiles(tree, path.join(__dirname, 'files', options.type), packageRoot, options);
39
- updateJson(tree, `${packageRoot}/package.json`, (packageJson) => {
40
- packageJson['name'] = packageName;
34
+ var _a, _b;
35
+ const packageName = (_a = getValid(options.name)) !== null && _a !== void 0 ? _a : 'empty-package';
36
+ let projectRoot = '';
37
+ if (isValid(options.directory)) {
38
+ projectRoot = `${getValid(options.directory)}/${packageName}`;
39
+ }
40
+ else {
41
+ projectRoot = `packages/${packageName}`;
42
+ }
43
+ // Namespace the package if provided
44
+ let fullPackageName = packageName;
45
+ if (isValid(options.ns)) {
46
+ fullPackageName = `${getValid(options.ns)}-${packageName}`;
47
+ }
48
+ // Calculate the offset from root for relative paths in templates
49
+ const offset = offsetFromRoot(projectRoot);
50
+ // Define template options with offsetFromRoot for relative paths
51
+ const templateOptions = Object.assign(Object.assign({}, options), { name: fullPackageName, offsetFromRoot: offset, template: '', dot: '.' });
52
+ // Determine the package type and generate files accordingly
53
+ const packageType = (_b = getValid(options.type)) !== null && _b !== void 0 ? _b : 'core';
54
+ console.log(`Generating ${packageType} package: ${fullPackageName} at ${projectRoot}`);
55
+ // Generate the appropriate package files based on type
56
+ switch (packageType) {
57
+ case 'browser':
58
+ generateFiles(tree, path.join(__dirname, 'files', 'browser'), projectRoot, templateOptions);
59
+ break;
60
+ case 'client':
61
+ generateFiles(tree, path.join(__dirname, 'files', 'client'), projectRoot, templateOptions);
62
+ break;
63
+ case 'server':
64
+ generateFiles(tree, path.join(__dirname, 'files', 'server'), projectRoot, templateOptions);
65
+ break;
66
+ case 'core':
67
+ default:
68
+ generateFiles(tree, path.join(__dirname, 'files', 'core'), projectRoot, templateOptions);
69
+ break;
70
+ }
71
+ // Rename underscore-prefixed files to dot files
72
+ renameDotFiles(tree, projectRoot);
73
+ // Copy .npmrc from the main project root if exists
74
+ const mainProjectRoot = options.projectRoot || '';
75
+ copyNpmrc(tree, mainProjectRoot, projectRoot);
76
+ // Update package.json with the correct package name
77
+ updateJson(tree, `${projectRoot}/package.json`, (packageJson) => {
78
+ packageJson.name = fullPackageName;
41
79
  return packageJson;
42
80
  });
43
81
  if (cmdLine) {
44
- syncConfig(tree, packageRoot, options);
82
+ syncConfig(tree, projectRoot, options);
45
83
  }
46
84
  else {
47
- processFiles(tree, packageRoot, options);
85
+ processFiles(tree, projectRoot, options);
48
86
  yield formatFiles(tree);
49
87
  }
88
+ return {
89
+ packageName: fullPackageName,
90
+ projectRoot,
91
+ };
50
92
  });export{addPackageGenerator,addPackageGenerator as default,generatePackage};//# sourceMappingURL=generator.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"generator.mjs","sources":["../../../src/generators/add-package/generator.ts"],"sourcesContent":[null],"names":[],"mappings":"sRAOsB,SAAA,mBAAmB,CAAC,IAAU,EAAE,OAAkC,EAAA;;QACpF,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;AACxB,YAAA,OAAO,CAAC,KAAK,CAAC,kDAAkD,CAAC,CAAC;YAClE,OAAO;SACV;QAED,MAAM,QAAQ,GAAG,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;QACzD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,IAAI,WAAW,IAAI,WAAW,CAAC,iBAAiB,EAAE,KAAK,KAAK,EAAE;YAC1D,IAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;AAChC,gBAAA,OAAO,CAAC,KAAK,CAAC,gFAAgF,CAAC,CAAC;gBAChG,OAAO;aACV;AACD,YAAA,eAAe,CAAC,IAAI,EAAM,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,KAAE,IAAI,EAAE,WAAW,CAAC,iBAAiB,EAAE,EAAG,CAAA,EAAA,IAAI,CAAC,CAA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C,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,WAAW,EAAE,eAAe,CAAC,CAAC;YACzF,MAAM;KACb;;AAGD,IAAA,cAAc,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;;AAGlC,IAAA,MAAM,eAAe,GAAG,OAAO,CAAC,WAAW,IAAI,EAAE,CAAC;AAClD,IAAA,SAAS,CAAC,IAAI,EAAE,eAAe,EAAE,WAAW,CAAC,CAAC;;IAG9C,UAAU,CAAC,IAAI,EAAE,CAAG,EAAA,WAAW,eAAe,EAAE,CAAC,WAAW,KAAI;AAC5D,QAAA,WAAW,CAAC,IAAI,GAAG,eAAe,CAAC;AACnC,QAAA,OAAO,WAAW,CAAC;AACvB,KAAC,CAAC,CAAC;IAEH,IAAI,OAAO,EAAE;AACT,QAAA,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;KAC1C;SAAM;AACH,QAAA,YAAY,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;AACzC,QAAA,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;KAC3B;IAED,OAAO;AACH,QAAA,WAAW,EAAE,eAAe;QAC5B,WAAW;KACd,CAAC;AACN,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/generate-plugin",
3
- "version": "7.0.4-alpha.1",
3
+ "version": "7.0.4-alpha.2",
4
4
  "type": "module",
5
5
  "main": "./lib/index.mjs",
6
6
  "typings": "./lib/index.d.ts",
@@ -26,5 +26,5 @@
26
26
  },
27
27
  "executors": "./executors.json",
28
28
  "generators": "./generators.json",
29
- "gitHead": "2191788389a85def10699cb0114c12b780291c24"
29
+ "gitHead": "6f0008c84e4b55390bc23edf6689934300fa3aca"
30
30
  }
@@ -145,7 +145,7 @@
145
145
  "@babel/register": "^7.18.9",
146
146
  "@babel/runtime": "^7.20.1",
147
147
  "@common-stack/env-list-loader": "7.0.4-alpha.0",
148
- "@common-stack/generate-plugin": "7.0.4-alpha.0",
148
+ "@common-stack/generate-plugin": "7.0.4-alpha.1",
149
149
  "@common-stack/rollup-vite-utils": "7.0.4-alpha.0",
150
150
  "@emotion/babel-plugin": "^11.11.0",
151
151
  "@graphql-codegen/add": "^5.0.3",
@@ -2,16 +2,22 @@
2
2
  import graphql from '@rollup/plugin-graphql';
3
3
  import image from '@rollup/plugin-image';
4
4
  import typescript from '@rollup/plugin-typescript';
5
+ import esbuild from 'rollup-plugin-esbuild'
5
6
  import { string } from 'rollup-plugin-string';
6
7
  import svg from 'rollup-plugin-svg';
7
8
  import { copy } from '@web/rollup-plugin-copy';
9
+ import json from '@rollup/plugin-json';
8
10
  import modifyLibFilesPlugin from '@common-stack/rollup-vite-utils/lib/rollup/rollupPluginModifyLibFiles.js';
9
11
  import generateJsonFromObject from '@common-stack/rollup-vite-utils/lib/rollup/rollupPluginGenerateJson.js';
10
12
  import addJsExtensionToImportsPlugin from '@common-stack/rollup-vite-utils/lib/rollup/rollupPluginAddJsExtension.js';
11
13
  import { ignoreCssUrlPlugin } from '@common-stack/rollup-vite-utils/lib/rollup/pluginIgnore.js';
12
14
  // Define any additional plugins specific to this bundle
13
15
  const additionalPlugins = [
14
- copy({ patterns: ['**/cdm-locales/**/*', '**/*.gql', '**/**/*.graphql', '**/styles/**/*', '**/css/**/*'], rootDir: './src' }),
16
+ copy({
17
+ patterns: ['**/cdm-locales/**/*', '**/*.gql', '**/**/*.graphql', '**/styles/**/*', '**/templates/**/*', '**/css/**/*'],
18
+ rootDir: './src',
19
+ }),
20
+ json(),
15
21
  ];
16
22
 
17
23
  function deepMergeConfigs(baseConfig, specificConfig) {
@@ -37,37 +43,54 @@ const baseConfig = {
37
43
  addJsExtensionToImportsPlugin({
38
44
  packages: '*',
39
45
  needToAddIndexJs: [],
40
- excludeImports: ['@emotion/react/jsx-runtime'],
46
+ // exclude fs/promises from modifying
47
+ excludeImports: ['@emotion/react/jsx-runtime', 'fs/promises', '@apollo/server*'],
41
48
  }),
42
- typescript(), // TypeScript at the top as per best practices
49
+ typescript(), // Initially include the TypeScript plugin
43
50
  ignoreCssUrlPlugin(),
44
- modifyLibFilesPlugin({
45
- include: ['**/**/compute.js'], // Adjust to target specific files or patterns
46
- outputDir: 'lib', // Ensure this matches your actual output directory
47
- }),
48
- generateJsonFromObject({}),
49
-
50
51
  ...additionalPlugins,
51
52
  ],
52
53
  external: (id) => !/^[./]/.test(id),
53
54
  globals: { react: 'React' },
54
55
  };
55
56
 
56
- // Function to create a configuration by extending the base
57
- function createRollupConfig(overrides, isWatchMode = false) {
58
- const config = deepMergeConfigs(baseConfig, overrides);
57
+ // Updated createRollupConfig function to accept an options object as the second parameter.
58
+ // If useEsbuild is true, the TypeScript plugin is removed completely and replaced with the esbuild plugin.
59
+ function createRollupConfig(specificOverrides, options = {}) {
60
+ const { useEsbuild, isWatchMode, generateRoutesJSON } = options;
61
+ const config = deepMergeConfigs(baseConfig, specificOverrides);
59
62
 
60
- // Adjust TypeScript plugin based on watch mode
61
- config.plugins = config.plugins.map((plugin) => {
62
- if (plugin.name === 'typescript') {
63
- return typescript({
64
- ...plugin.options,
65
- noEmitOnError: !isWatchMode, // Set to false only in watch mode
66
- });
67
- }
68
- return plugin;
69
- });
63
+ // Conditionally add both modifyLibFilesPlugin and generateJsonFromObject plugins if generateRoutesJSON option is provided.
64
+ if (generateRoutesJSON) {
65
+ // Add modifyLibFilesPlugin with predetermined configuration.
66
+ config.plugins.push(modifyLibFilesPlugin({
67
+ include: ['**/**/compute.js'], // Adjust to target specific files or patterns
68
+ outputDir: 'lib', // Ensure this matches your actual output directory
69
+ }));
70
+ // Allow generateRoutesJSON to be an object with plugin configuration or simply a boolean.
71
+ const jsonConfig = typeof generateRoutesJSON === 'object' ? generateRoutesJSON : {};
72
+ config.plugins.push(generateJsonFromObject(jsonConfig));
73
+ }
70
74
 
75
+ if (useEsbuild) {
76
+ // Remove the TypeScript plugin completely.
77
+ config.plugins = config.plugins.filter((plugin) => plugin.name !== 'typescript');
78
+ // Add the esbuild plugin only. Note: The "watch" option is removed as it's not supported by esbuild.
79
+ config.plugins.push(esbuild({
80
+ target: 'es2017', // Adjust the target as needed
81
+ }));
82
+ } else {
83
+ // Retain the TypeScript plugin and adjust its options based on watch mode.
84
+ config.plugins = config.plugins.map((plugin) => {
85
+ if (plugin.name === 'typescript') {
86
+ return typescript({
87
+ ...plugin.options,
88
+ noEmitOnError: !isWatchMode, // Adjust based on watch mode
89
+ });
90
+ }
91
+ return plugin;
92
+ });
93
+ }
71
94
  return config;
72
95
  }
73
96
 
@@ -1,4 +1,4 @@
1
- import { createRollupConfig } from '../../../rollup.config.base.mjs';
1
+ import { createRollupConfig } from '<%= offsetFromRoot %>rollup.config.base.mjs';
2
2
  // Define any additional plugins specific to this bundle
3
3
  const additionalPlugins = [
4
4
  ];
@@ -1,28 +1,16 @@
1
1
  {
2
- "extends": "../../../tsconfig.json",
3
- "compilerOptions": {
4
- "sourceMap": true,
5
- "resolveJsonModule": true,
6
- "rootDir": "src",
7
- "outDir": "lib",
8
- "declaration": true,
9
- "declarationDir": "lib",
10
- "types": [
11
- "@types/node",
12
- "@types/jest",
13
- "../../../typings",
14
- ],
15
- "skipLibCheck": true
16
- },
17
- "include": [
18
- "src"
19
- ],
20
- "exclude": [
21
- "../../../node_modules",
22
- "node_modules",
23
- "lib",
24
- "lib",
25
- "webpack.config.js",
26
- "rollup.config.mjs"
27
- ]
28
- }
2
+ "extends": "<%= offsetFromRoot %>tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "outDir": "lib",
5
+ "rootDir": "./src",
6
+ "sourceMap": true,
7
+ "noImplicitAny": true,
8
+ "declaration": true,
9
+ "lib": ["es6", "dom", "esnext", "es2015.core"],
10
+ "allowSyntheticDefaultImports": true,
11
+ "esModuleInterop": true,
12
+ "jsx": "react"
13
+ },
14
+ "include": ["src"],
15
+ "exclude": ["node_modules", "lib"]
16
+ }
@@ -1,29 +1,34 @@
1
- import { createRollupConfig } from '../../../rollup.config.base.mjs';
1
+ import { createRollupConfig } from '<%= offsetFromRoot %>rollup.config.base.mjs';
2
2
 
3
3
  // Define any additional plugins specific to this bundle
4
- const additionalPlugins = [
5
- ];
4
+ const additionalPlugins = [];
6
5
 
7
6
  // Use the createRollupConfig function to merge the base and specific configurations
8
- export default [
9
- createRollupConfig({
10
- input: ['src/index.ts'],
11
- plugins: [
12
- // Spread in additional plugins specific to this config
13
- ...additionalPlugins,
14
- ],
15
- output: [
16
- {
17
- dir: 'lib',
18
- format: 'es',
19
- name: 'Client',
20
- compact: true,
21
- exports: 'named',
22
- sourcemap: true,
23
- preserveModules: true,
24
- chunkFileNames: '[name]-[hash].[format].js',
25
- globals: { react: 'React' },
26
- },
27
- ],
28
- }),
29
- ];
7
+ export default (commandLineArgs) => {
8
+ const isWatchMode = commandLineArgs.watch;
9
+ return [
10
+ createRollupConfig({
11
+ input: ['src/index.ts'],
12
+ plugins: [
13
+ // Spread in additional plugins specific to this config
14
+ ...additionalPlugins,
15
+ ],
16
+ output: [
17
+ {
18
+ dir: 'lib',
19
+ format: 'es',
20
+ name: 'Accounts',
21
+ compact: true,
22
+ exports: 'named',
23
+ sourcemap: true,
24
+ preserveModules: true,
25
+ chunkFileNames: '[name]-[hash].[format].js',
26
+ globals: { react: 'React' },
27
+ },
28
+ ],
29
+ }, {
30
+ isWatchMode,
31
+ generateRoutesJSON: false,
32
+ }),
33
+ ];
34
+ };
@@ -1,27 +1,14 @@
1
1
  {
2
- "extends": "../../../tsconfig.json",
3
- "compilerOptions": {
4
- "jsx": "react",
5
- "rootDir": "src",
6
- "outDir": "lib",
7
- "declaration": true,
8
- "declarationDir": "lib",
9
- "types": [
10
- "@types/node",
11
- "@types/jest",
12
- "../../../typings",
13
- ],
14
- "skipLibCheck": true
15
- },
16
- "include": [
17
- "src"
18
- ],
19
- "exclude": [
20
- "../../../node_modules",
21
- "node_modules",
22
- "lib",
23
- "lib",
24
- "webpack.config.js",
25
- "rollup.config.mjs"
26
- ]
27
- }
2
+ "extends": "<%= offsetFromRoot %>tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "jsx": "react",
5
+ "rootDir": "src",
6
+ "outDir": "lib",
7
+ "declaration": true,
8
+ "declarationDir": "lib",
9
+ "types": ["@types/node", "@types/jest", "../../../typings"],
10
+ "skipLibCheck": true
11
+ },
12
+ "include": ["src"],
13
+ "exclude": ["../../../node_modules", "node_modules", "lib", "webpack.config.js", "rollup.config.mjs"]
14
+ }
@@ -1,65 +1,37 @@
1
- import graphql from '@rollup/plugin-graphql';
2
- import image from '@rollup/plugin-image';
3
- import typescript from '@rollup/plugin-typescript';
4
- import { string } from 'rollup-plugin-string';
5
- function appendJsExtensionForMonacoEditor() {
6
- return {
7
- name: 'append-js-extension-for-monaco-editor',
8
- transform(code, id) {
9
- // Only modify .ts files and ignore node_modules
10
- if (id.includes('node_modules') || !id.endsWith('.ts')) {
11
- return null;
12
- }
1
+ import { createRollupConfig } from '<%= offsetFromRoot %>rollup.config.base.mjs';
13
2
 
14
- let modifiedCode = code;
15
- const monacoImportRegex = /(@vscode-alt\/monaco-editor\/esm\/vs\/[a-zA-Z0-9\/._-]+)(?<!\.js)('|")/g;
3
+ // Define any additional plugins specific to this bundle
4
+ const additionalPlugins = [];
16
5
 
17
- modifiedCode = modifiedCode.replace(monacoImportRegex, (match, p1, p2) => {
18
- // Directly append '.js' to the captured path, excluding if it already ends with '.js'
19
- return `${p1}.js${p2}`;
20
- });
21
-
22
- return {
23
- code: modifiedCode,
24
- map: null, // Returning null for simplicity, consider generating source maps if necessary
25
- };
26
- },
27
- };
28
- }
29
-
30
- const bundle = (config) => ({
31
- ...config,
32
- input: 'src/index.ts',
33
- // marking all node modules as external
34
- external: (id) => !/^[./]/.test(id),
35
- });
36
- const globals = { react: 'React' };
37
-
38
- export default [
39
- bundle({
40
- plugins: [
41
- typescript({ noEmitOnError: true }),
42
- image(),
43
- graphql({
44
- include: '**/*.gql',
45
- }),
46
- string({
47
- include: '**/*.graphql',
48
- }),
49
- appendJsExtensionForMonacoEditor(),
50
- ],
51
- output: [
6
+ // Use the createRollupConfig function to merge the base and specific configurations
7
+ export default (commandLineArgs) => {
8
+ const isWatchMode = commandLineArgs.watch;
9
+ return [
10
+ createRollupConfig(
11
+ {
12
+ input: ['src/index.ts'],
13
+ plugins: [
14
+ // Spread in additional plugins specific to this config
15
+ ...additionalPlugins,
16
+ ],
17
+ output: [
18
+ {
19
+ dir: 'lib',
20
+ format: 'es',
21
+ name: 'Accounts',
22
+ compact: true,
23
+ exports: 'named',
24
+ sourcemap: true,
25
+ preserveModules: true,
26
+ chunkFileNames: '[name]-[hash].[format].js',
27
+ globals: { react: 'React' },
28
+ },
29
+ ],
30
+ },
52
31
  {
53
- dir: 'lib',
54
- format: 'es',
55
- name: 'Core',
56
- compact: true,
57
- exports: 'named',
58
- sourcemap: false,
59
- preserveModules: true,
60
- chunkFileNames: '[name]-[hash].[format].js',
61
- globals,
32
+ isWatchMode,
33
+ generateRoutesJSON: false,
62
34
  },
63
- ],
64
- }),
65
- ];
35
+ ),
36
+ ];
37
+ };
@@ -1,22 +1,13 @@
1
1
  {
2
- "extends": "../../../tsconfig.json",
3
- "compilerOptions": {
4
- "resolveJsonModule": true,
5
- "rootDir": "src",
6
- "outDir": "lib",
7
- "declaration": true,
8
- "preserveConstEnums": true,
9
- "declarationDir": "lib"
10
- },
11
- "include": [
12
- "src"
13
- ],
14
- "exclude": [
15
- "../../../node_modules",
16
- "node_modules",
17
- "lib",
18
- "lib",
19
- "webpack.config.js",
20
- "rollup.config.mjs"
21
- ]
22
- }
2
+ "extends": "<%= offsetFromRoot %>tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "resolveJsonModule": true,
5
+ "rootDir": "src",
6
+ "outDir": "lib",
7
+ "declaration": true,
8
+ "preserveConstEnums": true,
9
+ "declarationDir": "lib"
10
+ },
11
+ "include": ["src"],
12
+ "exclude": ["../../../node_modules", "node_modules", "lib", "webpack.config.js", "rollup.config.mjs"]
13
+ }
@@ -1,30 +1,37 @@
1
- import { createRollupConfig } from '../../../rollup.config.base.mjs';
2
- import json from '@rollup/plugin-json'
1
+ import { createRollupConfig } from '<%= offsetFromRoot %>rollup.config.base.mjs';
2
+ import json from '@rollup/plugin-json';
3
3
 
4
4
  // Define any additional plugins specific to this bundle
5
- const additionalPlugins = [
6
- json()
7
- ];
5
+ const additionalPlugins = [json()];
8
6
 
9
7
  // Use the createRollupConfig function to merge the base and specific configurations
10
- export default [
11
- createRollupConfig({
12
- input: ['src/index.ts'],
13
- plugins: [
14
- // Spread in additional plugins specific to this config
15
- ...additionalPlugins,
16
- ],
17
- output: [
8
+ export default (commandLineArgs) => {
9
+ const isWatchMode = commandLineArgs.watch;
10
+ return [
11
+ createRollupConfig(
18
12
  {
19
- dir: 'lib',
20
- format: 'es',
21
- name: 'Server',
22
- compact: true,
23
- exports: 'named',
24
- sourcemap: true,
25
- preserveModules: true,
26
- chunkFileNames: '[name]-[hash].[format].js',
13
+ input: ['src/index.ts'],
14
+ plugins: [
15
+ // Spread in additional plugins specific to this config
16
+ ...additionalPlugins,
17
+ ],
18
+ output: [
19
+ {
20
+ dir: 'lib',
21
+ format: 'es',
22
+ name: 'Accounts',
23
+ compact: true,
24
+ exports: 'named',
25
+ sourcemap: true,
26
+ preserveModules: true,
27
+ chunkFileNames: '[name]-[hash].[format].js',
28
+ },
29
+ ],
27
30
  },
28
- ],
29
- }),
30
- ];
31
+ {
32
+ isWatchMode,
33
+ generateRoutesJSON: false,
34
+ },
35
+ ),
36
+ ];
37
+ };
@@ -1,27 +1,17 @@
1
1
  {
2
- "extends": "../../../tsconfig.json",
3
- "compilerOptions": {
4
- "resolveJsonModule": true,
5
- "rootDir": "./src",
6
- "outDir": "lib",
7
- "sourceMap": false,
8
- "noEmitOnError": false,
9
- "declarationDir": "lib",
10
- "skipLibCheck": true,
11
- "declaration": true,
12
- "declarationMap": true,
13
- "types": [
14
- "@types/node",
15
- "@types/jest",
16
- "../../../typings"
17
- ]
18
- },
19
- "include": ["src"],
20
- "exclude": [
21
- "node_modules",
22
- "lib",
23
- "dist",
24
- "rollup.config.mjs",
25
- "webpack.config.js"
26
- ]
2
+ "extends": "<%= offsetFromRoot %>tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "resolveJsonModule": true,
5
+ "rootDir": "./src",
6
+ "outDir": "lib",
7
+ "sourceMap": false,
8
+ "noEmitOnError": false,
9
+ "declarationDir": "lib",
10
+ "skipLibCheck": true,
11
+ "declaration": true,
12
+ "declarationMap": true,
13
+ "types": ["@types/node", "@types/jest", "../../../typings"]
14
+ },
15
+ "include": ["src"],
16
+ "exclude": ["node_modules", "lib", "dist", "rollup.config.mjs", "webpack.config.js"]
27
17
  }