Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/red-islands-drop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"modular-scripts": patch
---

Bump @rollup/plugin-commonjs from 21.1.0 to 22.0.0
2 changes: 1 addition & 1 deletion packages/modular-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"dependencies": {
"@babel/code-frame": "7.16.7",
"@rollup/plugin-babel": "5.3.1",
"@rollup/plugin-commonjs": "21.1.0",
"@rollup/plugin-commonjs": "22.0.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "13.2.1",
"@svgr/core": "6.1.2",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`WHEN building with preserve modules SHOULD create the correct index.js 1`] = `
"export { default } from './index2.js';
//# sourceMappingURL=index.js.map
"
`;

exports[`WHEN building with preserve modules SHOULD create the correct index2.js 1`] = `
"async function runInAsync() {
const { runAsync } = await import('./runAsync.js');
return runAsync();
}

export { runInAsync as default };
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index2.js.map
"
`;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`modular-scripts WHEN building a view THEN outputs the correct output cjs index2.js map file 1`] = `
Object {
"file": "index2.js",
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AACe,SAAS,UAAU,GAAG;AACrC,EAAE,uBAAuBA,gBAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AACpD,IAAI,aAAa,EAAE,WAAW;AAC9B,GAAG,EAAE,wBAAwB,CAAC,CAAC;AAC/B;;;;",
"names": Array [
"React",
],
"sources": Array [
"../src/index.tsx",
],
"sourcesContent": Array [
"import * as React from 'react';

export default function SampleView(): JSX.Element {
return <div data-testid=\\"test-this\\">this is a modular view</div>
}",
],
"version": 3,
}
`;

exports[`modular-scripts WHEN building a view THEN outputs the correct output cjs file 1`] = `
"'use strict';

var index = require('./index2.js');



module.exports = index;
//# sourceMappingURL=index.js.map
"
`;

exports[`modular-scripts WHEN building a view THEN outputs the correct output cjs index2.js file 1`] = `
"'use strict';

var React = require('react');

function _interopNamespace(e) {
Expand Down Expand Up @@ -32,27 +65,17 @@ function SampleView() {
}

module.exports = SampleView;
//# sourceMappingURL=index.js.map
//# sourceMappingURL=index2.js.map
"
`;

exports[`modular-scripts WHEN building a view THEN outputs the correct output cjs map file 1`] = `
Object {
"file": "index.js",
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AACe,SAAS,UAAU,GAAG;AACrC,EAAE,uBAAuBA,gBAAK,CAAC,aAAa,CAAC,KAAK,EAAE;AACpD,IAAI,aAAa,EAAE,WAAW;AAC9B,GAAG,EAAE,wBAAwB,CAAC,CAAC;AAC/B;;;;",
"names": Array [
"React",
],
"sources": Array [
"../src/index.tsx",
],
"sourcesContent": Array [
"import * as React from 'react';

export default function SampleView(): JSX.Element {
return <div data-testid=\\"test-this\\">this is a modular view</div>
}",
],
"mappings": ";;;;;;",
"names": Array [],
"sources": Array [],
"sourcesContent": Array [],
"version": 3,
}
`;
40 changes: 32 additions & 8 deletions packages/modular-scripts/src/__tests__/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,17 @@ describe('WHEN building with preserve modules', () => {
.toMatchInlineSnapshot(`
"sample-async-package
├─ dist-cjs
│ ├─ index.js #y5z0kw
│ ├─ index.js.map #1gofapj
│ ├─ index.js #p1m6x9
│ ├─ index.js.map #16jes1h
│ ├─ index2.js #1gdggtn
│ ├─ index2.js.map #r11rcb
│ ├─ runAsync.js #kr3qrh
│ └─ runAsync.js.map #19q2dqp
├─ dist-es
│ ├─ index.js #7arwpf
│ ├─ index.js.map #p3aqj2
│ ├─ index.js #tcl83f
│ ├─ index.js.map #yz1h1d
│ ├─ index2.js #67jtpf
│ ├─ index2.js.map #1pcnly9
│ ├─ runAsync.js #1tt0e7o
│ └─ runAsync.js.map #1tlnsv0
├─ dist-types
Expand All @@ -84,6 +88,22 @@ describe('WHEN building with preserve modules', () => {
).toMatchSnapshot();
});

it('SHOULD create the correct index2.js', () => {
expect(
String(
fs.readFileSync(
path.join(
getModularRoot(),
'dist',
packageName,
'dist-es',
'index2.js',
),
),
),
).toMatchSnapshot();
});

it('SHOULD create the correct runAsync.js', () => {
expect(
String(
Expand Down Expand Up @@ -149,11 +169,15 @@ describe('WHEN building packages with private cross-package dependencies', () =>
.toMatchInlineSnapshot(`
"sample-depending-package
├─ dist-cjs
│ ├─ index.js #1gj4b9h
│ └─ index.js.map #1v4zj6b
│ ├─ index.js #1m9v9ya
│ ├─ index.js.map #79ot9r
│ ├─ index2.js #q6vf2j
│ └─ index2.js.map #10q3jzt
├─ dist-es
│ ├─ index.js #xezjee
│ └─ index.js.map #isxuu
│ ├─ index.js #3qxwo1
│ ├─ index.js.map #yz1h1d
│ ├─ index2.js #14be4lv
│ └─ index2.js.map #jfjxet
├─ dist-types
│ └─ index.d.ts #6hjmh9
└─ package.json"
Expand Down
54 changes: 46 additions & 8 deletions packages/modular-scripts/src/__tests__/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,16 +259,50 @@ describe('modular-scripts', () => {
).toMatchSnapshot();
});

it('THEN outputs the correct output cjs index2.js file', () => {
expect(
String(
fs.readFileSync(
path.join(
modularRoot,
'dist',
'sample-view',
'dist-cjs',
'index2.js',
),
),
),
).toMatchSnapshot();
});

it('THEN outputs the correct output cjs index2.js map file', () => {
expect(
fs.readJsonSync(
path.join(
modularRoot,
'dist',
'sample-view',
'dist-cjs',
'index2.js.map',
),
),
).toMatchSnapshot();
});

it('THEN outputs the correct directory structure', () => {
expect(tree(path.join(modularRoot, 'dist', 'sample-view')))
.toMatchInlineSnapshot(`
"sample-view
├─ dist-cjs
│ ├─ index.js #a7k6ic
│ └─ index.js.map #1m4qim9
│ ├─ index.js #p1m6x9
│ ├─ index.js.map #16jes1h
│ ├─ index2.js #dbk75e
│ └─ index2.js.map #11cwgsp
├─ dist-es
│ ├─ index.js #1ymmv5l
│ └─ index.js.map #11lg0ox
│ ├─ index.js #tcl83f
│ ├─ index.js.map #yz1h1d
│ ├─ index2.js #urz4k4
│ └─ index2.js.map #1w4fdrj
├─ dist-types
│ └─ index.d.ts #1vloh7q
└─ package.json"
Expand Down Expand Up @@ -347,11 +381,15 @@ describe('modular-scripts', () => {
.toMatchInlineSnapshot(`
"sample-package
├─ dist-cjs
│ ├─ index.js #rq9uxe
│ └─ index.js.map #19satcx
│ ├─ index.js #p1m6x9
│ ├─ index.js.map #16jes1h
│ ├─ index2.js #6y6kyx
│ └─ index2.js.map #10ij9v
├─ dist-es
│ ├─ index.js #3bszhr
│ └─ index.js.map #1m2nocl
│ ├─ index.js #tcl83f
│ ├─ index.js.map #yz1h1d
│ ├─ index2.js #hx36fq
│ └─ index2.js.map #bbrfkq
├─ dist-types
│ └─ index.d.ts #f68aj
└─ package.json"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2061,10 +2061,10 @@
"@babel/helper-module-imports" "^7.10.4"
"@rollup/pluginutils" "^3.1.0"

"@rollup/plugin-commonjs@21.1.0":
version "21.1.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-21.1.0.tgz#45576d7b47609af2db87f55a6d4b46e44fc3a553"
integrity sha512-6ZtHx3VHIp2ReNNDxHjuUml6ur+WcQ28N1yHgCQwsbNkQg2suhxGMDQGJOn/KuDxKtd1xuZP5xSTwBA4GQ8hbA==
"@rollup/plugin-commonjs@22.0.0":
version "22.0.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-commonjs/-/plugin-commonjs-22.0.0.tgz#f4d87016e2fbf187a593ab9f46626fe05b59e8bd"
integrity sha512-Ktvf2j+bAO+30awhbYoCaXpBcyPmJbaEUYClQns/+6SNCYFURbvBiNbWgHITEsIgDDWCDUclWRKEuf8cwZCFoQ==
dependencies:
"@rollup/pluginutils" "^3.1.0"
commondir "^1.0.1"
Expand Down