Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update to rollup 4 #1370

Merged
merged 21 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/x-archetype-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@vue/test-utils": "~1.0.3",
"jest": "~27.5.0",
"rimraf": "~3.0.2",
"rollup": "~2.79.1",
"rollup": "~4.9.1",
"rollup-plugin-copy": "~3.5.0",
"rollup-plugin-delete": "~2.0.0",
"rollup-plugin-typescript2": "~0.36.0",
Expand Down
diegopf marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
2 changes: 1 addition & 1 deletion packages/x-components/build/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ async function build(): Promise<any> {
* Function for deleting useless folders.
*/
function removeTempFiles(): void {
fs.rmdirSync(path.join(rootDir, 'temp'), { recursive: true });
fs.rmSync(path.join(rootDir, 'temp'), { recursive: true });
}
10 changes: 5 additions & 5 deletions packages/x-components/build/rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const rollupConfig = createRollupOptions({
* Because of that, when rollup detects a circular dependency (it emits a warning), we stop
* the build with an error */
if (warning.code === 'CIRCULAR_DEPENDENCY') {
throw Error(`Circular dependency found: ${warning.cycle?.join(' ') as string}`);
throw Error(`Circular dependency found: ${warning.ids?.join(' ') as string}`);
}
},
external(id) {
Expand Down Expand Up @@ -119,7 +119,7 @@ export const rollupConfig = createRollupOptions({
copy({
targets: [
{
src: ['build-helpers', 'CHANGELOG.md', 'package.json', 'README.md', 'docs'],
src: ['CHANGELOG.md', 'package.json', 'README.md', 'docs'],
dest: buildPath
}
],
Expand All @@ -136,9 +136,9 @@ export const rollupConfig = createRollupOptions({
const commonCssOptions = createRollupOptions({
output: {
dir: cssOutputDirectory,
assetFileNames: '[name][extname]'
},
preserveModules: true
assetFileNames: '[name][extname]',
preserveModules: true
}
});

/**
Expand Down
8 changes: 3 additions & 5 deletions packages/x-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"./tests/**/*",
"**/*.scss",
"**/*.scss.js",
"**/*vue_styles.*.vue.js",
"**/*vue[0-9].js",
Copy link
Contributor Author

@diegopf diegopf Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Due to how rollup generates now the output filenames when preserving modules, we need to adjust the sideEffect field in the package.json so bundlers do not tree shake styles of vue components.

The rollup-plugin-vue splits every vue sfc into two virtual files. Taking for example the redirection.vue component:

redirection.vue?rollup-plugin-vue=script.ts
redirection.vue?rollup-plugin-vue=styles.0.css

Prior to v3 rollup generates three files:
redirection.vue.js
redirection.vue_rollup_plugin-vue_script.vue.js
redirection.vue_rollup_plugin-vue_styles.0.js.

However, now rollup will name those files:
redirection.vue.js
redirection.vue.2.js
redirection.vue.3.js

You can see a simple example using the rollup repl

Rollup 2.79.1 filenames

Rollup 4.9.1 filenames

"**/*.css",
"**/*.vue"
],
Expand Down Expand Up @@ -97,7 +97,7 @@
"@empathyco/x-tailwindcss": "^1.1.2-alpha.0",
"@microsoft/api-documenter": "~7.23.0",
"@microsoft/api-extractor": "~7.38.0",
"@rollup/plugin-commonjs": "~25.0.0",
"@rollup/plugin-commonjs": "~25.0.7",
"@testing-library/jest-dom": "~5.17.0",
"@types/autoprefixer": "~10.2.0",
"@types/glob": "^8.0.1",
Expand All @@ -118,11 +118,9 @@
"postcss-dir-pseudo-class": "~7.0.0",
"postcss-logical": "~4.0.2",
"rimraf": "~3.0.2",
"rollup": "~2.79.1",
"rollup": "~4.9.1",
"rollup-plugin-copy": "~3.5.0",
"rollup-plugin-delete": "~2.0.0",
"rollup-plugin-rename": "~1.0.1",
"rollup-plugin-sourcemaps": "~0.6.3",
"rollup-plugin-styles": "~4.0.0",
"rollup-plugin-typescript2": "~0.36.0",
"rollup-plugin-vue": "~5.1.9",
Expand Down
diegopf marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iep! We forgot this one!
output: [{ format: 'esm', dir: resolve(__dirname, '../showcase'), preserveModules: true }],

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { resolve } from 'path';
import commonjs from '@rollup/plugin-commonjs';
import typescript from 'rollup-plugin-typescript2';
import vue from 'rollup-plugin-vue';
import * as url from 'url';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

export default {
input: resolve(__dirname, 'src/index.ts'),
Expand Down
6 changes: 3 additions & 3 deletions packages/x-tailwindcss/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"dev": "vite serve demo",
"dev:build": "vite build demo",
"prebuild": "rimraf ./dist ./showcase ./*.tgz",
"build": "rollup -c && rollup -c demo/rollup.config.js",
"build": "rollup -c && rollup -c demo/rollup.config.mjs",
"postbuild": "pnpm pack",
"lint": "eslint . --ext .ts,.vue",
"prepublishOnly": "pnpm run build"
Expand All @@ -57,12 +57,12 @@
}
},
"devDependencies": {
"@rollup/plugin-commonjs": "~25.0.0",
"@rollup/plugin-commonjs": "~25.0.7",
"autoprefixer": "~10.4.4",
"postcss": "~8.4.12",
"postcss-import": "~15.1.0",
"rimraf": "~3.0.2",
"rollup": "~2.79.1",
"rollup": "~4.9.1",
"rollup-plugin-typescript2": "~0.36.0",
"rollup-plugin-vue": "~5.1.9",
"tailwindcss": "~3.3.0",
Expand Down
diegopf marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { resolve } from 'path';
import typescript from 'rollup-plugin-typescript2';
import commonjs from '@rollup/plugin-commonjs';
import * as url from 'url';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));

export default {
input: resolve(__dirname, 'src/index.ts'),
Expand Down
2 changes: 1 addition & 1 deletion packages/x-types/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"@microsoft/api-extractor": "~7.38.0",
"@types/jest": "~27.5.0",
"jest": "~27.5.0",
"rollup": "~2.79.1",
"rollup": "~4.9.1",
"rollup-plugin-delete": "~2.0.0",
"rollup-plugin-typescript2": "~0.36.0",
"typescript": "~4.9.4"
Expand Down
diegopf marked this conversation as resolved.
Show resolved Hide resolved
File renamed without changes.
Loading