@ms-cloudpack/bundler-rollup 0.2.12 → 0.2.13
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRollupPlugins.d.ts","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAqBrC,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"getRollupPlugins.d.ts","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAqBrC,wBAAsB,gBAAgB,CAAC,OAAO,EAAE;IAC9C,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,SAAS,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA+EpB"}
|
package/lib/getRollupPlugins.js
CHANGED
|
@@ -23,7 +23,7 @@ function getSwcPlugin() {
|
|
|
23
23
|
}
|
|
24
24
|
export async function getRollupPlugins(options) {
|
|
25
25
|
const { isProduction, packagePath, enableTypescript, dynamicImports = [], sourcemap } = options;
|
|
26
|
-
const
|
|
26
|
+
const swcConfigsForTs = enableTypescript ? getSwcConfig({ packagePath, sourcemap }) : undefined;
|
|
27
27
|
return [
|
|
28
28
|
// Used to replaces constants in the code.
|
|
29
29
|
replace({
|
|
@@ -59,34 +59,17 @@ export async function getRollupPlugins(options) {
|
|
|
59
59
|
}),
|
|
60
60
|
// Used to browserify node globals (process, global, etc.)
|
|
61
61
|
nodePolyfills(),
|
|
62
|
-
|
|
62
|
+
// The rollup swc plugin gets confused by angle bracket casts like `const x = <T>value;`
|
|
63
|
+
// in .ts files if the tsx option is enabled, so use separate rules for .ts and .tsx files.
|
|
64
|
+
// https://github.com/microsoft/cloudpack/pull/2555
|
|
65
|
+
swcConfigsForTs &&
|
|
63
66
|
(await getSwcPlugin())({
|
|
64
|
-
swc:
|
|
65
|
-
...swcTypescriptConfig,
|
|
66
|
-
jsc: {
|
|
67
|
-
...swcTypescriptConfig.jsc,
|
|
68
|
-
parser: {
|
|
69
|
-
...swcTypescriptConfig.jsc?.parser,
|
|
70
|
-
syntax: 'typescript',
|
|
71
|
-
tsx: false,
|
|
72
|
-
},
|
|
73
|
-
},
|
|
74
|
-
},
|
|
67
|
+
swc: swcConfigsForTs.tsOnly,
|
|
75
68
|
include: /\.ts$/,
|
|
76
69
|
}),
|
|
77
|
-
|
|
70
|
+
swcConfigsForTs &&
|
|
78
71
|
(await getSwcPlugin())({
|
|
79
|
-
swc:
|
|
80
|
-
...swcTypescriptConfig,
|
|
81
|
-
jsc: {
|
|
82
|
-
...swcTypescriptConfig.jsc,
|
|
83
|
-
parser: {
|
|
84
|
-
...swcTypescriptConfig.jsc?.parser,
|
|
85
|
-
syntax: 'typescript',
|
|
86
|
-
tsx: true,
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
|
-
},
|
|
72
|
+
swc: swcConfigsForTs.tsx,
|
|
90
73
|
include: /\.tsx$/,
|
|
91
74
|
}),
|
|
92
75
|
// Only run this plugin on **/*.dynamic.* files (plus others as specified) to avoid an extra
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRollupPlugins.js","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,uBAAuB,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,MAAM,qBAAqB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAE9C,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAE5C,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,QAAQ,MAAM,uBAAuB,CAAC;AAC7C,OAAO,QAAQ,MAAM,6BAA6B,CAAC;AACnD,OAAO,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAC;AAErF,8FAA8F;AAC9F,6EAA6E;AAC7E,uGAAuG;AACvG,kHAAkH;AAClH,MAAM,IAAI,GAAG,KAAwC,CAAC;AACtD,MAAM,OAAO,GAAG,QAA8C,CAAC;AAC/D,MAAM,MAAM,GAAG,OAA4C,CAAC;AAC5D,MAAM,aAAa,GAAG,cAA0D,CAAC;AACjF,MAAM,OAAO,GAAG,QAA8C,CAAC;AAC/D,MAAM,sBAAsB,GAAG,uBAA4E,CAAC;AAE5G,SAAS,YAAY;IACnB,OAAO,MAAM,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAiC,CAAC;AAC7F,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,OAMtC;IACC,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,gBAAgB,EAAE,cAAc,GAAG,EAAE,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;IAEhG,MAAM,
|
|
1
|
+
{"version":3,"file":"getRollupPlugins.js","sourceRoot":"","sources":["../src/getRollupPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC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,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;aACxF;SACF,CAAC;QAEF,2CAA2C;QAC3C,CAAC,CAAC,YAAY,IAAI,MAAM,EAAE;KAC3B,CAAC,MAAM,CAAC,CAAC,MAAM,EAAoB,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;AACnD,CAAC","sourcesContent":["import { getSwcConfig } from '@ms-cloudpack/bundler-utilities';\nimport _dynamicImportVariables from '@rollup/plugin-dynamic-import-vars';\nimport _json from '@rollup/plugin-json';\nimport { nodeResolve } from '@rollup/plugin-node-resolve';\nimport _replace from '@rollup/plugin-replace';\nimport type _swc from '@rollup/plugin-swc';\nimport _terser from '@rollup/plugin-terser';\nimport type { Plugin } from 'rollup';\nimport _nodePolyfills from 'rollup-plugin-polyfill-node';\nimport _postcss from 'rollup-plugin-postcss';\nimport commonjs from './plugins/commonjs/index.js';\nimport { normalizeRequireStatements } from './plugins/normalizeRequireStatements.js';\n\n// Workaround for https://github.com/microsoft/TypeScript/issues/49189#issuecomment-1137756847\n// (https://arethetypeswrong.github.io/?p=%40rollup%2Fplugin-replace%405.0.2)\n// At runtime, we should always be using the ESM version of these packages, which use `export default`.\n// However, typescript interprets the types as CJS modules with a `default` property (which will fail at runtime).\nconst json = _json as unknown as typeof _json.default;\nconst replace = _replace as unknown as typeof _replace.default;\nconst terser = _terser as unknown as typeof _terser.default;\nconst nodePolyfills = _nodePolyfills as unknown as typeof _nodePolyfills.default;\nconst postcss = _postcss as unknown as typeof _postcss.default;\nconst dynamicImportVariables = _dynamicImportVariables as unknown as typeof _dynamicImportVariables.default;\n\nfunction getSwcPlugin() {\n return import('@rollup/plugin-swc').then((m) => m.default) as Promise<typeof _swc.default>;\n}\n\nexport async function getRollupPlugins(options: {\n isProduction?: boolean;\n packagePath: string;\n enableTypescript?: boolean;\n dynamicImports?: string[];\n sourcemap: boolean | undefined;\n}): Promise<Plugin[]> {\n const { isProduction, packagePath, enableTypescript, dynamicImports = [], sourcemap } = options;\n\n const swcConfigsForTs = enableTypescript ? getSwcConfig({ packagePath, sourcemap }) : undefined;\n\n return [\n // Used to replaces constants in the code.\n replace({\n values: {\n 'process.env.NODE_ENV': isProduction ? `\"production\"` : `\"development\"`,\n DEPRECATED_UNIT_TEST: 'true',\n },\n preventAssignment: true,\n }),\n\n normalizeRequireStatements(),\n\n postcss({\n modules: {\n globalModulePaths: [/global\\.css$/],\n },\n }),\n\n // Used to parse commonjs.\n commonjs({\n // Treat all dependencies as external esm modules (since we'll be bundling them.)\n esmExternals: true,\n\n // When __esModule is true, the default export is `exports.default`; otherwise it's `module.exports`.\n defaultIsModuleExports: true,\n\n // Convert `require('library')` to `import * as library from 'library'` always, because `import library from\n // 'library' risks runtime failure if the dependency is ESM that doesn't export a default.\n requireReturnsDefault: false,\n }),\n\n // Used to compile json files into javascript exports.\n json(),\n\n // // Used to resolve node_modules.\n nodeResolve({\n preferBuiltins: false,\n browser: true,\n extensions: ['.js', '.json', ...(enableTypescript ? ['.ts', '.tsx'] : [])],\n }),\n\n // Used to browserify node globals (process, global, etc.)\n nodePolyfills(),\n\n // The rollup swc plugin gets confused by angle bracket casts like `const x = <T>value;`\n // in .ts files if the tsx option is enabled, so use separate rules for .ts and .tsx files.\n // https://github.com/microsoft/cloudpack/pull/2555\n swcConfigsForTs &&\n (await getSwcPlugin())({\n swc: swcConfigsForTs.tsOnly,\n include: /\\.ts$/,\n }),\n\n swcConfigsForTs &&\n (await getSwcPlugin())({\n swc: swcConfigsForTs.tsx,\n include: /\\.tsx$/,\n }),\n\n // Only run this plugin on **/*.dynamic.* files (plus others as specified) to avoid an extra\n // parsing/processing step on all files.\n // Must be done AFTER the TS step because it can only handle JS syntax.\n dynamicImportVariables({\n include: [\n '**/*.dynamic.*',\n // Convert the dynamic imports options to globs starting with **\n // (the plugin seems to be matching against full paths)\n ...dynamicImports.map((d) => (d.startsWith('**/') ? d : d.replace(/^(\\.?\\/)?/, '**/'))),\n ],\n }),\n\n // Minify production builds as a last step.\n !!isProduction && terser(),\n ].filter((plugin): plugin is Plugin => !!plugin);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ms-cloudpack/bundler-rollup",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.13",
|
|
4
4
|
"description": "A cloudpack plugin for abstracting rollup.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -19,13 +19,13 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@ms-cloudpack/bundler-capabilities": "^0.2.
|
|
23
|
-
"@ms-cloudpack/bundler-utilities": "^0.
|
|
24
|
-
"@ms-cloudpack/common-types": "^0.24.
|
|
25
|
-
"@ms-cloudpack/esm-stub-utilities": "^0.14.
|
|
26
|
-
"@ms-cloudpack/package-utilities": "^11.3.
|
|
22
|
+
"@ms-cloudpack/bundler-capabilities": "^0.2.11",
|
|
23
|
+
"@ms-cloudpack/bundler-utilities": "^0.2.0",
|
|
24
|
+
"@ms-cloudpack/common-types": "^0.24.6",
|
|
25
|
+
"@ms-cloudpack/esm-stub-utilities": "^0.14.7",
|
|
26
|
+
"@ms-cloudpack/package-utilities": "^11.3.3",
|
|
27
27
|
"@ms-cloudpack/path-string-parsing": "^1.2.6",
|
|
28
|
-
"@ms-cloudpack/path-utilities": "^3.0.
|
|
28
|
+
"@ms-cloudpack/path-utilities": "^3.0.3",
|
|
29
29
|
"@rollup/plugin-dynamic-import-vars": "^2.0.0",
|
|
30
30
|
"@rollup/plugin-json": "^6.0.0",
|
|
31
31
|
"@rollup/plugin-node-resolve": "^15.0.0",
|