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

Fix naming of rollup plugins and helper functions in ember-scoped-css #31

Merged
merged 3 commits into from
May 16, 2023
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
10 changes: 2 additions & 8 deletions ember-scoped-css/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import addonJsUnplugin from './src/addon-js-unplugin.js';
import addonCssRollup from './src/addon-css-rollup.js';
import addonHbsRollup from './src/addon-hbs-rollup.js';
import appJsUnplugin from './src/app-js-unplugin.js';
import appCssUnplugin from './src/app-css-unplugin.js';
import appScopedcssWebpack from './src/app-scopedcss-webpack.js';
import addonRewritecssRollup from './src/addon-rewritecss-rollup.js';
import scopedCssUnplugin from './src/scoped-css-unplugin.js';

export {
addonJsUnplugin,
addonCssRollup,
addonHbsRollup,
scopedCssUnplugin,
appJsUnplugin,
appCssUnplugin,
appScopedcssWebpack,
addonRewritecssRollup,
};
86 changes: 0 additions & 86 deletions ember-scoped-css/src/addon-css-rollup.js

This file was deleted.

46 changes: 0 additions & 46 deletions ember-scoped-css/src/addon-hbs-rollup.js

This file was deleted.

65 changes: 0 additions & 65 deletions ember-scoped-css/src/addon-js-unplugin.js

This file was deleted.

31 changes: 0 additions & 31 deletions ember-scoped-css/src/addon-rewritecss-rollup.js

This file was deleted.

4 changes: 2 additions & 2 deletions ember-scoped-css/src/app-css-livereload-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createUnplugin } from 'unplugin';
import path from 'path';
import { readFile } from 'fs/promises';
import { Compilation } from 'webpack';
import getPostfix from './lib/getPostfix.js';
import generateHash from './lib/generateAbsolutePathHash.js';

export default createUnplugin(({ loaders, htmlEntrypointInfo }) => {
return {
Expand Down Expand Up @@ -41,7 +41,7 @@ export default createUnplugin(({ loaders, htmlEntrypointInfo }) => {
css = await loader.bind({ resourcePath: cssPath })(css);
}
// random string; lenght is 8
const postfix = getPostfix(path.basename(cssPath));
const postfix = generateHash(path.basename(cssPath));

this.emitFile({
type: 'asset',
Expand Down
4 changes: 2 additions & 2 deletions ember-scoped-css/src/app-css-loader.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// import { createUnplugin } from 'unplugin';
import { basename } from 'path';
import fsExists from './lib/fsExists.js';
import getPostfix from './lib/getPostfix.js';
import generateHash from './lib/generateAbsolutePathHash.js';
import rewriteCss from './lib/rewriteCss.js';
// import path from 'path';

export default async function (code) {
const cssPath = this.resourcePath;
const cssFileName = basename(cssPath);
const postfix = getPostfix(cssPath);
const postfix = generateHash(cssPath);

const hbsPath = cssPath.replace('.css', '.hbs');
const gjsPath = cssPath.replace('.css', '.js');
Expand Down
4 changes: 2 additions & 2 deletions ember-scoped-css/src/app-js-unplugin.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { createUnplugin } from 'unplugin';
import replaceGlimmerAst from './lib/replaceGlimmerAst.js';
import path from 'path';
import getPostfix from './lib/getPostfix.js';
import generateHash from './lib/generateAbsolutePathHash.js';
import getClassesTagsFromCss from './lib/getClassesTagsFromCss.js';

function* iterateOpcodes(opcodes) {
Expand Down Expand Up @@ -48,7 +48,7 @@ export default createUnplugin(({ appDir }) => {

async transform(code, id) {
const cssPath = id.replace(/(\.js)|(\.hbs)/, '.css');
const postfix = getPostfix(cssPath);
const postfix = generateHash(cssPath);

return await replaceGlimmerAst(code, id, (opcodes, css) => {
const { classes, tags } = getClassesTagsFromCss(css);
Expand Down
4 changes: 2 additions & 2 deletions ember-scoped-css/src/app-scopedcss-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import rewriteCss from './lib/rewriteCss.js';
import { readFile, writeFile } from 'fs/promises';
import path from 'path';
import getPostfix from './lib/getPostfix.js';
import generateHash from './lib/generateAbsolutePathHash.js';
import fsExists from './lib/fsExists.js';
import getFiles from './lib/getFiles.js';

Expand Down Expand Up @@ -44,7 +44,7 @@ export default class {
continue;
}
const fileName = path.basename(file);
const postfix = getPostfix(fileName);
const postfix = generateHash(fileName);
const css = await readFile(file, 'utf-8');
const rewrittenCss = rewriteCss(css, postfix, fileName);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import generateHash from './generateHash.js';
import generateHash from './generateRelativePathHash.js';
import path from 'path';

export default function (cssFileName) {
Expand Down
4 changes: 2 additions & 2 deletions ember-scoped-css/src/lib/replaceScopedClass.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import recast from 'ember-template-recast';
import renameClass from './renameClass.js';
import getPostfix from './getPostfix.js';
import generateHash from './generateAbsolutePathHash.js';

export default function (hbs, templatePath) {
let ast = recast.parse(hbs);
let stack = [];
const cssPath = templatePath.replace(/(\.hbs)?\.js$/, '.css');
const postfix = getPostfix(cssPath);
const postfix = generateHash(cssPath);

recast.traverse(ast, {
All: {
Expand Down
Loading