Skip to content

Commit

Permalink
fix: improve built time in dev mode (#153)
Browse files Browse the repository at this point in the history
* fix: improve built time in dev mode

* fix: include json view
  • Loading branch information
dylandepass authored May 27, 2024
1 parent 1ef66f7 commit 0b53c60
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 23 deletions.
2 changes: 1 addition & 1 deletion build/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { exec } from 'child_process';

chokidar.watch(['src/'])
.on('change', () => {
exec('npm run build', (error, stdout, stderr) => {
exec('npm run build:dev', (error, stdout, stderr) => {
if (error) {
console.error(`${error.name}: ${error.message}`);
console.error(`[STACK] ${error.stack}`);
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"test": "wtr \"./test/**/*.test.js\"",
"docs": "npx jsdoc2md -c .jsdoc.json --files './src/*.js' > docs/API.md",
"semantic-release": "semantic-release",
"build:watch": "rimraf dist && npm run build && node build/watch.js",
"build:watch": "npm run build:dev && node build/watch.js",
"build:dev": "rimraf dist && rollup -c rollup.config-dev.js",
"build": "rimraf dist && rollup -c rollup.config.js && npm run build:analyze",
"build:analyze": "npm run analyze -- --globs src/extension/app/aem-sidekick.js",
"build:safari": "node ./build/build-browser.js safari",
Expand Down
24 changes: 24 additions & 0 deletions rollup.config-dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2023 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
// @ts-nocheck

/* eslint-disable import/no-extraneous-dependencies */

import { createExtension, viewBuild } from './rollup.config.js';

export default [
{
input: 'src/extension/views/json/json.js',
...viewBuild('chrome', '/views/json'),
},
...createExtension('chrome'),
];
30 changes: 11 additions & 19 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,6 @@ function commonPlugins() {

function extensionPlugins(browser) {
return [
/** Resolve bare module imports */
nodeResolve(),
/** Transform decorators with babel */
babel({ babelHelpers: 'bundled' }),
/** Minify JS, compile JS to a lower language target */
esbuild({
minify: true,
target: ['chrome64', 'firefox67', 'safari11.1'],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
/** Bundle assets references via import.meta.url */
importMetaAssets(),
/** Copy static assets */
Expand All @@ -81,9 +69,6 @@ function extensionPlugins(browser) {
{ src: 'src/extension/rum.js', dest: `./dist/${browser}` },
],
}),
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
sidekickManifestBuildPlugin(browser),
];
}
Expand All @@ -95,26 +80,33 @@ function extensionBuild(browser) {
};
}

function viewBuild(browser, path) {
function scriptBuild(browser) {
return {
...shared(browser),
plugins: [...commonPlugins()],
};
}

export function viewBuild(browser, path) {
return {
...shared(browser, path),
plugins: [...commonPlugins()],
};
}

function createExtension(browser) {
export function createExtension(browser) {
return [
{
input: 'src/extension/index.js',
...extensionBuild(browser),
},
{
input: 'src/extension/background.js',
...extensionBuild(browser),
...scriptBuild(browser),
},
{
input: 'src/extension/content.js',
...extensionBuild(browser),
...scriptBuild(browser),
},
];
}
Expand Down

0 comments on commit 0b53c60

Please sign in to comment.