Skip to content

Commit

Permalink
docs: update readme (#278)
Browse files Browse the repository at this point in the history
  • Loading branch information
Talljack committed Aug 2, 2024
1 parent b190cb1 commit 0bde687
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 86 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,7 @@ Remove({

// filters for transforming targets
include: [/\.[jt]sx?$/, /\.vue\??/],
exclude: [/node_modules/, /\.git/],
// transform source code
sourceMaps: true,
exclude: [/node_modules/, /\.git/]
})
```

Expand Down
2 changes: 1 addition & 1 deletion playground/rolldown/rolldown.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export default defineConfig({
sourcemap: true,
},
plugins: [
process.env.MODE === 'production' ? Rolldown({ sourceMaps: true }) : null,
process.env.MODE === 'production' ? Rolldown() : null,
].filter(Boolean),
})
26 changes: 13 additions & 13 deletions playground/rolldown/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
"jsx": "preserve", /* Specify what JSX code is generated. */
"jsx": "preserve", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": "./", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
Expand All @@ -24,10 +27,10 @@
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
/* Modules */
"module": "ESNext", /* Specify what module code is generated. */
// "rootDir": "./", /* Specify the root folder within your source files. */
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
"baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
"module": "ESNext", /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Specify the base directory to resolve non-relative module names. */
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
Expand Down Expand Up @@ -67,7 +70,7 @@
// "newLine": "crlf", /* Set the newline character for emitting files. */
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
"noEmitOnError": false, /* Disable emitting files if any type checking errors are reported. */
"noEmitOnError": false, /* Disable emitting files if any type checking errors are reported. */
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
Expand All @@ -76,12 +79,9 @@
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */

/* Type Checking */
"strict": true, /* Enable all strict type-checking options. */
"forceConsistentCasingInFileNames": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
Expand All @@ -103,7 +103,7 @@

/* Completeness */
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
"skipLibCheck": true /* Skip type checking all .d.ts files. */
},
"include": ["src/**/*"]
}
138 changes: 70 additions & 68 deletions playground/rspack/rspack.config.js
Original file line number Diff line number Diff line change
@@ -1,72 +1,74 @@
const rspack = require("@rspack/core");
const refreshPlugin = require("@rspack/plugin-react-refresh");
const isDev = process.env.NODE_ENV === "development";
const RspackPlugin = require('unplugin-remove/rspack').default;
/* eslint-disable @typescript-eslint/no-var-requires */
const rspack = require('@rspack/core')
const RefreshPlugin = require('@rspack/plugin-react-refresh')

const isDev = process.env.NODE_ENV === 'development'
const RspackPlugin = require('unplugin-remove/rspack').default
/**
* @type {import('@rspack/cli').Configuration}
*/
module.exports = {
context: __dirname,
entry: {
main: "./src/main.tsx"
},
resolve: {
extensions: ["...", ".ts", ".tsx", ".jsx"]
},
devServer: {
port: 3000,
hot: true,
open: true
},
module: {
rules: [
{
test: /\.svg$/,
type: "asset"
},
{
test: /\.(jsx?|tsx?)$/,
use: [
{
loader: "builtin:swc-loader",
options: {
sourceMap: true,
jsc: {
parser: {
syntax: "typescript",
tsx: true
},
transform: {
react: {
runtime: "automatic",
development: isDev,
refresh: isDev
}
}
},
env: {
targets: [
"chrome >= 87",
"edge >= 88",
"firefox >= 78",
"safari >= 14"
]
}
}
}
]
}
]
},
plugins: [
new rspack.DefinePlugin({
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV)
}),
new rspack.ProgressPlugin({}),
new rspack.HtmlRspackPlugin({
template: "./index.html"
}),
RspackPlugin(),
isDev ? new refreshPlugin() : null
].filter(Boolean)
};
context: __dirname,
entry: {
main: './src/main.tsx',
},
resolve: {
extensions: ['...', '.ts', '.tsx', '.jsx'],
},
devServer: {
port: 3000,
hot: true,
open: true,
},
module: {
rules: [
{
test: /\.svg$/,
type: 'asset',
},
{
test: /\.(jsx?|tsx?)$/,
use: [
{
loader: 'builtin:swc-loader',
options: {
sourceMap: true,
jsc: {
parser: {
syntax: 'typescript',
tsx: true,
},
transform: {
react: {
runtime: 'automatic',
development: isDev,
refresh: isDev,
},
},
},
env: {
targets: [
'chrome >= 87',
'edge >= 88',
'firefox >= 78',
'safari >= 14',
],
},
},
},
],
},
],
},
plugins: [
new rspack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
new rspack.ProgressPlugin({}),
new rspack.HtmlRspackPlugin({
template: './index.html',
}),
RspackPlugin(),
isDev ? new RefreshPlugin() : null,
].filter(Boolean),
}
1 change: 0 additions & 1 deletion src/core/unpluginContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export const createUnpluginContext = (options: Options = {}) => {
}
code = removeDebugger(code)
const { generatorCode } = removeConsoleLogs(code, options.consoleType, true)
console.log('generatorCode', generatorCode, id)
s = new MagicString(generatorCode)
return {
code: generatorCode,
Expand Down

0 comments on commit 0bde687

Please sign in to comment.