@vyr/pack-rollup-config-plugin 0.0.4

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/package.json ADDED
@@ -0,0 +1 @@
1
+ {"name":"@vyr/pack-rollup-config-plugin","version":"0.0.4","description":"","main":"./build/index.js","author":"","license":"ISC"}
package/src/index.ts ADDED
@@ -0,0 +1,47 @@
1
+ const fs = require('fs-extra')
2
+
3
+ const getRollupConfigContent = (outputFile: string, input: string, outputPath: string, external: string[]) => {
4
+ const configObj = {
5
+ }
6
+
7
+ const config = [
8
+ `{`,
9
+ ` input: ${JSON.stringify(input)},`,
10
+ ` output: {`,
11
+ ` file: ${JSON.stringify(outputPath)},`,
12
+ ` format: 'cjs',`,
13
+ ` inlineDynamicImports: true,`,
14
+ ` },`,
15
+ ` external: ${JSON.stringify(external)},`,
16
+ ` plugins: [`,
17
+ ` nodeResolve({ preferBuiltins: true}),`,
18
+ ` commonjs({ ignoreDynamicRequires: true }),`,
19
+ ` esbuild(${JSON.stringify(configObj)}),`,
20
+ ` varRename(${JSON.stringify(external)}, ${JSON.stringify(outputFile)}),`,
21
+ ` json(),`,
22
+ ` postcss({ extract: false, minimize: true })`,
23
+ ` ],`,
24
+ ` treeshake: false,`,
25
+ `}`,
26
+ ].join('\n')
27
+
28
+ return config
29
+ }
30
+
31
+ const createRollupConfigFactory = (config: string) => {
32
+ const factory = new Function(
33
+ 'nodeResolve',
34
+ 'commonjs',
35
+ 'json',
36
+ 'postcss',
37
+ 'esbuild',
38
+ 'varRename',
39
+ `return ${config}`)
40
+
41
+ return factory
42
+ }
43
+
44
+ export {
45
+ getRollupConfigContent,
46
+ createRollupConfigFactory,
47
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "CommonJS",
5
+ "moduleResolution": "node",
6
+ "lib": [
7
+ "ESNext",
8
+ "DOM",
9
+ "DOM.Iterable"
10
+ ],
11
+ "outDir": "build",
12
+ "strict": true,
13
+ "jsx": "preserve",
14
+ "declaration": true,
15
+ "skipLibCheck": true,
16
+ "esModuleInterop": true,
17
+ "allowSyntheticDefaultImports": true,
18
+ "forceConsistentCasingInFileNames": true,
19
+ "useDefineForClassFields": true,
20
+ "sourceMap": false,
21
+ "baseUrl": "",
22
+ "types": [
23
+ "webpack-env"
24
+ ],
25
+ "paths": {}
26
+ },
27
+ "include": [
28
+ "src/**/*.ts",
29
+ ],
30
+ "exclude": []
31
+ }