Skip to content

Commit

Permalink
Use rollup (#276)
Browse files Browse the repository at this point in the history
* use rollup

* remove karma-webpack
  • Loading branch information
imnutz authored Aug 9, 2024
1 parent c3dd076 commit dc590c1
Show file tree
Hide file tree
Showing 9 changed files with 10,772 additions and 21,301 deletions.
12 changes: 0 additions & 12 deletions babel.config.js

This file was deleted.

11 changes: 6 additions & 5 deletions bin/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,22 @@ MINIFIED_FILENAME="$ROOT_DIR/dist/td.min.js"
sed -e $GLOBAL_REPLACE -e $VERSION_REPLACE -e $HOST_REPLACE -e $DATABASE_REPLACE -e $PATHNAME_REPLACE lib/config.template.js > lib/config.js

#NODE_ENV=production
$ROOT_DIR/node_modules/.bin/webpack
npm run build-dev
if [ $FILENAME != "td" ]
then
mv $ROOT_DIR/dist/td.js $ROOT_DIR/dist/$FILENAME.js
fi

MINIFY_BUILD=true $ROOT_DIR/node_modules/.bin/webpack --output-filename [name].min.js
npm run build-prod
if [ $FILENAME != "td" ]
then
mv $ROOT_DIR/dist/td.min.js $ROOT_DIR/dist/$FILENAME.min.js
fi

cat $ROOT_DIR/src/loader.js |
sed -e $GLOBAL_REPLACE -e $URL_REPLACE |
$ROOT_DIR/node_modules/.bin/uglifyjs -m -c > $ROOT_DIR/dist/loader.min.js
cat $ROOT_DIR/src/loader.js | sed -e $GLOBAL_REPLACE -e $URL_REPLACE > src/refined_loader.js
npm run build-loader

rm src/refined_loader.js

ESCAPED_LOADER="$(echo $ROOT_DIR/dist/loader.min.js | sed -e 's^/^\\/^g')"

Expand Down
27 changes: 10 additions & 17 deletions karma.conf.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
var branch = process.env.TRAVIS_PULL_REQUEST_BRANCH || process.env.TRAVIS_BRANCH
var sha = require('child_process')
.execSync('git rev-parse --short=9 HEAD', { cwd: __dirname })
.toString().trim()
var startTime = new Date().toISOString()

var webpackConfig = require('./webpack.config')
webpackConfig.entry = undefined
webpackConfig.mode = 'development'
var commonjs = require('@rollup/plugin-commonjs')
var nodeResolver = require('@rollup/plugin-node-resolve')

module.exports = function (config) {
config.set({
Expand All @@ -28,7 +21,6 @@ module.exports = function (config) {

// list of files / patterns to load in the browser
files: [
require.resolve('@babel/polyfill/dist/polyfill.js'),
{ pattern: 'lib/**/*.js', included: false },
{ pattern: 'test/*.spec.js', included: true, watched: false }
],
Expand All @@ -39,15 +31,16 @@ module.exports = function (config) {
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
'test/*.spec.js': ['webpack']
'test/*.spec.js': ['rollup']
},

webpack: webpackConfig,

webpackMiddleware: {
// webpack-dev-middleware configuration
// i. e.
stats: 'errors-only'
rollupPreprocessor: {
plugins: [nodeResolver(), commonjs()],
output: {
format: 'iife',
name: 'td_js_sdk_test',
strict: false
}
},

client: {
Expand Down
Loading

0 comments on commit dc590c1

Please sign in to comment.