Skip to content

Commit

Permalink
Adding cjs version
Browse files Browse the repository at this point in the history
  • Loading branch information
Shan Carter committed Mar 14, 2018
1 parent 08e6fb0 commit d9acaa7
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 26 deletions.
2 changes: 1 addition & 1 deletion lucid/scratch/js/package-lock.json

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

4 changes: 2 additions & 2 deletions lucid/scratch/js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lucid-components",
"version": "0.0.3",
"version": "0.0.4",
"svelte.root": "src",
"license": "Apache-2.0",
"main": "public/index.js",
Expand All @@ -23,7 +23,7 @@
"node-fetch": "^2.1.1"
},
"scripts": {
"build": "rollup -c",
"build": "rollup -c rollup.config.js && rollup -c rollup.cjs.config.js",
"dev": "rollup -c -w",
"test": "mocha"
}
Expand Down
46 changes: 46 additions & 0 deletions lucid/scratch/js/rollup.cjs.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2018 The Lucid Authors.All Rights Reserved.
//
// Licensed 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 CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ==============================================================================

import svelte from 'rollup-plugin-svelte';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

const production = !process.env.ROLLUP_WATCH;

export default {
input: 'src/index.js',
output: {
sourcemap: true,
format: 'cjs',
name: 'lucidComponents',
file: 'public/index.cjs.js'
},
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
store: true,
cascade: false
}),

// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:
// https://github.com/rollup/rollup-plugin-commonjs
resolve(),
commonjs(),
]
};
43 changes: 21 additions & 22 deletions lucid/scratch/js/rollup.config.js
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,26 @@ import commonjs from 'rollup-plugin-commonjs';
const production = !process.env.ROLLUP_WATCH;

export default {
input: 'src/index.js',
output: {
sourcemap: true,
format: 'umd',
name: 'lucidComponents',
file: 'public/index.js'
},
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
store: true,
cascade: false
}),
input: 'src/index.js',
output: {
sourcemap: true,
format: 'es',
file: 'public/index.js'
},
plugins: [
svelte({
// enable run-time checks when not in production
dev: !production,
store: true,
cascade: false
}),

// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:
// https://github.com/rollup/rollup-plugin-commonjs
resolve(),
commonjs(),
]
// If you have external dependencies installed from
// npm, you'll most likely need these plugins. In
// some cases you'll need additional configuration —
// consult the documentation for details:
// https://github.com/rollup/rollup-plugin-commonjs
resolve(),
commonjs(),
]
};
2 changes: 1 addition & 1 deletion lucid/scratch/js/test/load.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const chai = require('chai');
const expect = chai.expect;

const fetchMock = require('fetch-mock');
const load = require("../public/index.js").load;
const load = require("../public/index.cjs.js").load;

const mockData = { 'test': 42 }
fetchMock.mock('404', 404);
Expand Down

0 comments on commit d9acaa7

Please sign in to comment.