Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

one-app-bundler v7.0.0 #568

Merged
merged 40 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
da67ea2
chore(reset): restore other tools in package
code-forger Oct 17, 2023
9b8aeb7
feat(one-app-server-bundler): bundle for the server
code-forger Oct 24, 2023
b9fdd99
chore(one-app-bundler): remove old entry from README.md
code-forger Oct 24, 2023
b849bbe
chore(one-app-bundler): remove duplicate import
code-forger Oct 24, 2023
e9e9879
chore(one-app-bundler): fix comment
code-forger Oct 24, 2023
758a786
chore(one-app-bundler): remove console
code-forger Oct 24, 2023
d50c04a
chore(one-app-bundler): remove console
code-forger Oct 24, 2023
7d287bf
chore(one-app-bundler): update to holocron release
code-forger Oct 25, 2023
b09251c
Merge branch 'main' into v7.0.0-alpha-webpack-5
code-forger Oct 25, 2023
05864fa
chore(alpha): pre-release of package
code-forger Nov 2, 2023
262b5eb
chore(deps): fix deps
code-forger Nov 3, 2023
888f13d
Merge branch 'main' into v7.0.0-alpha-webpack-5
code-forger Nov 3, 2023
aa2c5a5
feat(bundler): review comments
code-forger Nov 13, 2023
8933072
chore(workflows): drop node 16
code-forger Nov 13, 2023
1ec8045
chore(workflow): support only node 18
code-forger Nov 13, 2023
af47b33
Merge branch 'main' into v7.0.0-alpha-webpack-5
code-forger Nov 16, 2023
6de0d13
chore(test): change order
code-forger Nov 16, 2023
4c3decc
fix(mock): fix mock fs
code-forger Nov 16, 2023
cf65efa
Merge branch 'main' into v7.0.0-alpha-webpack-5
JAdshead Dec 5, 2023
fcbb2a3
fix(bundler): remove eslint stuff, fix scss imports
code-forger Dec 13, 2023
058ceb6
Merge branch 'v7.0.0-alpha-webpack-5' of https://github.com/americane…
code-forger Dec 13, 2023
a1a453c
Merge branch 'main' into v7.0.0-alpha-webpack-5
code-forger Dec 13, 2023
ea89a24
chore(merge): consume jonny's change better
code-forger Dec 13, 2023
65c94a0
chore(test): run in band to fix fs issue
code-forger Dec 18, 2023
f53658f
Merge branch 'main' into v7.0.0-alpha-webpack-5
code-forger Dec 18, 2023
94ee77a
feat(styles): replace style loader WIP
code-forger Jan 29, 2024
f2d5435
Merge branch 'v7.0.0-alpha-webpack-5' of https://github.com/americane…
code-forger Jan 29, 2024
c71cc26
Merge branch 'main' into v7.0.0-alpha-webpack-5
code-forger Jan 29, 2024
b74fcb0
feat(styleLoader): replace style loader
code-forger Jan 31, 2024
23fa890
test(coverage): coverage
code-forger Feb 1, 2024
135f9f4
fix(ssrStyles): sync plugin
code-forger Feb 1, 2024
6779ffc
fix(ssrStyles): inject better syntax
code-forger Feb 1, 2024
ee24048
Merge branch 'main' into v7.0.0-alpha-webpack-5
code-forger Feb 2, 2024
0ca2ab6
fix(cssmodules): fix scoping path
code-forger Feb 2, 2024
c6acb0d
Merge branch 'main' into v7.0.0-alpha-webpack-5
code-forger Feb 2, 2024
521a8f0
chore(review): copy
code-forger Feb 2, 2024
35ee12d
chore(renamedPackage): move to renamed package
code-forger Feb 8, 2024
64c72bd
Merge branch 'v7.0.0-alpha-webpack-5' of https://github.com/americane…
code-forger Feb 8, 2024
fe7d196
chore(reivew): review comments
code-forger Feb 8, 2024
21441b5
chore(review): review comments
code-forger Feb 9, 2024
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
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@

module.exports = {
presets: ['amex'],
plugins: ['@babel/plugin-syntax-import-assertions'],
code-forger marked this conversation as resolved.
Show resolved Hide resolved
};
2 changes: 1 addition & 1 deletion jest.cjs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ module.exports = {
roots: [
'packages/eslint-plugin-one-app',
'packages/holocron-dev-server',
'packages/one-app-bundler',
'packages/one-app-locale-bundler',
'packages/one-app-server-bundler',
'packages/one-app-runner',
],
};
3 changes: 3 additions & 0 deletions jest.esm.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ module.exports = {
'!**/__test_fixtures__/**',
'!**/node_modules/**',
'!**/build/**',
'!packages/*/bin/**',
'!packages/*/test-utils.js',
'!packages/*/test-results/**',
'!packages/*/jest.esm.setup.js',
// Despite it not being in the root, coverage reports see this package
Expand All @@ -35,5 +37,6 @@ module.exports = {
],
roots: [
'packages/one-app-dev-bundler',
'packages/one-app-bundler',
],
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"lerna:publish": "lerna publish from-package --yes"
},
"devDependencies": {
"@babel/plugin-syntax-import-assertions": "^7.22.5",
"@commitlint/cli": "^13.1.0",
"@commitlint/config-conventional": "^13.1.0",
"@testing-library/jest-dom": "5.0.0",
Expand All @@ -52,4 +53,4 @@
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
}
}
8 changes: 8 additions & 0 deletions packages/one-app-bundler/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "amex",
"rules": {
"no-console": 0,
"import/extensions": 0, // ECMAscript modules explicitly require all extensions for relative imports
code-forger marked this conversation as resolved.
Show resolved Hide resolved
"unicorn/import-index": 0 // ECMAscript modules explicitly require no folder imports
}
}
16 changes: 0 additions & 16 deletions packages/one-app-bundler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,19 +401,3 @@ You can specify which version of One App you module is compatible with by simply
}
}
```

### Other Available Scripts

The following scripts are provided by `one-app-bundler` and used by `one-app`.

**`npm run build:bundle`**

This would bundle one app.

**`npm run serve-module ../path-to-your-one-app-module`**

This would serve your module locally.

**`npm run drop-module ../path-to-your-one-app-module`**

This would stop serving your module locally.
4 changes: 3 additions & 1 deletion packages/one-app-bundler/__tests__/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"rules": {
"no-console": 0, // CLI's are allowed to use console
"unicorn/no-process-exit": 0, // CLI's are allowed to exit
"unicorn/prefer-spread": 0 // Spread is not always semantically identical
"unicorn/prefer-spread": 0, // Spread is not always semantically identical
"import/extensions": 0, // ECMAscript modules explicitly require all extensions for relative imports
"unicorn/import-index": 0 // ECMAscript modules explicitly require no folder imports
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ jest.mock('@americanexpress/one-app-dev-bundler', () => ({
devBuildModule: async () => undefined,
bundleExternalFallbacks: async () => undefined,
}));
jest.mock('../../bin/webpack-bundle-module', () => jest.fn());

jest.mock('../../bin/webpack-bundle-module', () => ({
webpackBundleModule: jest.fn(),
}));

jest.spyOn(console, 'info');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,64 +46,78 @@ describe('bundle-module', () => {
process.argv = argv;
});

it('should bundle language packs', () => {
it('should bundle language packs', async () => {
expect.assertions(2);
process.argv = [];
require('../../bin/webpack-bundle-module');
const { webpackBundleModule } = require('../../bin/webpack-bundle-module');
await webpackBundleModule();
expect(localeBundler).toHaveBeenCalledTimes(1);
expect(localeBundler).toHaveBeenCalledWith(false);
});

it('should bundle the module for the server', () => {
it('should bundle the module for the server', async () => {
expect.assertions(4);
process.argv = [];
require('../../bin/webpack-bundle-module');
const { webpackBundleModule } = require('../../bin/webpack-bundle-module');
await webpackBundleModule();

expect(webpack).toHaveBeenCalledTimes(3);
expect(webpack).toHaveBeenCalledWith(serverConfig, 'cb(node, true)');
expect(webpack.mock.calls[0][0]).not.toHaveProperty('watch');
expect(webpack.mock.calls[0][0]).not.toHaveProperty('watchOptions');
});

it('should bundle the module for modern browsers', () => {
it('should bundle the module for modern browsers', async () => {
expect.assertions(4);
process.argv = [];
require('../../bin/webpack-bundle-module');
const { webpackBundleModule } = require('../../bin/webpack-bundle-module');
await webpackBundleModule();

expect(webpack).toHaveBeenCalledTimes(3);
expect(webpack).toHaveBeenCalledWith(clientConfig('modern'), 'cb(browser, true)');
expect(webpack.mock.calls[1][0]).not.toHaveProperty('watch');
expect(webpack.mock.calls[1][0]).not.toHaveProperty('watchOptions');
});

it('should bundle the module for legacy browsers', () => {
it('should bundle the module for legacy browsers', async () => {
expect.assertions(4);
process.argv = [];
require('../../bin/webpack-bundle-module');
const { webpackBundleModule } = require('../../bin/webpack-bundle-module');
await webpackBundleModule();

expect(webpack).toHaveBeenCalledTimes(3);
expect(webpack).toHaveBeenCalledWith(clientConfig('legacy'), 'cb(legacyBrowser, true)');
expect(webpack.mock.calls[2][0]).not.toHaveProperty('watch');
expect(webpack.mock.calls[2][0]).not.toHaveProperty('watchOptions');
});

it('should use the locale bundler\'s watch mode', () => {
it('should use the locale bundler\'s watch mode', async () => {
expect.assertions(2);
process.argv = ['--watch'];
require('../../bin/webpack-bundle-module');
const { webpackBundleModule } = require('../../bin/webpack-bundle-module');
await webpackBundleModule();
expect(localeBundler).toHaveBeenCalledTimes(1);
expect(localeBundler).toHaveBeenCalledWith(true);
});

it('should bundle module for legacy browsers when disableDevelopmentLegacyBundle is false', () => {
it('should bundle module for legacy browsers when disableDevelopmentLegacyBundle is false', async () => {
expect.assertions(2);
jest.mock('../../utils/getConfigOptions', () => jest.fn(() => ({ disableDevelopmentLegacyBundle: false })));
process.argv = [];
require('../../bin/webpack-bundle-module');
const { webpackBundleModule } = require('../../bin/webpack-bundle-module');
await webpackBundleModule();

expect(webpack).toHaveBeenCalledTimes(3);
expect(webpack).toHaveBeenCalledWith(clientConfig('legacy'), 'cb(legacyBrowser, true)');
});

it('should not bundle module for legacy browsers when disableDevelopmentLegacyBundle is true', () => {
it('should not bundle module for legacy browsers when disableDevelopmentLegacyBundle is true', async () => {
expect.assertions(2);
process.env.NODE_ENV = 'development';
jest.mock('../../utils/getConfigOptions', () => jest.fn(() => ({ disableDevelopmentLegacyBundle: true })));
process.argv = [];
require('../../bin/webpack-bundle-module');
const { webpackBundleModule } = require('../../bin/webpack-bundle-module');
await webpackBundleModule();

expect(webpack).toHaveBeenCalledTimes(2);
expect(webpack).not.toHaveBeenCalledWith(clientConfig('legacy'), 'cb(legacyBrowser, true)');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports['getConfigOptions should throw when a user attempts to provide an app provided external 1'] = '"@americanexpress/one-app-bundler: Attempted to bundle @americanexpress/one-app-ducks, but modules cannot provide externals that One App includes."';
exports[`getConfigOptions should throw when a user attempts to provide an app provided external 1`] = `"@americanexpress/one-app-bundler: Attempted to bundle @americanexpress/one-app-ducks, but modules cannot provide externals that One App includes."`;

exports['getConfigOptions should throw when a user attempts to use an app provided external from the root module 1'] = '"@americanexpress/one-app-bundler: Attempted to bundle @americanexpress/one-app-router, but modules cannot provide externals that One App includes."';
exports[`getConfigOptions should throw when a user attempts to use an app provided external from the root module 1`] = `"@americanexpress/one-app-bundler: Attempted to bundle @americanexpress/one-app-router, but modules cannot provide externals that One App includes."`;

exports['getConfigOptions should throw when a user includes both requiredExternals and providedExternals configs 1'] = '"@americanexpress/one-app-bundler: Modules cannot configure both requiredExternals and providedExternals. See README for details."';
exports[`getConfigOptions should throw when a user includes both requiredExternals and providedExternals configs 1`] = `"@americanexpress/one-app-bundler: Modules cannot configure both requiredExternals and providedExternals. See README for details."`;
Loading