Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(create-app): native esm templates #2609

Merged
merged 1 commit into from
Jul 26, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
],
"plugins": ["react-hooks"],
"ignorePatterns": ["node_modules", "dist", "st-types"],
"parserOptions": {
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"singleQuote": true,
"overrides": [
{
"files": ["*.js", "*.ts", "*.tsx"],
"files": ["*.js", "*.cjs", "*.mjs", "*.ts", "*.tsx", "*.cts", "*.mts"],
"options": {
"tabWidth": 4
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// @ts-check

import { stylableRollupPlugin } from '@stylable/rollup-plugin';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
import html from '@rollup/plugin-html';
import image from '@rollup/plugin-image';
import replace from '@rollup/plugin-replace';
import rollupTypescript from '@rollup/plugin-typescript';
import copy from 'rollup-plugin-copy';
import serve from 'rollup-plugin-serve';

const isProductionMode = process.env.NODE_ENV === 'production';

/** @type {import('rollup').RollupOptions} */
export default {
input: 'src/index.tsx',
output: {
file: 'dist/bundle.js',
format: 'umd',
sourcemap: !isProductionMode,
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV ?? 'production'),
preventAssignment: true,
}),
image(),
nodeResolve(),
commonjs(),
html({}),
rollupTypescript({ compilerOptions: { sourceMap: !isProductionMode } }),
stylableRollupPlugin({ stcConfig: true, optimization: { minify: isProductionMode } }),
copy({
targets: [{ src: 'favicon.ico', dest: 'dist' }],
}),
!isProductionMode &&
serve({
open: true,
contentBase: ['dist'],
port: 3000,
}),
],
};
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//@ts-check
// @ts-check

const { typedConfiguration } = require('@stylable/cli');

exports.stcConfig = typedConfiguration({
options: {
srcDir: './src',
outDir: './st-types',
dts: true,
cjs: false,
},
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ts-check
// @ts-check

/** @type {import('create-stylable-app').TemplateDefinition} */
module.exports = {
dependencies: ['react', 'react-dom'],
Expand Down Expand Up @@ -31,6 +32,7 @@ module.exports = {
description: 'Stylable App',
private: true,
license: 'UNLICENSED',
type: 'module',
scripts: {
clean: 'rimraf dist',
prebuild: 'npm run clean',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
],
"plugins": ["react-hooks"],
"ignorePatterns": ["node_modules", "dist", "st-types"],
"parserOptions": {
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"singleQuote": true,
"overrides": [
{
"files": ["*.js", "*.ts", "*.tsx"],
"files": ["*.js", "*.cjs", "*.mjs", "*.ts", "*.tsx", "*.cts", "*.mts"],
"options": {
"tabWidth": 4
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//@ts-check
// @ts-check

const { typedConfiguration } = require('@stylable/cli');

exports.stcConfig = typedConfiguration({
options: {
srcDir: './src',
outDir: './st-types',
dts: true,
cjs: false,
},
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ts-check
// @ts-check

/** @type {import('create-stylable-app').TemplateDefinition} */
module.exports = {
dependencies: ['react', 'react-dom'],
Expand Down Expand Up @@ -27,6 +28,7 @@ module.exports = {
description: 'Stylable App',
private: true,
license: 'UNLICENSED',
type: 'module',
scripts: {
clean: 'rimraf dist',
prebuild: 'npm run clean',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const { StylableWebpackPlugin } = require('@stylable/webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// @ts-check

import { StylableWebpackPlugin } from '@stylable/webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';

/** @type {import('webpack').Configuration} */
module.exports = {
export default {
mode: 'development',
devtool: 'source-map',
module: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
],
"plugins": ["react-hooks"],
"ignorePatterns": ["node_modules", "dist", "st-types"],
"parserOptions": {
"sourceType": "module"
},
"settings": {
"react": {
"version": "detect"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"singleQuote": true,
"overrides": [
{
"files": ["*.js", "*.ts", "*.tsx"],
"files": ["*.js", "*.cjs", "*.mjs", "*.ts", "*.tsx", "*.cts", "*.mts"],
"options": {
"tabWidth": 4
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//@ts-check
// @ts-check

const { typedConfiguration } = require('@stylable/cli');

exports.stcConfig = typedConfiguration({
options: {
srcDir: './src',
outDir: './st-types',
dts: true,
cjs: false,
},
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ts-check
// @ts-check

/** @type {import('create-stylable-app').TemplateDefinition} */
module.exports = {
dependencies: ['react', 'react-dom'],
Expand Down Expand Up @@ -27,6 +28,7 @@ module.exports = {
description: 'Stylable App',
private: true,
license: 'UNLICENSED',
type: 'module',
scripts: {
clean: 'rimraf dist',
prebuild: 'npm run clean',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const { StylableWebpackPlugin } = require('@stylable/webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// @ts-check

import { StylableWebpackPlugin } from '@stylable/webpack-plugin';
import HtmlWebpackPlugin from 'html-webpack-plugin';

/** @type {import('webpack').Configuration} */
module.exports = {
export default {
mode: 'development',
devtool: 'source-map',
module: {
Expand Down