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(bundling): add createNodesV2 for rollup plugin #28090

Merged
merged 3 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 5 additions & 1 deletion packages/rollup/plugin.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
export { createNodes, RollupPluginOptions } from './src/plugins/plugin';
export {
createNodes,
createNodesV2,
RollupPluginOptions,
} from './src/plugins/plugin';
142 changes: 91 additions & 51 deletions packages/rollup/src/plugins/__snapshots__/plugin.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,70 +1,110 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`@nx/rollup/plugin non-root project should create nodes 1`] = `
{
"projects": {
"mylib": {
"root": "mylib",
"targets": {
"build": {
"cache": true,
"command": "rollup -c rollup.config.js",
"dependsOn": [
"^build",
],
"inputs": [
"production",
"^production",
{
"externalDependencies": [
"rollup",
[
[
"mylib/rollup.config.js",
{
"projects": {
"mylib": {
"root": "mylib",
"targets": {
"build": {
"cache": true,
"command": "rollup -c rollup.config.js",
"dependsOn": [
"^build",
],
"inputs": [
"production",
"^production",
{
"externalDependencies": [
"rollup",
],
},
],
"metadata": {
"description": "Run Rollup",
"help": {
"command": "npx rollup --help",
"example": {
"options": {
"sourcemap": true,
"watch": true,
},
},
},
"technologies": [
"rollup",
],
},
"options": {
"cwd": "mylib",
},
"outputs": [
"{workspaceRoot}/mylib/build",
"{workspaceRoot}/mylib/dist",
],
},
],
"options": {
"cwd": "mylib",
},
"outputs": [
"{workspaceRoot}/mylib/build",
"{workspaceRoot}/mylib/dist",
],
},
},
},
},
}
],
]
`;

exports[`@nx/rollup/plugin root project should create nodes 1`] = `
{
"projects": {
".": {
"root": ".",
"targets": {
"build": {
"cache": true,
"command": "rollup -c rollup.config.js",
"dependsOn": [
"^build",
],
"inputs": [
"production",
"^production",
{
"externalDependencies": [
"rollup",
[
[
"rollup.config.js",
{
"projects": {
".": {
"root": ".",
"targets": {
"build": {
"cache": true,
"command": "rollup -c rollup.config.js",
"dependsOn": [
"^build",
],
"inputs": [
"production",
"^production",
{
"externalDependencies": [
"rollup",
],
},
],
"metadata": {
"description": "Run Rollup",
"help": {
"command": "npx rollup --help",
"example": {
"options": {
"sourcemap": true,
"watch": true,
},
},
},
"technologies": [
"rollup",
],
},
"options": {
"cwd": ".",
},
"outputs": [
"{workspaceRoot}/dist",
],
},
],
"options": {
"cwd": ".",
},
"outputs": [
"{workspaceRoot}/dist",
],
},
},
},
},
}
],
]
`;
8 changes: 4 additions & 4 deletions packages/rollup/src/plugins/plugin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type CreateNodesContext } from '@nx/devkit';
import { createNodes } from './plugin';
import { createNodesV2 } from './plugin';
import { TempFs } from 'nx/src/internal-testing-utils/temp-fs';

// Jest 29 does not support dynamic import() unless --experimental-vm-modules is set.
Expand All @@ -11,7 +11,7 @@ jest.mock('rollup/loadConfigFile', () => {
});

describe('@nx/rollup/plugin', () => {
let createNodesFunction = createNodes[1];
let createNodesFunction = createNodesV2[1];
let context: CreateNodesContext;
let cwd = process.cwd();

Expand Down Expand Up @@ -77,7 +77,7 @@ describe('@nx/rollup/plugin', () => {
it('should create nodes', async () => {
// ACT
const nodes = await createNodesFunction(
'rollup.config.js',
['rollup.config.js'],
{
buildTargetName: 'build',
},
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('@nx/rollup/plugin', () => {
it('should create nodes', async () => {
// ACT
const nodes = await createNodesFunction(
'mylib/rollup.config.js',
['mylib/rollup.config.js'],
{
buildTargetName: 'build',
},
Expand Down
Loading